Correct duplicate object UID check

I forgot numbers greater than 1 million are truncated when converted to
string:

http://killzonekid.com/arma-scripting-tutorials-float-to-string-position-to-string/

KeyStartNumber exceeded 6 digits which is why it was being truncated to
"1e+011" and getting stuck on loop (as that string was already in
currentObjectUIDs) as mentioned in 2df7279.

Starting at 10, there should never be more than a couple duplicates
generated, so keyStartNumber will never exceed about 100 max.  Added an
exit just for a fail safe.
This commit is contained in:
ebaydayz
2016-05-16 11:52:45 -04:00
parent 116caaa788
commit 65233757e8
2 changed files with 4 additions and 1 deletions

View File

@@ -228,6 +228,9 @@ dayz_objectUID2 = {
while {true} do {
if !(_key in currentObjectUIDs) exitWith {currentObjectUIDs set [count currentObjectUIDs,_key];};
keyStartNumber = keyStartNumber + 1;
if (keyStartNumber > 40000) exitWith { //Should never fail more times than total number of objects in database
diag_log format["ERROR: dayz_objectUID2 failed to correct duplicate objectUID: %1. This should not happen.",_key];
};
_key = str keyStartNumber;
diag_log format["Duplicate UID generated by dayz_objectUID2. Automatically corrected to +1= %1. This should rarely happen.",_key];
};