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
 

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 DownloadNextMod ()
 
static Action NetReload ()
 
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 14 of file ModNet.cs.

Member Function Documentation

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

Definition at line 86 of file ModNet.cs.

References Terraria.ModLoader.ModLoader.GetMod(), Terraria.ModLoader.ModLoader.Mods, and Terraria.ModLoader.ModNet.ModHeader.path.

86  {
87  var queue = new Queue<Mod>(syncMods.Where(m => m.Side == ModSide.Both));
88  while (queue.Count > 0) {
89  var depNames = ModOrganizer.dependencyCache[queue.Dequeue().Name];
90  foreach (var dep in depNames.Select(ModLoader.GetMod).Where(m => m.Side == ModSide.NoSync && !syncMods.Contains(m))) {
91  syncMods.Add(dep);
92  queue.Enqueue(dep);
93  }
94  }
95  }
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.DownloadNextMod ( )
staticprivate

Definition at line 169 of file ModNet.cs.

References Terraria.ModLoader.ModNet.ModHeader.name.

169  {
170  downloadingMod = downloadQueue.Dequeue();
171  downloadingFile = null;
172 
173  var p = new ModPacket(MessageID.ModFile);
174  p.Write(downloadingMod.name);
175  p.Send();
176  }
static Queue< ModHeader > downloadQueue
Definition: ModNet.cs:51
static ModHeader downloadingMod
Definition: ModNet.cs:52
static FileStream downloadingFile
Definition: ModNet.cs:53
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 Action Terraria.ModLoader.ModNet.NetReload ( )
staticprivate

Definition at line 272 of file ModNet.cs.

272  {
273  // Main.ActivePlayerFileData gets cleared during reload
274  var path = Main.ActivePlayerFileData.Path;
275  var isCloudSave = Main.ActivePlayerFileData.IsCloudSave;
276  return () => {
277  // re-select the current player
278  Player.GetFileData(path, isCloudSave).SetAsActive();
279  //from Netplay.ClientLoopSetup
280  Main.player[Main.myPlayer].hostile = false;
281  Main.clientPlayer = (Player)Main.player[Main.myPlayer].clientClone();
282 
283  Main.menuMode = 10;
284  OnModsDownloaded(false);
285  };
286  }
static void OnModsDownloaded(bool needsReload)
Definition: ModNet.cs:257
static void Terraria.ModLoader.ModNet.OnModsDownloaded ( bool  needsReload)
staticprivate

Definition at line 257 of file ModNet.cs.

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

257  {
258  if (needsReload) {
259  ModLoader.OnSuccessfulLoad = NetReload();
260  ModLoader.Reload();
261  return;
262  }
263 
264  downloadingMod = null;
265  netMods = null;
266  foreach (var mod in ModLoader.Mods)
267  mod.netID = -1;
268 
269  new ModPacket(MessageID.SyncMods).Send();
270  }
static ModHeader downloadingMod
Definition: ModNet.cs:52
static Action NetReload()
Definition: ModNet.cs:272
static Mod[] netMods
Definition: ModNet.cs:42

+ Here is the call graph for this function:

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

Definition at line 300 of file ModNet.cs.

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

300  {
301  var mods = ModLoader.Mods;
302  var list = new List<Mod>();
303  var n = reader.ReadInt32();
304  for (short i = 0; i < n; i++) {
305  var name = reader.ReadString();
306  var mod = mods.SingleOrDefault(m => m.Name == name);
307  list.Add(mod);
308  if (mod != null) //nosync mod that doesn't exist on the client
309  mod.netID = i;
310  }
311  netMods = list.ToArray();
313 
314  ItemLoader.ReadNetGlobalOrder(reader);
315  WorldHooks.ReadNetWorldOrder(reader);
316  }
static void SetupDiagnostics()
Definition: ModNet.cs:370
static Mod[] netMods
Definition: ModNet.cs:42

+ Here is the call graph for this function:

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

Definition at line 370 of file ModNet.cs.

References Terraria.ModLoader.Mod.Name.

370  {
371  rxMsgType = new int[netMods.Length];
372  rxDataType = new int[netMods.Length];
373  txMsgType = new int[netMods.Length];
374  txDataType = new int[netMods.Length];
375  }
static int[] rxDataType
Definition: ModNet.cs:366
static int[] txDataType
Definition: ModNet.cs:368
static Mod[] netMods
Definition: ModNet.cs:42
static int[] txMsgType
Definition: ModNet.cs:367
static int[] rxMsgType
Definition: ModNet.cs:365

Member Data Documentation

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

Definition at line 178 of file ModNet.cs.

FileStream Terraria.ModLoader.ModNet.downloadingFile
staticprivate

Definition at line 53 of file ModNet.cs.

long Terraria.ModLoader.ModNet.downloadingLength
staticprivate

Definition at line 54 of file ModNet.cs.

ModHeader Terraria.ModLoader.ModNet.downloadingMod
staticprivate

Definition at line 52 of file ModNet.cs.

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

Definition at line 51 of file ModNet.cs.

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

Definition at line 49 of file ModNet.cs.

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

Mod [] Terraria.ModLoader.ModNet.netMods
staticprivate

Definition at line 42 of file ModNet.cs.

int [] Terraria.ModLoader.ModNet.rxDataType
static

Definition at line 366 of file ModNet.cs.

int [] Terraria.ModLoader.ModNet.rxMsgType
static

Definition at line 365 of file ModNet.cs.

int [] Terraria.ModLoader.ModNet.txDataType
static

Definition at line 368 of file ModNet.cs.

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

int [] Terraria.ModLoader.ModNet.txMsgType
static

Definition at line 367 of file ModNet.cs.

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

Property Documentation