Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
cfggameplayhandler.c
Go to the documentation of this file.
2 {
3  private static string m_Path = "$mission:cfggameplay.json";
4  private static ref array<ref ITEM_DataBase> m_Items = new array<ref ITEM_DataBase>();
5 
6  static ref CfgGameplayJson m_Data = new CfgGameplayJson();
7 
8  //---------------------------------------------------------------------------------------
9  static void RegisterItem(ITEM_DataBase item)
10  {
11  m_Items.Insert(item);
12  }
13  //---------------------------------------------------------------------------------------
14  private static void ValidateItems()
15  {
16  foreach (ITEM_DataBase item : m_Items)
17  {
18  if (!item.ValidateServer())
19  {
20  string itemName = item.Type().ToString();
21  itemName.Replace("ITEM_", "");
22  PrintToRPT("Validation failed during loading of 'cfggameplay.json' for " + itemName);
23  item.InitServer();
24  }
25  }
26  }
27 
28  //---------------------------------------------------------------------------------------
29  private static void InitData()
30  {
31  foreach (ITEM_DataBase item:m_Items)
32  {
33  item.InitServer();
34  }
35  }
36  #ifdef DEVELOPER
37  //---------------------------------------------------------------------------------------
38  static void Output()
39  {
40  Print(m_Items.Count());
41  }
42  #endif
43  //---------------------------------------------------------------------------------------
44  static bool LoadData()
45  {
46  if (!FileExist(m_Path))
47  {
48  m_Path = "";
49  GetGame().GetWorldName(m_Path);
50  m_Path = string.Format("dz/worlds/%1/ce/cfggameplay.json", m_Path);
51  }
52 
53  bool cfgGameplayFileEnabled = GetGame().ServerConfigGetInt( "enableCfgGameplayFile" );
54 
55  #ifdef DIAG_DEVELOPER
56  if (!GetGame().IsDedicatedServer())
57  {
58  cfgGameplayFileEnabled = true;
59  }
60  #endif
61 
62  if (!cfgGameplayFileEnabled || !FileExist(m_Path))
63  {
64  m_Data.InitServer();//legacy call
65  InitData();
66  OnLoaded();
67  return false;
68  }
69 
70  string errorMessage;
71  if (!JsonFileLoader<CfgGameplayJson>.LoadFile(m_Path, m_Data, errorMessage))
72  ErrorEx(errorMessage);
73 
74  ValidateItems();
75  OnLoaded();
76 
77  return true;
78  }
79 
80  //---------------------------------------------------------------------------------------
81  static void OnLoaded()
82  {
83  GetGame().GetMission().OnGameplayDataHandlerLoad();
84  DayZGame.Cast(GetGame()).OnGameplayDataHandlerLoad();
85  }
86 
87  //---------------------------------------------------------------------------------------
88  static void SyncDataSend(notnull Man player)
89  {
90  GetGame().RPCSingleParam(player, ERPCs.RPC_CFG_GAMEPLAY_SYNC, new Param1<CfgGameplayJson>(m_Data), true, player.GetIdentity());
91  }
92 
93  //---------------------------------------------------------------------------------------
94  static void SyncDataSendEx(notnull PlayerIdentity identity)
95  {
96  //Debug.Log("SyncDataSendEx");
97  GetGame().RPCSingleParam(null, ERPCs.RPC_CFG_GAMEPLAY_SYNC, new Param1<CfgGameplayJson>(m_Data), true, identity);
98  }
99 
100  //---------------------------------------------------------------------------------------
101 
102  static void OnRPC(Man player, ParamsReadContext ctx)
103  {
104  Param1<CfgGameplayJson> data = new Param1<CfgGameplayJson>(null);
105 
106  if ( ctx.Read(data) )
107  {
108  m_Data = data.param1;
109  }
110  else
111  {
112  ErrorEx("CfgGameplayHandler - client failed to read incoming data");
113  }
114  }
115 
116 
117  // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
121  // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
122 
123  //========================
124  // !!! ONLY GETTERS BELLOW
125  //========================
126 
127 
128  //----------------------------------------------------------------------------------
129  static bool GetDisablePersonalLight()
130  {
131  return m_Data.PlayerData.disablePersonalLight;
132  }
133  //----------------------------------------------------------------------------------
134 
135  //------------------------------- WorldsData -----------------------------------
136  static int GetLightingConfig()
137  {
138  return m_Data.WorldsData.lightingConfig;
139  }
140 
141  static TStringArray GetObjectSpawnersArr()
142  {
143  return m_Data.WorldsData.objectSpawnersArr;
144  }
145 
146  static array<float> GetEnvironmentMinTemps()
147  {
148  return m_Data.WorldsData.environmentMinTemps;
149  }
150 
151  static array<float> GetEnvironmentMaxTemps()
152  {
153  return m_Data.WorldsData.environmentMaxTemps;
154  }
155  static array<float> GetWetnessWeightModifiers()
156  {
157  return m_Data.WorldsData.wetnessWeightModifiers;
158  }
159  //----------------------------------------------------------------------------------
160 
161 
162  static bool GetDisableBaseDamage()
163  {
164  return m_Data.GeneralData.disableBaseDamage;
165  }
166  //----------------------------------------------------------------------------------
167 
168  static bool GetDisableContainerDamage()
169  {
170  return m_Data.GeneralData.disableContainerDamage;
171  }
172  //----------------------------------------------------------------------------------
173  static bool GetDisableRespawnDialog()
174  {
175  return m_Data.GeneralData.disableRespawnDialog;
176  }
177  //----------------------------------------------------------------------------------
178  static bool GetDisableRespawnInUnconsciousness()
179  {
180  return m_Data.GeneralData.disableRespawnInUnconsciousness;
181  }
182  //----------------------------------------------------------------------------------
183  static float GetSprintStaminaModifierErc()
184  {
185  return m_Data.PlayerData.StaminaData.sprintStaminaModifierErc;
186  }
187  //----------------------------------------------------------------------------------
188  static float GetSprintStaminaModifierCro()
189  {
190  return m_Data.PlayerData.StaminaData.sprintStaminaModifierCro;
191  }
192  //----------------------------------------------------------------------------------
193  static float GetSprintSwimmingStaminaModifier()
194  {
195  return m_Data.PlayerData.StaminaData.sprintSwimmingStaminaModifier;
196  }//----------------------------------------------------------------------------------
197  static float GetSprintLadderStaminaModifier()
198  {
199  return m_Data.PlayerData.StaminaData.sprintLadderStaminaModifier;
200  }
201  //----------------------------------------------------------------------------------
202  static float GetStaminaWeightLimitThreshold()
203  {
204  return m_Data.PlayerData.StaminaData.staminaWeightLimitThreshold;
205  }
206  //----------------------------------------------------------------------------------
207  static float GetStaminaMax()
208  {
209  return m_Data.PlayerData.StaminaData.staminaMax;
210  }
211  //----------------------------------------------------------------------------------
212  static float GetStaminaKgToStaminaPercentPenalty()
213  {
214  return m_Data.PlayerData.StaminaData.staminaKgToStaminaPercentPenalty;
215  }
216  //----------------------------------------------------------------------------------
217  static float GetStaminaMinCap()
218  {
219  return m_Data.PlayerData.StaminaData.staminaMinCap;
220  }
221  //----------------------------------------------------------------------------------
222  static float GetMeleeStaminaModifier()
223  {
224  return m_Data.PlayerData.StaminaData.meleeStaminaModifier;
225  }
226  //----------------------------------------------------------------------------------
227  static float GetObstacleTraversalStaminaModifier()
228  {
229  return m_Data.PlayerData.StaminaData.obstacleTraversalStaminaModifier;
230  }
231  //----------------------------------------------------------------------------------
232  static float GetHoldBreathStaminaModifier()
233  {
234  return m_Data.PlayerData.StaminaData.holdBreathStaminaModifier;
235  }
236  //----------------------------------------------------------------------------------
237  static float GetMovementTimeToStrafeJog()
238  {
239  return Math.Max(0.01, m_Data.PlayerData.MovementData.timeToStrafeJog);
240  }
241  //----------------------------------------------------------------------------------
242  static float GetMovementTimeToSprint()
243  {
244  return Math.Max(0.01, m_Data.PlayerData.MovementData.timeToSprint);
245  }
246  //----------------------------------------------------------------------------------
247  static float GetMovementTimeToStrafeSprint()
248  {
249  return Math.Max(0.01, m_Data.PlayerData.MovementData.timeToStrafeSprint);
250  }
251  //----------------------------------------------------------------------------------
252  static float GetMovementRotationSpeedJog()
253  {
254  return Math.Max(0.01, m_Data.PlayerData.MovementData.rotationSpeedJog);
255  }
256  //----------------------------------------------------------------------------------
257  static float GetMovementRotationSpeedSprint()
258  {
259  return Math.Max(0.01, m_Data.PlayerData.MovementData.rotationSpeedSprint);
260  }
261  //----------------------------------------------------------------------------------
262  static bool GetDisable2dMap()
263  {
264  return m_Data.PlayerData.disable2dMap;
265  }
266  //----------------------------------------------------------------------------------
267  static bool GetDisableIsCollidingBBoxCheck()
268  {
269  return m_Data.BaseBuildingData.HologramData.disableIsCollidingBBoxCheck;
270  }
271  //----------------------------------------------------------------------------------
272  static bool GetDisableIsCollidingPlayerCheck()
273  {
274  return m_Data.BaseBuildingData.HologramData.disableIsCollidingPlayerCheck;
275  }
276  //----------------------------------------------------------------------------------
277  static bool GetDisableIsClippingRoofCheck()
278  {
279  return m_Data.BaseBuildingData.HologramData.disableIsClippingRoofCheck;
280  }
281  //----------------------------------------------------------------------------------
282  static bool GetDisableIsBaseViableCheck()
283  {
284  return m_Data.BaseBuildingData.HologramData.disableIsBaseViableCheck;
285  }
286  //----------------------------------------------------------------------------------
287  static bool GetDisableIsInTerrainCheck()
288  {
289  return m_Data.BaseBuildingData.HologramData.disableIsInTerrainCheck;
290  }
291  //----------------------------------------------------------------------------------
292  static bool GetDisableIsUnderwaterCheck()
293  {
294  return m_Data.BaseBuildingData.HologramData.disableIsUnderwaterCheck;
295  }
296  //----------------------------------------------------------------------------------
297  static bool GetDisableHeightPlacementCheck()
298  {
299  return m_Data.BaseBuildingData.HologramData.disableHeightPlacementCheck;
300  }
301  //----------------------------------------------------------------------------------
302  static bool GetDisableIsPlacementPermittedCheck()
303  {
304  return m_Data.BaseBuildingData.HologramData.disableIsPlacementPermittedCheck;
305  }
306  //----------------------------------------------------------------------------------
307  static bool GetDisableIsCollidingAngleCheck()
308  {
309  return m_Data.BaseBuildingData.HologramData.disableIsCollidingAngleCheck;
310  }
311  //----------------------------------------------------------------------------------
312  static bool GetDisableIsCollidingGPlotCheck()
313  {
314  return m_Data.BaseBuildingData.HologramData.disableIsCollidingGPlotCheck;
315  }
316  //----------------------------------------------------------------------------------
317  static bool GetDisableIsCollidingCheck()
318  {
319  return m_Data.BaseBuildingData.ConstructionData.disableIsCollidingCheck;
320  }
321  //----------------------------------------------------------------------------------
322  static bool GetDisablePerformRoofCheck()
323  {
324  return m_Data.BaseBuildingData.ConstructionData.disablePerformRoofCheck;
325  }
326  //----------------------------------------------------------------------------------
327  static bool GetDisableDistanceCheck()
328  {
329  return m_Data.BaseBuildingData.ConstructionData.disableDistanceCheck;
330  }
331  //----------------------------------------------------------------------------------
332  static TStringSet GetDisallowedTypesInUnderground()
333  {
334  return m_Data.BaseBuildingData.HologramData.disallowedTypesInUnderground;
335  }
336  //----------------------------------------------------------------------------------
337  static bool GetHitIndicationOverrideEnabled() //TODO - ?
338  {
339  return m_Data.UIData.HitIndicationData.hitDirectionOverrideEnabled;
340  }
341  //----------------------------------------------------------------------------------
342  static int GetHitIndicationMode()
343  {
344  return m_Data.UIData.HitIndicationData.hitDirectionBehaviour;
345  }
346  //----------------------------------------------------------------------------------
347  static int GetHitIndicationTypeID()
348  {
349  return m_Data.UIData.HitIndicationData.hitDirectionStyle;
350  }
351  //----------------------------------------------------------------------------------
352  static int GetHitIndicationIndicatorColor()
353  {
354  return m_Data.UIData.HitIndicationData.hitDirectionIndicatorColorStr.HexToInt();
355  }
356  //----------------------------------------------------------------------------------
357  static float GetHitIndicationMaxDuration()
358  {
359  return m_Data.UIData.HitIndicationData.hitDirectionMaxDuration;
360  }
361  //----------------------------------------------------------------------------------
362  static float GetHitIndicationBreakPoint()
363  {
364  return m_Data.UIData.HitIndicationData.hitDirectionBreakPointRelative;
365  }
366  //----------------------------------------------------------------------------------
367  static float GetHitIndicationScatter()
368  {
369  return m_Data.UIData.HitIndicationData.hitDirectionScatter;
370  }
371  //----------------------------------------------------------------------------------
372  static bool GetHitIndicationPPEEnabled()
373  {
374  return m_Data.UIData.HitIndicationData.hitIndicationPostProcessEnabled;
375  }
376  //----------------------------------------------------------------------------------
377  static bool GetUse3DMap()
378  {
379  return m_Data.UIData.use3DMap;
380  }
381  //----------------------------------------------------------------------------------
382  static float GetShockRefillSpeedConscious()
383  {
384  return m_Data.PlayerData.ShockHandlingData.shockRefillSpeedConscious;
385  }
386  //----------------------------------------------------------------------------------
387  static float GetShockRefillSpeedUnconscious()
388  {
389  return m_Data.PlayerData.ShockHandlingData.shockRefillSpeedUnconscious;
390  }
391  //----------------------------------------------------------------------------------
392  static bool GetAllowRefillSpeedModifier()
393  {
394  return m_Data.PlayerData.ShockHandlingData.allowRefillSpeedModifier;
395  }
396 
397  //--- MapData ----------------------------------------------------------------------
398  static bool GetMapIgnoreMapOwnership()
399  {
400  return m_Data.MapData.ignoreMapOwnership;
401  }
402  //----------------------------------------------------------------------------------
403  static bool GetMapIgnoreNavItemsOwnership()
404  {
405  return m_Data.MapData.ignoreNavItemsOwnership;
406  }
407  //----------------------------------------------------------------------------------
408  static bool GetMapDisplayPlayerPosition()
409  {
410  return m_Data.MapData.displayPlayerPosition;
411  }
412  //----------------------------------------------------------------------------------
413  static bool GetMapDisplayNavigationInfo()
414  {
415  return m_Data.MapData.displayNavInfo;
416  }
417  //----------------------------------------------------------------------------------
418  static float GetStaminaDepletionSpeed()
419  {
420  return m_Data.PlayerData.DrowningData.staminaDepletionSpeed;
421  }
422  //----------------------------------------------------------------------------------
423  static float GetHealthDepletionSpeed()
424  {
425  return m_Data.PlayerData.DrowningData.healthDepletionSpeed;
426  }
427  //----------------------------------------------------------------------------------
428  static float GetShockDepletionSpeed()
429  {
430  return m_Data.PlayerData.DrowningData.shockDepletionSpeed;
431  }
432  //----------------------------------------------------------------------------------
433  static bool GetAllowStaminaAffectInertia()
434  {
435  return m_Data.PlayerData.MovementData.allowStaminaAffectInertia;
436  }
437  //----------------------------------------------------------------------------------
438  static TStringArray GetPlayerSpawnGearPresetFiles()
439  {
440  return m_Data.PlayerData.spawnGearPresetFiles;
441  }
442  //----------------------------------------------------------------------------------
443 }
GetGame
proto native CGame GetGame()
m_Data
string m_Data
Definition: universaltemperaturesource.c:205
FileExist
proto bool FileExist(string name)
Check existence of file.
Print
proto void Print(void var)
Prints content of variable to console/log.
CfgGameplayJson
contents of this class will be transfered to client upon connecting, with the variables in either ini...
Definition: cfggameplaydatajson.c:2
ErrorEx
enum ShapeType ErrorEx
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
PlayerIdentity
The class that will be instanced (moddable)
Definition: gameplay.c:377
PrintToRPT
proto void PrintToRPT(void var)
Prints content of variable to RPT file (performance warning - each write means fflush!...
CfgGameplayHandler
Definition: cfggameplayhandler.c:1
array< ref ITEM_DataBase >
ITEM_DataBase
Definition: cfggameplaydatajson.c:24
ERPCs
ERPCs
Definition: erpcs.c:1
Math
Definition: enmath.c:6
TStringSet
set< string > TStringSet
Definition: enscript.c:775