Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
plugindiagmenuserver.c
Go to the documentation of this file.
1 // For modding, see PluginDiagMenuModding.c
2 // !!! MODDING DISCLAIMER: These are debug functionality files, if you are thinking about modding the vanilla ones, do so at your own risk
3 // These files will not be maintained with the thought of "what if a modder modded this" (Excluding the modding functionality of course)
4 // Which is why the modding functionality was developed with the thought of the modded ones having their own isolated safe space
5 
7 {
8 #ifdef DIAG_DEVELOPER
9  static ref map<Man, int> m_Subscribers = new map<Man, int>;
10 
11  // A bit of a hack, because SP creates both Client and Server Plugins
12  override private void RegisterDiags()
13  {
14  if (GetGame().IsMultiplayer())
15  {
16  super.RegisterDiags();
17  }
18  }
19 
20  //---------------------------------------------
21  override void OnRPC(PlayerBase player, int rpc_type, ParamsReadContext ctx)
22  {
23  super.OnRPC(player, rpc_type, ctx);
24 
25  switch (rpc_type)
26  {
27  case ERPCs.DEV_DIAGMENU_SUBSCRIBE:
28  {
29  if (ctx.Read(CachedObjectsParams.PARAM1_INT))
30  {
31  int newMask = CachedObjectsParams.PARAM1_INT.param1;
32  int currentMask = m_Subscribers.Get(player);
33 
34  if (newMask != currentMask)
35  {
36  if (newMask == 0)
37  {
38  m_Subscribers.Remove(player);
39  }
40  else
41  {
42  m_Subscribers.Set(player, newMask);
43  }
44  }
45  }
46  break;
47  }
48  }
49  }
50 
51  //---------------------------------------------
52  static void SendDataToSubscribersServer(Object target, ESubscriberSystems system, int rpc_type, Param data, bool guaranteed = true)
53  {
54  for (int i = 0; i < m_Subscribers.Count(); ++i)
55  {
56  Man man = m_Subscribers.GetKey(i);
57  if (man)
58  {
59  int subscribedSystems = m_Subscribers.Get(man);
60  if (system & subscribedSystems)
61  {
62  GetGame().RPCSingleParam( target, rpc_type, data, guaranteed, man.GetIdentity() );
63  }
64  }
65  else
66  {
67  m_Subscribers.RemoveElement(i);
68  i--;
69  }
70  }
71  }
72 #endif
73 }
GetGame
proto native CGame GetGame()
Param
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition: param.c:11
CachedObjectsParams
Definition: utilityclasses.c:9
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
OnRPC
void OnRPC(ParamsReadContext ctx)
Definition: displaystatus.c:216
PlayerBase
Definition: playerbaseclient.c:1
map
map
Definition: controlsxboxnew.c:3
Object
Definition: objecttyped.c:1
PluginDiagMenuServer
Definition: plugindiagmenuserver.c:6
ERPCs
ERPCs
Definition: erpcs.c:1
PluginDiagMenu
Definition: plugindiagmenu.c:29