Terraria ModLoader  0.11.1
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 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 StreamingDownloadRequest _currentRequest
 
static ModHeader downloadingHeader
 
static Queue< ModHeader > downloadQueue = new Queue<ModHeader>()
 
static Mod [] netMods
 

Detailed Description

Definition at line 17 of file ModNet.cs.

Member Function Documentation

◆ AddNoSyncDeps()

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

Definition at line 101 of file ModNet.cs.

101  {
102  var queue = new Queue<Mod>(syncMods.Where(m => m.Side == ModSide.Both));
103  while (queue.Count > 0) {
104  foreach (var dep in AssemblyManager.GetDependencies(queue.Dequeue())) {
105  if (dep.Side == ModSide.NoSync && !syncMods.Contains(dep)) {
106  syncMods.Add(dep);
107  queue.Enqueue(dep);
108  }
109  }
110  }
111  }
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

◆ DownloadNextMod()

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

Definition at line 225 of file ModNet.cs.

References Terraria.ModLoader.ModLoader.GetMod().

225  {
226  downloadingHeader = downloadQueue.Dequeue();
227  var p = new ModPacket(MessageID.ModFile);
228  p.Write(downloadingHeader.name);
229  p.Send();
230  }
static Queue< ModHeader > downloadQueue
Definition: ModNet.cs:67
static ModHeader downloadingHeader
Definition: ModNet.cs:224
+ Here is the call graph for this function:

◆ GetMod()

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

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

+ Here is the caller graph for this function:

◆ IsModdedClient()

static bool Terraria.ModLoader.ModNet.IsModdedClient ( int  i)
static

◆ OnModsDownloaded()

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

Definition at line 291 of file ModNet.cs.

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

291  {
292  if (needsReload) {
293  ModLoader.OnSuccessfulLoad = NetReload();
294  ModLoader.Reload();
295  return;
296  }
297 
298  netMods = null;
299  foreach (var mod in ModLoader.Mods)
300  mod.netID = -1;
301 
302  new ModPacket(MessageID.SyncMods).Send();
303  }
static Mod [] netMods
Definition: ModNet.cs:58
+ Here is the call graph for this function:

◆ ReadNetIDs()

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

Definition at line 333 of file ModNet.cs.

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

333  {
334  var mods = ModLoader.Mods;
335  var list = new List<Mod>();
336  var n = reader.ReadInt32();
337  for (short i = 0; i < n; i++) {
338  var name = reader.ReadString();
339  var mod = mods.SingleOrDefault(m => m.Name == name);
340  list.Add(mod);
341  if (mod != null) //nosync mod that doesn't exist on the client
342  mod.netID = i;
343  }
344  netMods = list.ToArray();
346 
347  ItemLoader.ReadNetGlobalOrder(reader);
348  WorldHooks.ReadNetWorldOrder(reader);
349  }
static void SetupDiagnostics()
Definition: ModNet.cs:403
static Mod [] netMods
Definition: ModNet.cs:58
+ Here is the call graph for this function:

◆ SendServerConfigs()

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

Definition at line 113 of file ModNet.cs.

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

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

◆ SetupDiagnostics()

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

Definition at line 403 of file ModNet.cs.

References Terraria.ModLoader.Mod.Name.

403  {
404  rxMsgType = new int[netMods.Length];
405  rxDataType = new int[netMods.Length];
406  txMsgType = new int[netMods.Length];
407  txDataType = new int[netMods.Length];
408  }
static int [] rxDataType
Definition: ModNet.cs:399
static int [] txDataType
Definition: ModNet.cs:401
static Mod [] netMods
Definition: ModNet.cs:58
static int [] txMsgType
Definition: ModNet.cs:400
static int [] rxMsgType
Definition: ModNet.cs:398

Member Data Documentation

◆ _currentRequest

StreamingDownloadRequest Terraria.ModLoader.ModNet._currentRequest
staticprivate

Definition at line 260 of file ModNet.cs.

◆ downloadingHeader

ModHeader Terraria.ModLoader.ModNet.downloadingHeader
staticprivate

Definition at line 224 of file ModNet.cs.

◆ downloadQueue

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

Definition at line 67 of file ModNet.cs.

◆ NetModCount

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

Definition at line 65 of file ModNet.cs.

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

◆ netMods

Mod [] Terraria.ModLoader.ModNet.netMods
staticprivate

Definition at line 58 of file ModNet.cs.

◆ rxDataType

int [] Terraria.ModLoader.ModNet.rxDataType
static

Definition at line 399 of file ModNet.cs.

◆ rxMsgType

int [] Terraria.ModLoader.ModNet.rxMsgType
static

Definition at line 398 of file ModNet.cs.

◆ txDataType

int [] Terraria.ModLoader.ModNet.txDataType
static

Definition at line 401 of file ModNet.cs.

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

◆ txMsgType

int [] Terraria.ModLoader.ModNet.txMsgType
static

Definition at line 400 of file ModNet.cs.

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

Property Documentation

◆ AllowVanillaClients