Terraria ModLoader  0.11.4
A framework for Terraria mods
Terraria.ModLoader.ModNet Class Reference
+ Collaboration diagram for Terraria.ModLoader.ModNet:

Classes

class  ModHeader
 
class  NetConfig
 

Static Public Member Functions

static Mod GetMod (int netID)
 
static bool IsModdedClient (int i)
 

Static Public Attributes

static int NetModCount => netMods.Length
 
static int[] rxDataType
 
static int[] rxMsgType
 
static int[] txDataType
 
static int[] txMsgType
 

Properties

static bool AllowVanillaClients [get, set]
 

Static Private Member Functions

static void AddNoSyncDeps (List< Mod > syncMods)
 
static void CancelDownload ()
 
static void DownloadNextMod ()
 
static void OnModsDownloaded (bool needsReload)
 
static void ReadNetIDs (BinaryReader reader)
 
static void SendServerConfigs (ModPacket p, Mod mod)
 
static void SetupDiagnostics ()
 

Static Private Attributes

static FileStream downloadingFile
 
static long downloadingLength
 
static ModHeader downloadingMod
 
static Queue< ModHeader > downloadQueue = new Queue<ModHeader>()
 
static Mod[] netMods
 

Detailed Description

Definition at line 17 of file ModNet.cs.

Member Function Documentation

static void Terraria.ModLoader.ModNet.AddNoSyncDeps ( List< Mod syncMods)
staticprivate

Definition at line 104 of file ModNet.cs.

104  {
105  var queue = new Queue<Mod>(syncMods.Where(m => m.Side == ModSide.Both));
106  while (queue.Count > 0) {
107  foreach (var dep in AssemblyManager.GetDependencies(queue.Dequeue())) {
108  if (dep.Side == ModSide.NoSync && !syncMods.Contains(dep)) {
109  syncMods.Add(dep);
110  queue.Enqueue(dep);
111  }
112  }
113  }
114  }
ModSide
A ModSide enum defines how mods are synced between clients and servers. You can set your mod&#39;s ModSid...
Definition: ModSide.cs:4
static void Terraria.ModLoader.ModNet.CancelDownload ( )
staticprivate

Definition at line 316 of file ModNet.cs.

316  {
317  try {
318  downloadingFile?.Close();
319  File.Delete(downloadingMod.path);
320  }
321  catch { }
322  downloadingMod = null;
323  Netplay.disconnect = true;
324  }
static ModHeader downloadingMod
Definition: ModNet.cs:69
static FileStream downloadingFile
Definition: ModNet.cs:70
static void Terraria.ModLoader.ModNet.DownloadNextMod ( )
staticprivate

Definition at line 226 of file ModNet.cs.

References Terraria.ModLoader.Mod.Close(), and Terraria.ModLoader.ModLoader.GetMod().

226  {
227  downloadingMod = downloadQueue.Dequeue();
228  downloadingFile = null;
229  var p = new ModPacket(MessageID.ModFile);
230  p.Write(downloadingMod.name);
231  p.Send();
232  }
static Queue< ModHeader > downloadQueue
Definition: ModNet.cs:67
static ModHeader downloadingMod
Definition: ModNet.cs:69
static FileStream downloadingFile
Definition: ModNet.cs:70

+ Here is the call graph for this function:

static Mod Terraria.ModLoader.ModNet.GetMod ( int  netID)
static

Referenced by Terraria.ModLoader.ItemLoader.NeedsModSaving().

+ Here is the caller graph for this function:

static bool Terraria.ModLoader.ModNet.IsModdedClient ( int  i)
static
static void Terraria.ModLoader.ModNet.OnModsDownloaded ( bool  needsReload)
staticprivate

Definition at line 326 of file ModNet.cs.

References Terraria.ModLoader.ModLoader.Mods, and Terraria.ModLoader.ModPacket.Send().

326  {
327  if (needsReload) {
328  ModLoader.OnSuccessfulLoad = NetReload();
329  ModLoader.Reload();
330  return;
331  }
332 
333  downloadingMod = null;
334  netMods = null;
335  foreach (var mod in ModLoader.Mods)
336  mod.netID = -1;
337 
338  new ModPacket(MessageID.SyncMods).Send();
339  }
static ModHeader downloadingMod
Definition: ModNet.cs:69
static Mod[] netMods
Definition: ModNet.cs:58

+ Here is the call graph for this function:

