Advertisement
Guest User

server_monitor

a guest
May 17th, 2018
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.46 KB | None | 0 0
  1. private ["_date","_year","_month","_day","_hour","_minute","_date1","_key","_objectCount","_dir","_point","_i","_action","_dam","_selection","_wantExplosiveParts","_entity","_worldspace","_damage","_booleans","_rawData","_ObjectID","_class","_CharacterID","_inventory","_hitpoints","_fuel","_id","_objectArray","_script","_result","_outcome","_shutdown","_res"];
  2. [] execVM "\z\addons\dayz_server\system\s_fps.sqf"; //server monitor FPS (writes each ~181s diag_fps+181s diag_fpsmin*)
  3. #include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
  4.  
  5. waitUntil {!isNil "BIS_MPF_InitDone" && initialized};
  6. if (!isNil "sm_done") exitWith {}; // prevent server_monitor be called twice (bug during login of the first player)
  7. sm_done = false;
  8.  
  9. _legacyStreamingMethod = false; //use old object streaming method, more secure but will be slower and subject to the callExtension return size limitation.
  10.  
  11. dayz_serverIDMonitor = [];
  12. _DZE_VehObjects = [];
  13. dayz_versionNo = getText (configFile >> "CfgMods" >> "DayZ" >> "version");
  14. dayz_hiveVersionNo = getNumber (configFile >> "CfgMods" >> "DayZ" >> "hiveVersion");
  15. _hiveLoaded = false;
  16. _serverVehicleCounter = [];
  17. _tempMaint = DayZ_WoodenFence + DayZ_WoodenGates;
  18. diag_log "HIVE: Starting";
  19.  
  20. //Set the Time
  21. _key = "CHILD:307:";
  22. _result = _key call server_hiveReadWrite;
  23. _outcome = _result select 0;
  24. if (_outcome == "PASS") then {
  25. _date = _result select 1;
  26. _year = _date select 0;
  27. _month = _date select 1;
  28. _day = _date select 2;
  29. _hour = _date select 3;
  30. _minute = _date select 4;
  31.  
  32. if (dayz_ForcefullmoonNights) then {_date = [2012,8,2,_hour,_minute];};
  33. diag_log ["TIME SYNC: Local Time set to:", _date, "Fullmoon:",dayz_ForcefullmoonNights,"Date given by HiveExt.dll:",_result select 1];
  34. setDate _date;
  35. dayzSetDate = _date;
  36. publicVariable "dayzSetDate";
  37. };
  38.  
  39. //Stream in objects
  40. /* STREAM OBJECTS */
  41. //Send the key
  42. _timeStart = diag_tickTime;
  43.  
  44. for "_i" from 1 to 5 do {
  45. diag_log "HIVE: trying to get objects";
  46. _key = format["CHILD:302:%1:%2:",dayZ_instance, _legacyStreamingMethod];
  47. _result = _key call server_hiveReadWrite;
  48. if (typeName _result == "STRING") then {
  49. _shutdown = format["CHILD:400:%1:",(profileNamespace getVariable "SUPERKEY")];
  50. _res = _shutdown call server_hiveReadWrite;
  51. diag_log ("HIVE: attempt to kill.. HiveExt response:"+str(_res));
  52. } else {
  53. diag_log ("HIVE: found "+str(_result select 1)+" objects" );
  54. _i = 99; // break
  55. };
  56. };
  57.  
  58. _BuildingQueue = [];
  59. _objectQueue = [];
  60. _originsQueue = [];
  61. //Define arrays
  62. owner_B1 = [];
  63. owner_B2 = [];
  64. owner_B3 = [];
  65. owner_H1 = [];
  66. owner_H2 = [];
  67. owner_H3 = [];
  68. owner_SG = [];
  69. owner_LG = [];
  70. owner_KING = [];
  71. owner_SH = [];
  72.  
  73. if (typeName _result == "STRING") exitWith {
  74. diag_log "HIVE: Connection error. Server_monitor.sqf is exiting.";
  75. };
  76.  
  77. diag_log "HIVE: Request sent";
  78. _myArray = [];
  79. _val = 0;
  80. _status = _result select 0; //Process result
  81. _val = _result select 1;
  82. if (_legacyStreamingMethod) then {
  83. if (_status == "ObjectStreamStart") then {
  84. profileNamespace setVariable ["SUPERKEY",(_result select 2)];
  85. _hiveLoaded = true;
  86. //Stream Objects
  87. diag_log ("HIVE: Commence Object Streaming...");
  88. for "_i" from 1 to _val do {
  89. _result = _key call server_hiveReadWriteLarge;
  90. _status = _result select 0;
  91. _myArray set [count _myArray,_result];
  92. };
  93. };
  94. } else {
  95. if (_val > 0) then {
  96. _fileName = _key call server_hiveReadWrite;
  97. _lastFN = profileNamespace getVariable["lastFN",""];
  98. profileNamespace setVariable["lastFN",_fileName];
  99. saveProfileNamespace;
  100. if (_status == "ObjectStreamStart") then {
  101. profileNamespace setVariable ["SUPERKEY",(_result select 2)];
  102. _hiveLoaded = true;
  103. _myArray = Call Compile PreProcessFile _fileName;
  104. _key = format["CHILD:302:%1:%2:",_lastFN, _legacyStreamingMethod];
  105. _result = _key call server_hiveReadWrite; //deletes previous object data dump
  106. };
  107. } else {
  108. if (_status == "ObjectStreamStart") then {
  109. profileNamespace setVariable ["SUPERKEY",(_result select 2)];
  110. _hiveLoaded = true;
  111. };
  112. };
  113. };
  114.  
  115. diag_log ("HIVE: Streamed " + str(_val) + " objects");
  116.  
  117. // Don't spawn objects if no clients are online (createVehicle fails with Ref to nonnetwork object)
  118. if ((playersNumber west + playersNumber civilian) == 0) exitWith {
  119. diag_log "All clients disconnected. Server_monitor.sqf is exiting.";
  120. };
  121.  
  122. {
  123. private ["_object","_posATL"];
  124. //Parse Array
  125. _action = _x select 0;
  126. _idKey = _x select 1;
  127. _type = _x select 2;
  128. _ownerID = _x select 3;
  129. _worldspace = _x select 4;
  130. _inventory = _x select 5;
  131. _hitPoints = _x select 6;
  132. _fuel = _x select 7;
  133. _damage = _x select 8;
  134. _storageMoney = _x select 9;
  135.  
  136. //set object to be in maintenance mode
  137. _maintenanceMode = false;
  138. _maintenanceModeVars = [];
  139.  
  140. _dir = 90;
  141. _pos = [0,0,0];
  142. _wsDone = false;
  143. _wsCount = count _worldspace;
  144.  
  145. //Vector building
  146. _vector = [[0,0,0],[0,0,0]];
  147. _vecExists = false;
  148. _ownerPUID = "0";
  149.  
  150. if (_wsCount >= 2) then {
  151. _dir = _worldspace select 0;
  152. _posATL = _worldspace select 1;
  153. if (count _posATL == 3) then {
  154. _pos = _posATL;
  155. _wsDone = true;
  156. };
  157. if (_wsCount >= 3) then{
  158. _ws2TN = typename (_worldspace select 2);
  159. _ws3TN = typename (_worldspace select 3);
  160. if (_wsCount == 3) then{
  161. if (_ws2TN == "STRING") then{
  162. _ownerPUID = _worldspace select 2;
  163. } else {
  164. if (_ws2TN == "ARRAY") then{
  165. _vector = _worldspace select 2;
  166. _vecExists = true;
  167. };
  168. };
  169. } else {
  170. if (_wsCount == 4) then{
  171. if (_ws3TN == "STRING") then{
  172. _ownerPUID = _worldspace select 3;
  173. } else {
  174. if (_ws2TN == "STRING") then{
  175. _ownerPUID = _worldspace select 2;
  176. };
  177. };
  178. if (_ws2TN == "ARRAY") then{
  179. _vector = _worldspace select 2;
  180. _vecExists = true;
  181. } else {
  182. if (_ws3TN == "ARRAY") then{
  183. _vector = _worldspace select 3;
  184. _vecExists = true;
  185. };
  186. };
  187. };
  188. };
  189. } else {
  190. _worldspace set [count _worldspace, "0"];
  191. };
  192. };
  193.  
  194. if (!_wsDone) then {
  195. if ((count _posATL) >= 2) then {
  196. _pos = [_posATL select 0,_posATL select 1,0];
  197. diag_log format["MOVED OBJ: %1 of class %2 with worldspace array = %3 to pos: %4",_idKey,_type,_worldspace,_pos];
  198. } else {
  199. diag_log format["MOVED OBJ: %1 of class %2 with worldspace array = %3 to pos: [0,0,0]",_idKey,_type,_worldspace];
  200. };
  201. };
  202.  
  203. //diag_log format["OBJ: %1 - %2,%3,%4,%5,%6,%7,%8", _idKey,_type,_ownerID,_worldspace,_inventory,_hitPoints,_fuel,_damage];
  204. /*
  205. if (_type in _tempMaint) then {
  206. //Use hitpoints for Maintenance system and other systems later.
  207. //Enable model swap for a damaged model.
  208. if ("Maintenance" in _hitPoints) then {
  209. _maintenanceModeVars = [_type,_pos];
  210. _type = _type + "_Damaged";
  211. };
  212. //TODO add remove object and readd old fence (hideobject would be nice to use here :-( )
  213. //Pending change to new fence models\Layout
  214. };
  215. */
  216. _nonCollide = _type in DayZ_nonCollide;
  217. //Create it
  218. if (_nonCollide) then {
  219. _object = createVehicle [_type, [0,0,0], [], 0, "NONE"];
  220. } else {
  221. _object = _type createVehicle [0,0,0]; //more than 2x faster than createvehicle array
  222. };
  223. _object setDir _dir;
  224. _object setPosATL _pos;
  225. _object setDamage _damage;
  226. if (_vecExists) then {
  227. _object setVectorDirAndUp _vector;
  228. };
  229. _object enableSimulation false;
  230.  
  231. _doorLocked = _type in DZE_DoorsLocked;
  232. _isPlot = _type == "Plastic_Pole_EP1_DZ";
  233.  
  234. // prevent immediate hive write when vehicle parts are set up
  235. _object setVariable ["lastUpdate",diag_ticktime];
  236. _object setVariable ["ObjectID", _idKey, true];
  237. _object setVariable ["OwnerPUID", _ownerPUID, true];
  238. if (Z_SingleCurrency && {(_type in DZE_MoneyStorageClasses) || (_object isKindOf "AllVehicles")}) then {
  239. _object setVariable [Z_MoneyVariable, _storageMoney, true];
  240. };
  241.  
  242. dayz_serverIDMonitor set [count dayz_serverIDMonitor,_idKey];
  243.  
  244. if (!_wsDone) then {[_object,"position",true] call server_updateObject;};
  245. if (_type == "Base_Fire_DZ") then {_object spawn base_fireMonitor;};
  246.  
  247. _isDZ_Buildable = _object isKindOf "DZ_buildables";
  248. _isTrapItem = _object isKindOf "TrapItems";
  249. _isSafeObject = _type in DayZ_SafeObjects;
  250.  
  251. //Dont add inventory for traps.
  252. if (!_isDZ_Buildable && !_isTrapItem) then {
  253. clearWeaponCargoGlobal _object;
  254. clearMagazineCargoGlobal _object;
  255. clearBackpackCargoGlobal _object;
  256. if( (count _inventory > 0) && !_isPlot && !_doorLocked) then {
  257. if (_type in DZE_LockedStorage || _type in DZE_Origins_Buildings) then {
  258. // Do not send big arrays over network! Only server needs these
  259. _object setVariable ["WeaponCargo",(_inventory select 0),false];
  260. _object setVariable ["MagazineCargo",(_inventory select 1),false];
  261. _object setVariable ["BackpackCargo",(_inventory select 2),false];
  262. } else {
  263. _weaponcargo = _inventory select 0 select 0;
  264. _magcargo = _inventory select 1 select 0;
  265. _backpackcargo = _inventory select 2 select 0;
  266. _weaponqty = _inventory select 0 select 1;
  267. {_object addWeaponCargoGlobal [_x, _weaponqty select _foreachindex];} foreach _weaponcargo;
  268.  
  269. _magqty = _inventory select 1 select 1;
  270. {_object addMagazineCargoGlobal [_x, _magqty select _foreachindex];} foreach _magcargo;
  271.  
  272. _backpackqty = _inventory select 2 select 1;
  273. {_object addBackpackCargoGlobal [_x, _backpackqty select _foreachindex];} foreach _backpackcargo;
  274. };
  275. } else {
  276. if (DZE_permanentPlot && _isPlot) then {
  277. _object setVariable ["plotfriends", _inventory, true];
  278. };
  279. if (DZE_doorManagement && _doorLocked) then {
  280. _object setVariable ["doorfriends", _inventory, true];
  281. };
  282. };
  283. };
  284.  
  285. if (_object isKindOf "AllVehicles") then {
  286. _object setVariable["lastInventory",_inventory];
  287. _object setVariable ["CharacterID", _ownerID, true];
  288. _isAir = _object isKindOf "Air";
  289. {
  290. _selection = _x select 0;
  291. _dam = if (!_isAir && {_selection in dayZ_explosiveParts}) then {(_x select 1) min 0.8;} else {_x select 1;};
  292. _strH = "hit_" + (_selection);
  293. _object setHit[_selection,_dam];
  294. _object setVariable [_strH,_dam,true];
  295. } foreach _hitpoints;
  296. _oriarray =["ori_ZAZ968M","ori_taviander","ori_buchanka","ori_m3","ori_maniac","ori_KaTransp","ori_ScrapRaft"];
  297. if (typeOF _object in _oriarray) then {
  298. _object animate ["tropa",1];
  299. if (typeOF _object == "ori_ScrapRaft") then {_object animate ["OriModOhrana",1];};
  300. };
  301. [_object,"damage"] call server_updateObject;
  302.  
  303. _object setFuel _fuel;
  304. #include "VehicleAmmo.sqf";
  305. if (!_isSafeObject) then {
  306. _DZE_VehObjects set [count _DZE_VehObjects,_object];
  307. _object call fnc_veh_ResetEH;
  308. if (_ownerID != "0" && {!(_object isKindOf "Bicycle")}) then {
  309. _object setVehicleLock "locked";
  310. _object setVariable ["MF_Tow_Cannot_Tow",true,true];
  311. _object setVariable ["BTC_Cannot_Lift",true,true];
  312. };
  313. _serverVehicleCounter set [count _serverVehicleCounter,_type]; // total each vehicle
  314. } else {
  315. _object enableSimulation true;
  316. };
  317. } else {
  318. // Fix for leading zero issues on safe codes after restart
  319. _lockable = getNumber (configFile >> "CfgVehicles" >> _type >> "lockable");
  320. _codeCount = count (toArray _ownerID);
  321. switch (_lockable) do {
  322. case 4: {
  323. switch (_codeCount) do {
  324. case 3: {_ownerID = format["0%1",_ownerID];};
  325. case 2: {_ownerID = format["00%1",_ownerID];};
  326. case 1: {_ownerID = format["000%1",_ownerID];};
  327. };
  328. };
  329. case 3: {
  330. switch (_codeCount) do {
  331. case 2: {_ownerID = format["0%1",_ownerID];};
  332. case 1: {_ownerID = format["00%1",_ownerID];};
  333. };
  334. };
  335. };
  336. _object setVariable ["CharacterID", _ownerID, true];
  337. if (_isDZ_Buildable || {(_isSafeObject && !_isTrapItem)}) then {
  338. _object setVariable["memDir",_dir,true];
  339. if (DZE_GodModeBase && {!(_type in DZE_GodModeBaseExclude)}) then {
  340. _object addEventHandler ["HandleDamage",{false}];
  341. } else {
  342. _object addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];
  343. };
  344. _object setVariable ["OEMPos",_pos,true]; // used for inplace upgrades and lock/unlock of safe
  345. } else {
  346. _object enableSimulation true;
  347. };
  348. if (_isDZ_Buildable || {_isTrapItem}) then {
  349. //Use inventory for owner/clan info and traps armed state
  350. {
  351. _xTypeName = typeName _x;
  352. switch (_xTypeName) do {
  353. case "ARRAY": {
  354. _x1 = _x select 1;
  355. switch (_x select 0) do {
  356. case "ownerArray" : { _object setVariable ["ownerArray", _x1, true]; };
  357. case "clanArray" : { _object setVariable ["clanArray", _x1, true]; };
  358. case "armed" : { _object setVariable ["armed", _x1, true]; };
  359. case "padlockCombination" : { _object setVariable ["dayz_padlockCombination", _x1, false]; };
  360. case "BuildLock" : { _object setVariable ["BuildLock", _x1, true]; };
  361. };
  362. };
  363. case "STRING": {_object setVariable ["ownerArray", [_x], true]; };
  364. case "BOOLEAN": {_object setVariable ["armed", _x, true]};
  365. };
  366. } foreach _inventory;
  367.  
  368. if (_maintenanceMode) then { _object setVariable ["Maintenance", true, true]; _object setVariable ["MaintenanceVars", _maintenanceModeVars]; };
  369. };
  370. };
  371. //Monitor the object
  372. if(_type in DZE_Origins_Buildings) then {
  373. //diag_log format["Origins Object: %1 - %2", _type,_ownerID];
  374. _object setVariable ["CanBeUpdated",false, true];
  375. {
  376. _object setVariable ["OwnerUID",(_x select 0), true];
  377. _object setVariable ["OwnerName",(_x select 1), true];
  378. } count _hitPoints;
  379. _ownerUID = _object getVariable ["OwnerUID","0"];
  380. switch(_type) do {
  381. case "Uroven1DrevenaBudka" : { owner_B1 set [count owner_B1, _ownerUID];};
  382. case "Uroven2KladaDomek" : { owner_B2 set [count owner_B2, _ownerUID];};
  383. case "Uroven3DrevenyDomek" : { owner_B3 set [count owner_B3, _ownerUID];};
  384. case "Uroven1VelkaBudka" : { owner_H1 set [count owner_H1, _ownerUID];};
  385. case "Uroven2MalyDomek" : { owner_H2 set [count owner_H2, _ownerUID];};
  386. case "Uroven3VelkyDomek" : { owner_H3 set [count owner_H3, _ownerUID];};
  387. case "malaGaraz" : { owner_SG set [count owner_SG, _ownerUID];};
  388. case "velkaGaraz" : { owner_LG set [count owner_LG, _ownerUID];};
  389. case "kingramida" : { owner_KING set [count owner_KING, _ownerUID];};
  390. case "krepost" : { owner_SH set [count owner_SH, _ownerUID];};
  391. };
  392. if((_pos select 2) < 0.25) then {
  393. _object setVectorUp surfaceNormal position _object;
  394. };
  395. _object setVectorUp surfaceNormal position _object;
  396. };
  397. dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object]; //Monitor the object
  398. } forEach _myArray;
  399.  
  400. //enable simulation on vehicles after all buildables are spawned
  401. {
  402. _x enableSimulation true;
  403. _x setVelocity [0,0,1];
  404. } forEach _DZE_VehObjects;
  405.  
  406. diag_log format["HIVE: BENCHMARK - Server_monitor.sqf finished streaming %1 objects in %2 seconds (unscheduled)",_val,diag_tickTime - _timeStart];
  407.  
  408. // # END OF STREAMING #
  409. if (dayz_townGenerator) then {
  410. call compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_plantSpawner.sqf"; // Draw the pseudo random seeds
  411. };
  412. #ifndef OBJECT_DEBUG
  413. object_debug = false;
  414. #else
  415. object_debug = true;
  416. #endif
  417. [] execFSM "\z\addons\dayz_server\system\server_vehicleSync.fsm";
  418. [] execVM "\z\addons\dayz_server\system\scheduler\sched_init.sqf"; // launch the new task scheduler
  419.  
  420. createCenter civilian;
  421.  
  422. actualSpawnMarkerCount = 0;
  423. // count valid spawn markers, since different maps have different amounts
  424. for "_i" from 0 to 10 do {
  425. if ((getMarkerPos format["spawn%1",_i]) distance [0,0,0] > 0) then {
  426. actualSpawnMarkerCount = actualSpawnMarkerCount + 1;
  427. } else {
  428. _i = 11; // exit since we did not find any further markers
  429. };
  430. };
  431. diag_log format["Total Number of spawn locations %1", actualSpawnMarkerCount];
  432.  
  433. if (isDedicated) then {endLoadingScreen;};
  434. [] call compile preprocessFileLineNumbers "\z\addons\dayz_server\DZAI\init\dzai_initserver.sqf";
  435. [] ExecVM "\z\addons\dayz_server\WAI\init.sqf";
  436. [] ExecVM "\z\addons\dayz_server\origins\variables.sqf";
  437. allowConnection = true;
  438. sm_done = true;
  439. publicVariable "sm_done";
  440.  
  441. // Trap loop
  442. [] spawn {
  443. private ["_array","_array2","_array3","_script","_armed"];
  444. _array = str dayz_traps;
  445. _array2 = str dayz_traps_active;
  446. _array3 = str dayz_traps_trigger;
  447.  
  448. while {1 == 1} do {
  449. if ((str dayz_traps != _array) || (str dayz_traps_active != _array2) || (str dayz_traps_trigger != _array3)) then {
  450. _array = str dayz_traps;
  451. _array2 = str dayz_traps_active;
  452. _array3 = str dayz_traps_trigger;
  453. //diag_log "DEBUG: traps";
  454. //diag_log format["dayz_traps (%2) -> %1", dayz_traps, count dayz_traps];
  455. //diag_log format["dayz_traps_active (%2) -> %1", dayz_traps_active, count dayz_traps_active];
  456. //diag_log format["dayz_traps_trigger (%2) -> %1", dayz_traps_trigger, count dayz_traps_trigger];
  457. //diag_log "DEBUG: end traps";
  458. };
  459.  
  460. {
  461. if (isNull _x) then {
  462. dayz_traps = dayz_traps - [_x];
  463. _armed = false;
  464. _script = {};
  465. } else {
  466. _armed = _x getVariable ["armed", false];
  467. _script = call compile getText (configFile >> "CfgVehicles" >> typeOf _x >> "script");
  468. };
  469.  
  470. if (_armed) then {
  471. if !(_x in dayz_traps_active) then {["arm", _x] call _script;};
  472. } else {
  473. if (_x in dayz_traps_active) then {["disarm", _x] call _script;};
  474. };
  475. uiSleep 0.01;
  476. } forEach dayz_traps;
  477. uiSleep 1;
  478. };
  479. };
  480.  
  481. //Points of interest
  482. //[] execVM "\z\addons\dayz_server\compile\server_spawnInfectedCamps.sqf"; //Adds random spawned camps in the woods with corpses and loot tents (negatively impacts FPS)
  483. [] execVM "\z\addons\dayz_server\compile\server_spawnCarePackages.sqf";
  484. [] execVM "\z\addons\dayz_server\compile\server_spawnCrashSites.sqf";
  485.  
  486. if (dayz_townGenerator) then {execVM "\z\addons\dayz_server\system\lit_fireplaces.sqf";};
  487.  
  488. "PVDZ_sec_atp" addPublicVariableEventHandler {
  489. _x = _this select 1;
  490. switch (1==1) do {
  491. case (typeName _x == "STRING") : { // just some logs from the client
  492. diag_log _x;
  493. };
  494. case (count _x == 2) : { // wrong side
  495. diag_log format["P1ayer %1 reports possible 'side' hack. Server may be compromised!",(_x select 1) call fa_plr2Str];
  496. };
  497. default { // player hit
  498. _unit = _x select 0;
  499. _source = _x select 1;
  500. if (!isNull _source) then {
  501. diag_log format ["P1ayer %1 hit by %2 %3 from %4 meters in %5 for %6 damage",
  502. _unit call fa_plr2Str, if (!isPlayer _source && alive _source) then {"AI"} else {_source call fa_plr2Str}, _x select 2, _x select 3, _x select 4, _x select 5];
  503. };
  504. };
  505. };
  506. };
  507.  
  508. "PVDZ_objgather_Knockdown" addPublicVariableEventHandler {
  509. _tree = (_this select 1) select 0;
  510. _player = (_this select 1) select 1;
  511. _dis = _player distance _tree;
  512. _name = if (alive _player) then {name _player} else {"DeadPlayer"};
  513. _uid = getPlayerUID _player;
  514. _treeModel = _tree call fn_getModelName;
  515.  
  516. if (_dis < 30 && (_treeModel in dayz_trees or (_treeModel in dayz_plant)) && (_uid != "")) then {
  517. _tree setDamage 1;
  518. dayz_choppedTrees set [count dayz_choppedTrees,_tree];
  519. diag_log format["Server setDamage on tree or plant %1 chopped down by %2(%3)",_treeModel,_name,_uid];
  520. };
  521. };
  522.  
  523. // preload server traders menu data into cache
  524. if !(DZE_ConfigTrader) then {
  525. {
  526. // get tids
  527. _traderData = call compile format["menu_%1;",_x];
  528. if (!isNil "_traderData") then {
  529. {
  530. _traderid = _x select 1;
  531. _retrader = [];
  532.  
  533. _key = format["CHILD:399:%1:",_traderid];
  534. _data = "HiveEXT" callExtension _key;
  535. _result = call compile format["%1",_data];
  536. _status = _result select 0;
  537.  
  538. if (_status == "ObjectStreamStart") then {
  539. _val = _result select 1;
  540. call compile format["ServerTcache_%1 = [];",_traderid];
  541. for "_i" from 1 to _val do {
  542. _data = "HiveEXT" callExtension _key;
  543. _result = call compile format ["%1",_data];
  544. call compile format["ServerTcache_%1 set [count ServerTcache_%1,%2]",_traderid,_result];
  545. _retrader set [count _retrader,_result];
  546. };
  547. };
  548. } forEach (_traderData select 0);
  549. };
  550. } forEach serverTraders;
  551. };
  552.  
  553. if (_hiveLoaded) then {
  554. _serverVehicleCounter spawn {
  555. // spawn_vehicles
  556. // Get all buildings and roads only once. Very taxing, but only on first startup
  557. _serverVehicleCounter = _this;
  558. _vehiclesToUpdate = [];
  559. _startTime = diag_tickTime;
  560. _buildingList = [];
  561. _cfgLootFile = missionConfigFile >> "CfgLoot" >> "Buildings";
  562. {
  563. if (isClass (_cfgLootFile >> typeOf _x)) then {
  564. _buildingList set [count _buildingList,_x];
  565. };
  566. } count (getMarkerPos "center" nearObjects ["building",((getMarkerSize "center") select 1)]);
  567. _roadList = getMarkerPos "center" nearRoads ((getMarkerSize "center") select 1);
  568.  
  569. _vehLimit = MaxVehicleLimit - (count _serverVehicleCounter);
  570. if (_vehLimit > 0) then {
  571. diag_log ("HIVE: Spawning # of Vehicles: " + str(_vehLimit));
  572. for "_x" from 1 to _vehLimit do {call spawn_vehicles;};
  573. } else {
  574. diag_log "HIVE: Vehicle Spawn limit reached!";
  575. _vehLimit = 0;
  576. };
  577.  
  578. if (dayz_townGenerator) then {
  579. // Vanilla town generator spawns debris locally on each client
  580. MaxDynamicDebris = 0;
  581. } else {
  582. // Epoch global dynamic debris
  583. diag_log ("HIVE: Spawning # of Debris: " + str(MaxDynamicDebris));
  584. for "_x" from 1 to MaxDynamicDebris do {call spawn_roadblocks;};
  585. };
  586.  
  587. diag_log ("HIVE: Spawning # of Ammo Boxes: " + str(MaxAmmoBoxes));
  588. for "_x" from 1 to MaxAmmoBoxes do {call spawn_ammosupply;};
  589.  
  590. diag_log ("HIVE: Spawning # of Veins: " + str(MaxMineVeins));
  591. for "_x" from 1 to MaxMineVeins do {call spawn_mineveins;};
  592.  
  593. diag_log format["HIVE: BENCHMARK - Server finished spawning %1 DynamicVehicles, %2 Debris, %3 SupplyCrates and %4 MineVeins in %5 seconds (scheduled)",_vehLimit,MaxDynamicDebris,MaxAmmoBoxes,MaxMineVeins,diag_tickTime - _startTime];
  594.  
  595. //Update gear last after all dynamic vehicles are created to save random loot to database (low priority)
  596. {[_x,"gear"] call server_updateObject} count _vehiclesToUpdate;
  597. };
  598. };
  599.  
  600. [] spawn server_spawnEvents;
  601. [] execVM "\z\addons\dayz_server\init\safeZoneRelocate.sqf";
  602. /* //Causes issues with changing clothes
  603. _debugMarkerPosition = [(respawn_west_original select 0),(respawn_west_original select 1),1];
  604. _vehicle_0 = createVehicle ["DebugBox_DZ", _debugMarkerPosition, [], 0, "CAN_COLLIDE"];
  605. _vehicle_0 setPos _debugMarkerPosition;
  606. _vehicle_0 setVariable ["ObjectID","1",true];
  607. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement