move SQF wait/loop to get OID to SQL Procedure

for some reason you cannot directly get the OID using SELECT LAST_INSERT_ID(); and you cannot return it within the same hive call as the insert call (????).

Requires new procedure for 1.0.6.2
This commit is contained in:
icomrade
2017-09-25 12:14:41 -04:00
parent cb5d61eff7
commit 95b3174e04
7 changed files with 152 additions and 173 deletions

View File

@@ -1,4 +1,4 @@
private ["_activatingPlayer","_isOK","_worldspace","_location","_dir","_class","_uid","_key","_keySelected","_characterID","_donotusekey"];
private ["_activatingPlayer","_isOK","_worldspace","_location","_dir","_class","_uid","_key","_keySelected","_characterID","_donotusekey","_object","_result","_outcome","_oid","_object_para"];
//PVDZE_veh_Publish2 = [[_dir,_location],_part_out,false,_keySelected,_activatingPlayer];
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
@@ -14,7 +14,7 @@ if(_donotusekey) then {
_isOK = isClass(configFile >> "CfgWeapons" >> _keySelected);
};
if(!_isOK) exitWith { diag_log ("HIVE: CARKEY DOES NOT EXIST: "+ str(_keySelected)); };
if(!_isOK) exitWith {diag_log ("HIVE: CARKEY DOES NOT EXIST: "+ str(_keySelected));};
if(_donotusekey) then {
_characterID = _keySelected;
@@ -26,7 +26,6 @@ _dir = _worldspace select 0;
_location = _worldspace select 1;
_uid = _worldspace call dayz_objectUID2;
//Send request
_key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, 0 , _characterID, _worldspace, [], [], 1,_uid];
#ifdef OBJECT_DEBUG
@@ -35,57 +34,29 @@ diag_log ("HIVE: WRITE: "+ str(_key));
_key call server_hiveWrite;
// Switched to spawn so we can wait a bit for the ID
[_uid,_characterID,_class,_dir,_location,_donotusekey,_activatingPlayer] spawn {
private ["_object","_uid","_characterID","_done","_retry","_key","_result","_outcome","_oid","_class","_location","_object_para","_donotusekey","_activatingPlayer"];
_key = format["CHILD:388:%1:",_uid];
_uid = _this select 0;
_characterID = _this select 1;
_class = _this select 2;
//_dir = _this select 3;
_location = _this select 4;
_donotusekey = _this select 5;
_activatingPlayer = _this select 6;
#ifdef OBJECT_DEBUG
diag_log ("HIVE: WRITE: "+ str(_key));
#endif
_done = false;
_retry = 0;
// TODO: Needs major overhaul for 1.1
while {_retry < 10} do {
// GET DB ID
_key = format["CHILD:388:%1:",_uid];
#ifdef OBJECT_DEBUG
diag_log ("HIVE: WRITE: "+ str(_key));
#endif
_result = _key call server_hiveReadWrite;
_outcome = _result select 0;
if (_outcome == "PASS") then {
_oid = _result select 1;
#ifdef OBJECT_DEBUG
diag_log("CUSTOM: Selected " + str(_oid));
#endif
_done = true;
_retry = 100;
_result = _key call server_hiveReadWrite;
_outcome = _result select 0;
} else {
diag_log("CUSTOM: trying again to get id for: " + str(_uid));
_done = false;
_retry = _retry + 1;
uiSleep 1;
};
};
if (_outcome != "PASS") then {
diag_log("CUSTOM: failed to get id for : " + str(_uid));
} else {
_oid = _result select 1;
if(!_done) exitWith { diag_log("CUSTOM: failed to get id for : " + str(_uid)); };
#ifdef OBJECT_DEBUG
diag_log("CUSTOM: Selected " + str(_oid));
#endif
if(DZE_TRADER_SPAWNMODE) then {
//_object_para = createVehicle ["ParachuteMediumWest", [0,0,0], [], 0, "CAN_COLLIDE"];
_object_para = "ParachuteMediumWest" createVehicle [0,0,0];
_object_para setPos [_location select 0, _location select 1,(_location select 2) + 65];
//_object = createVehicle [_class, [0,0,0], [], 0, "CAN_COLLIDE"];
_object = _class createVehicle [0,0,0];
} else {
//_object = createVehicle [_class, _location, [], 0, "CAN_COLLIDE"];
// Don't use setPos or CAN_COLLIDE here. It will spawn inside other vehicles
_object = _class createVehicle _location;
if (surfaceIsWater _location && {({_x != _object} count (_location nearEntities ["Ship",8])) == 0}) then {
@@ -95,7 +66,6 @@ _key call server_hiveWrite;
};
if(!_donotusekey) then {
// Lock vehicle
_object setvehiclelock "locked";
};
@@ -105,7 +75,6 @@ _key call server_hiveWrite;
_object setVariable ["ObjectID", _oid, true];
_object setVariable ["lastUpdate",diag_tickTime];
_object setVariable ["CharacterID", _characterID, true];
//_object setVelocity [0,0,1];
if(DZE_TRADER_SPAWNMODE) then {
_object attachTo [_object_para, [0,0,-1.6]];
@@ -114,12 +83,11 @@ _key call server_hiveWrite;
detach _object;
deleteVehicle _object_para;
};
_object call fnc_veh_ResetEH;
// for non JIP users this should make sure everyone has eventhandlers for vehicles.
PVDZE_veh_Init = _object;
publicVariable "PVDZE_veh_Init";
diag_log format["PUBLISH: %1(%2) bought %3 with ObjectUID %4",if (alive _activatingPlayer) then {name _activatingPlayer} else {"DeadPlayer"},getPlayerUID _activatingPlayer,_class,_uid];
};