Fix Now the new Object Streaming way + much better performance

This commit is contained in:
Skaronator
2013-12-23 14:46:39 +01:00
parent 57688bf8c1
commit 092c437c63

View File

@@ -52,206 +52,203 @@ if (isServer and isNil "sm_done") then {
_BuildingQueue = []; _BuildingQueue = [];
_objectQueue = []; _objectQueue = [];
_finalEpochObjArray = [];
if ((_hiveResponse select 0) == "ObjectStreamStart") then { if ((_hiveResponse select 0) == "ObjectStreamStart") then {
diag_log ("HIVE: Commence Object Streaming..."); diag_log ("HIVE: Commence Object Streaming...");
_objectCount = _hiveResponse select 1;
_key = format["CHILD:302:%1:", dayZ_instance]; _key = format["CHILD:302:%1:", dayZ_instance];
_objectCount = _hiveResponse select 1;
for "_i" from 1 to _objectCount do { for "_i" from 1 to _objectCount do {
_hiveResponse = _key call server_hiveReadWriteLarge; _hiveResponse = _key call server_hiveReadWriteLarge;
//diag_log (format["HIVE dbg %1 %2", typeName _hiveResponse, _hiveResponse]); //diag_log (format["HIVE dbg %1 %2", typeName _hiveResponse, _hiveResponse]);
if ((_hiveResponse select 2) isKindOf "ModularItems") then {
if (((_hiveResponse select _i) select 2) isKindOf "ModularItems") then {
_BuildingQueue set [(count _BuildingQueue),_hiveResponse]; _BuildingQueue set [(count _BuildingQueue),_hiveResponse];
} else { } else {
_objectQueue set [(count _objectQueue),_hiveResponse]; _objectQueue set [(count _objectQueue),_hiveResponse];
}; };
diag_log ("HIVE: got " + str(_BuildingQueue) + " Epoch objects and" + str(_objectQueue) + " Vehicles");
}; };
}; };
diag_log ("HIVE: got " + str(count(_BuildingQueue)) + " Epoch Objects and " + str(count(_objectQueue)) + " Vehicles");
_spawnSort = [_BuildingQueue,_objectQueue]; // Put arrays in order that you wish them to spawn _finalEpochObjArray = _BuildingQueue + _objectQueue;
// # NOW SPAWN OBJECTS # // # NOW SPAWN OBJECTS #
_totalvehicles = 0; _totalvehicles = 0;
{ {
_idKey = _x select 1;
_type = _x select 2;
_ownerID = _x select 3;
_worldspace = _x select 4;
_intentory = _x select 5;
_hitPoints = _x select 6;
_fuel = _x select 7;
_damage = _x select 8;
_dir = 0;
_pos = [0,0,0];
_wsDone = false;
if (count _worldspace >= 2) then
{ {
_idKey = _x select 1; _dir = _worldspace select 0;
_type = _x select 2; if (count (_worldspace select 1) == 3) then {
_ownerID = _x select 3; _pos = _worldspace select 1;
_wsDone = true;
}
};
_worldspace = _x select 4; if (!_wsDone) then {
_intentory= _x select 5; if (count _worldspace >= 1) then { _dir = _worldspace select 0; };
_hitPoints= _x select 6; _pos = [getMarkerPos "center",0,4000,10,0,2000,0] call BIS_fnc_findSafePos;
_fuel = _x select 7; if (count _pos < 3) then { _pos = [_pos select 0,_pos select 1,0]; };
_damage = _x select 8; diag_log ("MOVED OBJ: " + str(_idKey) + " of class " + _type + " to pos: " + str(_pos));
};
_dir = 0;
_pos = [0,0,0]; if (_damage < 1) then {
_wsDone = false; //diag_log format["OBJ: %1 - %2", _idKey,_type];
if (count _worldspace >= 2) then
{ //Create it
_dir = _worldspace select 0; _object = createVehicle [_type, _pos, [], 0, "CAN_COLLIDE"];
if (count (_worldspace select 1) == 3) then { _object setVariable ["lastUpdate",time];
_pos = _worldspace select 1; _object setVariable ["ObjectID", _idKey, true];
_wsDone = true;
} _lockable = 0;
if(isNumber (configFile >> "CfgVehicles" >> _type >> "lockable")) then {
_lockable = getNumber(configFile >> "CfgVehicles" >> _type >> "lockable");
}; };
if (!_wsDone) then { // fix for leading zero issues on safe codes after restart
if (count _worldspace >= 1) then { _dir = _worldspace select 0; }; if (_lockable == 4) then {
_pos = [getMarkerPos "center",0,4000,10,0,2000,0] call BIS_fnc_findSafePos; _codeCount = (count (toArray _ownerID));
if (count _pos < 3) then { _pos = [_pos select 0,_pos select 1,0]; }; if(_codeCount == 3) then {
diag_log ("MOVED OBJ: " + str(_idKey) + " of class " + _type + " to pos: " + str(_pos)); _ownerID = format["0%1", _ownerID];
};
if(_codeCount == 2) then {
_ownerID = format["00%1", _ownerID];
};
if(_codeCount == 1) then {
_ownerID = format["000%1", _ownerID];
};
}; };
if (_lockable == 3) then {
if (_damage < 1) then { _codeCount = (count (toArray _ownerID));
//diag_log format["OBJ: %1 - %2", _idKey,_type]; if(_codeCount == 2) then {
_ownerID = format["0%1", _ownerID];
//Create it
_object = createVehicle [_type, _pos, [], 0, "CAN_COLLIDE"];
_object setVariable ["lastUpdate",time];
_object setVariable ["ObjectID", _idKey, true];
_lockable = 0;
if(isNumber (configFile >> "CfgVehicles" >> _type >> "lockable")) then {
_lockable = getNumber(configFile >> "CfgVehicles" >> _type >> "lockable");
}; };
if(_codeCount == 1) then {
// fix for leading zero issues on safe codes after restart _ownerID = format["00%1", _ownerID];
if (_lockable == 4) then {
_codeCount = (count (toArray _ownerID));
if(_codeCount == 3) then {
_ownerID = format["0%1", _ownerID];
};
if(_codeCount == 2) then {
_ownerID = format["00%1", _ownerID];
};
if(_codeCount == 1) then {
_ownerID = format["000%1", _ownerID];
};
}; };
};
if (_lockable == 3) then { _object setVariable ["CharacterID", _ownerID, true];
_codeCount = (count (toArray _ownerID));
if(_codeCount == 2) then {
_ownerID = format["0%1", _ownerID];
};
if(_codeCount == 1) then {
_ownerID = format["00%1", _ownerID];
};
};
_object setVariable ["CharacterID", _ownerID, true]; clearWeaponCargoGlobal _object;
clearMagazineCargoGlobal _object;
// _object setVehicleAmmo DZE_vehicleAmmo;
clearWeaponCargoGlobal _object; if ((typeOf _object) in dayz_allowedObjects) then {
clearMagazineCargoGlobal _object; _object addMPEventHandler ["MPKilled",{_this call object_handleServerKilled;}];
// _object setVehicleAmmo DZE_vehicleAmmo; // Test disabling simulation server side on buildables only.
_object enableSimulation false;
// used for inplace upgrades and lock/unlock of safe
_object setVariable ["OEMPos", _pos, true];
};
if ((typeOf _object) in dayz_allowedObjects) then { _object setdir _dir;
_object addMPEventHandler ["MPKilled",{_this call object_handleServerKilled;}]; _object setposATL _pos;
// Test disabling simulation server side on buildables only. _object setDamage _damage;
_object enableSimulation false;
// used for inplace upgrades and lock/unlock of safe
_object setVariable ["OEMPos", _pos, true];
};
_object setdir _dir; if (count _intentory > 0) then {
_object setposATL _pos; if (_type in DZE_LockedStorage) then {
_object setDamage _damage; // Fill variables with loot
_object setVariable ["WeaponCargo", (_intentory select 0), true];
_object setVariable ["MagazineCargo", (_intentory select 1), true];
_object setVariable ["BackpackCargo", (_intentory select 2), true];
} else {
if (count _intentory > 0) then { //Add weapons
if (_type in DZE_LockedStorage) then { _objWpnTypes = (_intentory select 0) select 0;
// Fill variables with loot _objWpnQty = (_intentory select 0) select 1;
_object setVariable ["WeaponCargo", (_intentory select 0), true]; _countr = 0;
_object setVariable ["MagazineCargo", (_intentory select 1), true];
_object setVariable ["BackpackCargo", (_intentory select 2), true];
} else {
//Add weapons
_objWpnTypes = (_intentory select 0) select 0;
_objWpnQty = (_intentory select 0) select 1;
_countr = 0;
{
if(_x in (DZE_REPLACE_WEAPONS select 0)) then {
_x = (DZE_REPLACE_WEAPONS select 1) select ((DZE_REPLACE_WEAPONS select 0) find _x);
};
_isOK = isClass(configFile >> "CfgWeapons" >> _x);
if (_isOK) then {
_block = getNumber(configFile >> "CfgWeapons" >> _x >> "stopThis") == 1;
if (!_block) then {
_object addWeaponCargoGlobal [_x,(_objWpnQty select _countr)];
};
};
_countr = _countr + 1;
} forEach _objWpnTypes;
//Add Magazines
_objWpnTypes = (_intentory select 1) select 0;
_objWpnQty = (_intentory select 1) select 1;
_countr = 0;
{
if (_x == "BoltSteel") then { _x = "WoodenArrow" }; // Convert BoltSteel to WoodenArrow
if (_x == "ItemTent") then { _x = "ItemTentOld" };
_isOK = isClass(configFile >> "CfgMagazines" >> _x);
if (_isOK) then {
_block = getNumber(configFile >> "CfgMagazines" >> _x >> "stopThis") == 1;
if (!_block) then {
_object addMagazineCargoGlobal [_x,(_objWpnQty select _countr)];
};
};
_countr = _countr + 1;
} forEach _objWpnTypes;
//Add Backpacks
_objWpnTypes = (_intentory select 2) select 0;
_objWpnQty = (_intentory select 2) select 1;
_countr = 0;
{
_isOK = isClass(configFile >> "CfgVehicles" >> _x);
if (_isOK) then {
_block = getNumber(configFile >> "CfgVehicles" >> _x >> "stopThis") == 1;
if (!_block) then {
_object addBackpackCargoGlobal [_x,(_objWpnQty select _countr)];
};
};
_countr = _countr + 1;
} forEach _objWpnTypes;
};
};
if (_object isKindOf "AllVehicles") then {
{ {
_selection = _x select 0; if(_x in (DZE_REPLACE_WEAPONS select 0)) then {
_dam = _x select 1; _x = (DZE_REPLACE_WEAPONS select 1) select ((DZE_REPLACE_WEAPONS select 0) find _x);
if (_selection in dayZ_explosiveParts and _dam > 0.8) then {_dam = 0.8};
[_object,_selection,_dam] call object_setFixServer;
} forEach _hitpoints;
_object setFuel _fuel;
if (!((typeOf _object) in dayz_allowedObjects)) then {
//_object setvelocity [0,0,1];
_object call fnc_veh_ResetEH;
if(_ownerID != "0" and !(_object isKindOf "Bicycle")) then {
_object setvehiclelock "locked";
}; };
_isOK = isClass(configFile >> "CfgWeapons" >> _x);
if (_isOK) then {
_block = getNumber(configFile >> "CfgWeapons" >> _x >> "stopThis") == 1;
if (!_block) then {
_object addWeaponCargoGlobal [_x,(_objWpnQty select _countr)];
};
};
_countr = _countr + 1;
} forEach _objWpnTypes;
_totalvehicles = _totalvehicles + 1; //Add Magazines
_objWpnTypes = (_intentory select 1) select 0;
_objWpnQty = (_intentory select 1) select 1;
_countr = 0;
{
if (_x == "BoltSteel") then { _x = "WoodenArrow" }; // Convert BoltSteel to WoodenArrow
if (_x == "ItemTent") then { _x = "ItemTentOld" };
_isOK = isClass(configFile >> "CfgMagazines" >> _x);
if (_isOK) then {
_block = getNumber(configFile >> "CfgMagazines" >> _x >> "stopThis") == 1;
if (!_block) then {
_object addMagazineCargoGlobal [_x,(_objWpnQty select _countr)];
};
};
_countr = _countr + 1;
} forEach _objWpnTypes;
// total each vehicle //Add Backpacks
serverVehicleCounter set [count serverVehicleCounter,_type]; _objWpnTypes = (_intentory select 2) select 0;
}; _objWpnQty = (_intentory select 2) select 1;
_countr = 0;
{
_isOK = isClass(configFile >> "CfgVehicles" >> _x);
if (_isOK) then {
_block = getNumber(configFile >> "CfgVehicles" >> _x >> "stopThis") == 1;
if (!_block) then {
_object addBackpackCargoGlobal [_x,(_objWpnQty select _countr)];
};
};
_countr = _countr + 1;
} forEach _objWpnTypes;
}; };
//Monitor the object
PVDZE_serverObjectMonitor set [count PVDZE_serverObjectMonitor,_object];
}; };
} forEach _x;
} forEach _spawnSort; if (_object isKindOf "AllVehicles") then {
{
_selection = _x select 0;
_dam = _x select 1;
if (_selection in dayZ_explosiveParts and _dam > 0.8) then {_dam = 0.8};
[_object,_selection,_dam] call object_setFixServer;
} forEach _hitpoints;
_object setFuel _fuel;
if (!((typeOf _object) in dayz_allowedObjects)) then {
//_object setvelocity [0,0,1];
_object call fnc_veh_ResetEH;
if(_ownerID != "0" and !(_object isKindOf "Bicycle")) then {
_object setvehiclelock "locked";
};
_totalvehicles = _totalvehicles + 1;
// total each vehicle
serverVehicleCounter set [count serverVehicleCounter,_type];
};
};
//Monitor the object
PVDZE_serverObjectMonitor set [count PVDZE_serverObjectMonitor,_object];
};
} forEach _finalEpochObjArray;
// # END SPAWN OBJECTS # // # END SPAWN OBJECTS #