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

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

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

References Terraria.ModLoader.ModNet.ModHeader.path.

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

Definition at line 212 of file ModNet.cs.

References Terraria.ModLoader.ModNet.ModHeader.name.

212  {
213  downloadingMod = downloadQueue.Dequeue();
214  downloadingFile = null;
215 
216  var p = new ModPacket(MessageID.ModFile);
217  p.Write(downloadingMod.name);
218  p.Send();
219  }
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 313 of file ModNet.cs.

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

313  {
314  if (needsReload) {
315  ModLoader.OnSuccessfulLoad = NetReload();
316  ModLoader.Reload();
317  return;
318  }
319 
320  // 3 cases: Needs reload because different mod sets, needs reload because config, config matches up.
321  foreach (var pendingConfig in pendingConfigs)
322  {
323  var activeConfig = ConfigManager.GetConfig(pendingConfig);
324  JsonConvert.PopulateObject(pendingConfig.json, activeConfig, ConfigManager.serializerSettingsCompact);
325  }
326  if (ConfigManager.AnyModNeedsReload())
327  {
328  ModLoader.OnSuccessfulLoad = NetReload();
329  ModLoader.Reload();
330  return;
331  }
332  foreach (var pendingConfig in pendingConfigs) {
333  var activeConfig = ConfigManager.GetConfig(pendingConfig);
334  activeConfig.OnChanged();
335  }
336 
337  downloadingMod = null;
338  netMods = null;
339  foreach (var mod in ModLoader.Mods)
340  mod.netID = -1;
341 
342  new ModPacket(MessageID.SyncMods).Send();
343  }
static ModHeader downloadingMod
Definition: ModNet.cs:69
virtual void OnChanged()
This hook is called anytime new config values have been set and are ready to take effect...
Definition: ModConfig.cs:38
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 373 of file ModNet.cs.

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

373  {
374  var mods = ModLoader.Mods;
375  var list = new List<Mod>();
376  var n = reader.ReadInt32();
377  for (short i = 0; i < n; i++) {
378  var name = reader.ReadString();
379  var mod = mods.SingleOrDefault(m => m.Name == name);
380  list.Add(mod);
381  if (mod != null) //nosync mod that doesn't exist on the client
382  mod.netID = i;
383  }
384  netMods = list.ToArray();
386 
387  ItemLoader.ReadNetGlobalOrder(reader);
388  WorldHooks.ReadNetWorldOrder(reader);
389  }
static void SetupDiagnostics()
Definition: ModNet.cs:443
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 443 of file ModNet.cs.

References Terraria.ModLoader.Mod.Name.

443  {
444  rxMsgType = new int[netMods.Length];
445  rxDataType = new int[netMods.Length];
446  txMsgType = new int[netMods.Length];
447  txDataType = new int[netMods.Length];
448  }
static int[] rxDataType
Definition: ModNet.cs:439
static int[] txDataType
Definition: ModNet.cs:441
static Mod[] netMods
Definition: ModNet.cs:58
static int[] txMsgType
Definition: ModNet.cs:440
static int[] rxMsgType
Definition: ModNet.cs:438

Member Data Documentation

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

Definition at line 221 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 439 of file ModNet.cs.

int [] Terraria.ModLoader.ModNet.rxMsgType
static

Definition at line 438 of file ModNet.cs.

int [] Terraria.ModLoader.ModNet.txDataType
static

Definition at line 441 of file ModNet.cs.

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

int [] Terraria.ModLoader.ModNet.txMsgType
static

Definition at line 440 of file ModNet.cs.

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

Property Documentation