Terraria ModLoader  0.10.1.5
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 SetupDiagnostics ()
 

Private Attributes

const int CHUNK_SIZE = 16384
 

Static Private Attributes

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

Detailed Description

Definition at line 16 of file ModNet.cs.

Member Function Documentation

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

Definition at line 121 of file ModNet.cs.

References Terraria.ModLoader.ModLoader.GetMod(), and Terraria.ModLoader.ModLoader.Mods.

121  {
122  var queue = new Queue<Mod>(syncMods.Where(m => m.Side == ModSide.Both));
123  while (queue.Count > 0) {
124  var depNames = ModOrganizer.dependencyCache[queue.Dequeue().Name];
125  foreach (var dep in depNames.Select(ModLoader.GetMod).Where(m => m.Side == ModSide.NoSync && !syncMods.Contains(m))) {
126  syncMods.Add(dep);
127  queue.Enqueue(dep);
128  }
129  }
130  }
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

+ Here is the call graph for this function:

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

Definition at line 299 of file ModNet.cs.

References Terraria.ModLoader.ModNet.ModHeader.path.

299  {
300  try {
301  downloadingFile?.Close();
302  File.Delete(downloadingMod.path);
303  }
304  catch { }
305  downloadingMod = null;
306  Netplay.disconnect = true;
307  Main.menuMode = 0;
308  }
static ModHeader downloadingMod
Definition: ModNet.cs:69
static FileStream downloadingFile
Definition: ModNet.cs:70
static void Terraria.ModLoader.ModNet.DownloadNextMod ( )
staticprivate

Definition at line 211 of file ModNet.cs.

References Terraria.ModLoader.ModNet.ModHeader.name.

211  {
212  downloadingMod = downloadQueue.Dequeue();
213  downloadingFile = null;
214 
215  var p = new ModPacket(MessageID.ModFile);
216  p.Write(downloadingMod.name);
217  p.Send();
218  }
static Queue< ModHeader > downloadQueue
Definition: ModNet.cs:67
static ModHeader downloadingMod
Definition: ModNet.cs:69
static FileStream downloadingFile
Definition: ModNet.cs:70
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 310 of file ModNet.cs.

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

310  {
311  if (needsReload) {
312  ModLoader.OnSuccessfulLoad = NetReload();
313  ModLoader.Reload();
314  return;
315  }
316 
317  // 3 cases: Needs reload because different mod sets, needs reload because config, config matches up.
318  foreach (var config in pendingConfigs)
319  {
320  var configInstance = ConfigManager.GetConfig(ModLoader.GetMod(config.modname), config.configname);
321  JsonConvert.PopulateObject(config.json, configInstance, ConfigManager.serializerSettingsCompact);
322  }
323  if (ConfigManager.AnyModNeedsReload())
324  {
325  ModLoader.OnSuccessfulLoad = NetReload();
326  ModLoader.Reload();
327  return;
328  }
329 
330  downloadingMod = null;
331  netMods = null;
332  foreach (var mod in ModLoader.Mods)
333  mod.netID = -1;
334 
335  new ModPacket(MessageID.SyncMods).Send();
336  }
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 366 of file ModNet.cs.

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

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

+ Here is the call graph for this function:

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

Definition at line 436 of file ModNet.cs.

References Terraria.ModLoader.Mod.Name.

436  {
437  rxMsgType = new int[netMods.Length];
438  rxDataType = new int[netMods.Length];
439  txMsgType = new int[netMods.Length];
440  txDataType = new int[netMods.Length];
441  }
static int[] rxDataType
Definition: ModNet.cs:432
static int[] txDataType
Definition: ModNet.cs:434
static Mod[] netMods
Definition: ModNet.cs:58
static int[] txMsgType
Definition: ModNet.cs:433
static int[] rxMsgType
Definition: ModNet.cs:431

Member Data Documentation

const int Terraria.ModLoader.ModNet.CHUNK_SIZE = 16384
private

Definition at line 220 of file ModNet.cs.

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 432 of file ModNet.cs.

int [] Terraria.ModLoader.ModNet.rxMsgType
static

Definition at line 431 of file ModNet.cs.

int [] Terraria.ModLoader.ModNet.txDataType
static

Definition at line 434 of file ModNet.cs.

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

int [] Terraria.ModLoader.ModNet.txMsgType
static

Definition at line 433 of file ModNet.cs.

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

Property Documentation