static void Terraria.ModLoader.ModNet.ReadNetIDs ( BinaryReader  reader)
staticprivate

Definition at line 369 of file ModNet.cs.

References Terraria.ModLoader.Mod.HijackSendData(), and Terraria.ModLoader.ModLoader.Mods.

369  {
370  var mods = ModLoader.Mods;
371  var list = new List<Mod>();
372  var n = reader.ReadInt32();
373  for (short i = 0; i < n; i++) {
374  var name = reader.ReadString();
375  var mod = mods.SingleOrDefault(m => m.Name == name);
376  list.Add(mod);
377  if (mod != null) //nosync mod that doesn't exist on the client
378  mod.netID = i;
379  }
380  netMods = list.ToArray();
382 
383  ItemLoader.ReadNetGlobalOrder(reader);
384  WorldHooks.ReadNetWorldOrder(reader);
385  }
static void SetupDiagnostics()
Definition: ModNet.cs:439
static Mod[] netMods
Definition: ModNet.cs:58

+ Here is the call graph for this function:

static void Terraria.ModLoader.ModNet.SendServerConfigs ( ModPacket  p,
Mod  mod 
)
staticprivate

Definition at line 116 of file ModNet.cs.

References Terraria.ModLoader.ModLoader.Mods, and Terraria.ModLoader.Config.ModConfig.OnChanged().

116  {
117  if (!ConfigManager.Configs.TryGetValue(mod, out var configs)) {
118  p.Write(0);
119  return;
120  }
121 
122  var serverConfigs = configs.Where(x => x.Mode == ConfigScope.ServerSide).ToArray();
123  p.Write(serverConfigs.Length);
124  foreach (var config in serverConfigs) {
125  string json = JsonConvert.SerializeObject(config, ConfigManager.serializerSettingsCompact);
126  Logging.Terraria.Info($"Sending Server Config {config.Name}: {json}");
127 
128  p.Write(config.Name);
129  p.Write(json);
130  }
131  }
ConfigScope
Each ModConfig class has a different scope. Failure to use the correct mode will lead to bugs...
Definition: ModConfig.cs:91

+ Here is the call graph for this function:

static void Terraria.ModLoader.ModNet.SetupDiagnostics ( )
staticprivate

Definition at line 439 of file ModNet.cs.

References Terraria.ModLoader.Mod.Name.

439  {
440  rxMsgType = new int[netMods.Length];
441  rxDataType = new int[netMods.Length];
442  txMsgType = new int[netMods.Length];
443  txDataType = new int[netMods.Length];
444  }
static int[] rxDataType
Definition: ModNet.cs:435
static int[] txDataType
Definition: ModNet.cs:437
static Mod[] netMods
Definition: ModNet.cs:58
static int[] txMsgType
Definition: ModNet.cs:436
static int[] rxMsgType
Definition: ModNet.cs:434

Member Data Documentation

FileStream Terraria.ModLoader.ModNet.downloadingFile
staticprivate

Definition at line 70 of file ModNet.cs.

long Terraria.ModLoader.ModNet.downloadingLength
staticprivate

Definition at line 71 of file ModNet.cs.

ModHeader Terraria.ModLoader.ModNet.downloadingMod
staticprivate

Definition at line 69 of file ModNet.cs.

Queue<ModHeader> Terraria.ModLoader.ModNet.downloadQueue = new Queue<ModHeader>()
staticprivate

Definition at line 67 of file ModNet.cs.

int Terraria.ModLoader.ModNet.NetModCount => netMods.Length
static

Definition at line 65 of file ModNet.cs.

Referenced by Terraria.ModLoader.Mod.GetPacket().

Mod [] Terraria.ModLoader.ModNet.netMods
staticprivate

Definition at line 58 of file ModNet.cs.

int [] Terraria.ModLoader.ModNet.rxDataType
static

Definition at line 435 of file ModNet.cs.

int [] Terraria.ModLoader.ModNet.rxMsgType
static

Definition at line 434 of file ModNet.cs.

int [] Terraria.ModLoader.ModNet.txDataType
static

Definition at line 437 of file ModNet.cs.

Referenced by Terraria.ModLoader.ModPacket.Send().

int [] Terraria.ModLoader.ModNet.txMsgType
static

Definition at line 436 of file ModNet.cs.

Referenced by Terraria.ModLoader.ModPacket.Send().

Property Documentation