Prevent duplicate objectUIDs

See #1504 for the details
This commit is contained in:
ebaydayz
2016-02-24 12:31:13 -05:00
parent 9bbeb1e43e
commit ff4a227a1d
5 changed files with 19 additions and 4 deletions

View File

@@ -49,6 +49,7 @@
[FIXED] Keyboard input is now disabled properly while unconscious @skynetdev @ebaydayz #1613 [FIXED] Keyboard input is now disabled properly while unconscious @skynetdev @ebaydayz #1613
[FIXED] Toilet paper dupe exploit when building outhouse @Markokil321 @ebaydayz #1599 [FIXED] Toilet paper dupe exploit when building outhouse @Markokil321 @ebaydayz #1599
[FIXED] Safes and lockboxes wiped when opening after restart and locking not being logged to RPT @ebaydayz #1413 #1503 [FIXED] Safes and lockboxes wiped when opening after restart and locking not being logged to RPT @ebaydayz #1413 #1503
[FIXED] Duplicate objectUIDs occasionally causing vehicles to swap classes or be deleted across restarts @ebaydayz #1504
[UPDATED] .hpp files updated in dayz_epoch_b CfgLootPos > CfgBuildingPos. @Uro1 [UPDATED] .hpp files updated in dayz_epoch_b CfgLootPos > CfgBuildingPos. @Uro1
[UPDATED] .bat files updated in Config-Examples @Raziel23x [UPDATED] .bat files updated in Config-Examples @Raziel23x

View File

@@ -49,8 +49,6 @@ if (_spawnDMG) then {
}; };
}; };
// TODO: check if uid already exists && if so increment by 1 && check again as soon as we find nothing continue.
//Send request //Send request
_key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, _damage , _characterID, _worldspace, [], _array, _fuel,_uid]; _key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, _damage , _characterID, _worldspace, [], _array, _fuel,_uid];
diag_log ("HIVE: WRITE: "+ str(_key)); diag_log ("HIVE: WRITE: "+ str(_key));

View File

@@ -28,8 +28,6 @@ _location = _worldspace select 1;
//Generate UID test using time //Generate UID test using time
_uid = _worldspace call dayz_objectUID3; _uid = _worldspace call dayz_objectUID3;
// TODO: check if uid already exists && if so increment by 1 && check again as soon as we find nothing continue.
//Send request //Send request
_key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, 0 , _characterID, _worldspace, [], [], 1,_uid]; _key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, 0 , _characterID, _worldspace, [], [], 1,_uid];
diag_log ("HIVE: WRITE: "+ str(_key)); diag_log ("HIVE: WRITE: "+ str(_key));

View File

@@ -579,6 +579,9 @@ server_getDiff2 = {
_result _result
}; };
currentObjectUIDs = [];
keyStartNumber = 100000000000;
dayz_objectUID = { dayz_objectUID = {
private["_position","_dir","_key","_object"]; private["_position","_dir","_key","_object"];
_object = _this; _object = _this;
@@ -599,6 +602,12 @@ dayz_objectUID2 = {
_key = _key + str(round(_x)); _key = _key + str(round(_x));
} count _position; } count _position;
_key = _key + str(round(_dir)); _key = _key + str(round(_dir));
// Make sure the generated key is not a duplicate
while {true} do {
if !(_key in currentObjectUIDs) exitWith {currentObjectUIDs set [count currentObjectUIDs,_key];};
keyStartNumber = keyStartNumber + 1;
_key = str keyStartNumber;
};
_key _key
}; };
@@ -613,6 +622,12 @@ dayz_objectUID3 = {
_key = _key + str(round(_x)); _key = _key + str(round(_x));
} count _position; } count _position;
_key = _key + str(round(_dir + time)); _key = _key + str(round(_dir + time));
// Make sure the generated key is not a duplicate
while {true} do {
if !(_key in currentObjectUIDs) exitWith {currentObjectUIDs set [count currentObjectUIDs,_key];};
keyStartNumber = keyStartNumber + 1;
_key = str keyStartNumber;
};
_key _key
}; };

View File

@@ -96,6 +96,9 @@ if (isServer && isNil "sm_done") then {
_fuel = _x select 7; _fuel = _x select 7;
_damage = _x select 8; _damage = _x select 8;
// Set objectUIDs in currentObjectUIDs list to prevent duplicates
if (_type in dayz_allowedObjects) then {_worldspace call dayz_objectUID2;} else {_worldspace call dayz_objectUID3;};
_dir = 0; _dir = 0;
_pos = [0,0,0]; _pos = [0,0,0];
_wsDone = false; _wsDone = false;