Jump to content

Duplicate ObjectUID Fix - Custom Addon with Arma2NET


SKO85

Recommended Posts

NOTE: Still in edit. Could contain some mistakes :)

Hi everyone,

I have been struggling a lot finding a working solution for the duplicate ObjectUID generation in the 1.0.5.1 version of the Epoch Mod. On my server I am using custom scripts like:

  • Plot Management
  • Snap Pro
  • Vector Building
  • And more...

All these custom scripts require additional values in the Worldspace column of your database. In a lot of changes that I have seen, the dayz_objectUID2 function was adapted to to generate some kind of a unique value for each object in your database. This was never working well for me. My database had about 3000-4000 objects and we got sometimes 5-10 duplicates in it. So I decided to use my software coding skills and create a more robust solution which is clean and easy to implement. It does not matter how your worldspace looks like and if you are using several of the above mentioned custom scripts.

The fix is using numerical 2 hashing alghorithms: MD5 and SHA1. Both are merged with a numerical transformation which provides a unique value. I will test the performance and release separated DLL's using only MD5 or SHA1 soon with some performance results for comparison.

IMPORTANT:

It is important not to have duplicate worldspace items in your database. Sometimes the server will spawn several vehicles at position 0,0 on the map. This will cause having same ObjectUID's. I have fixed this too and it is included in the instructions bellow. You will also need to clean your database. This can be done manually or with a tool that I provide with this solution.

Also, make a backup of your database so you can avoid loosing changes. If anything goes wrong, you can go back and restore as it was before ;)

 

ARMA2NET:

First of all, you will need an additional MOD to include on your server. This does not affect your players and they will not need to download anything. I am using Arma2NET as a mod which allows me to create custom DLL's for Arma 2 OA. This DLL contains code to generate hashes of the Worldspace which are unique.

  1. Follow the tutorial on "How to Install and setup Arma2NET".
  2. Download Arma2NET files from Armaholic's website: Click here to download.

 

Arma2NET Directory:

  1. Go to your @Arma2NET directory in the root of Arma 2 OA.
  2. Go to the AddIns directory.
  3. Download the ZIP from this post and place the ObjectUID directory inside the AddIns folder.
  4. It should look like: @Arma2NET\AddIns\ObjectUID\ObjectUID.dll

 

Epoch Server Changes:

Go to your server's PBO file or folder and open server_functions.sqf. Now replace the dayz_objectUID2 and dayz_objectUID3 code with:

function dayz_objectUID2

Spoiler

dayz_objectUID2 = {
    // Credits: FP4P
    // Date: 2017-02-16
    // PayPal: paypal.me/fp4p

    private["_key", "_worldspace", "_tmpArray", "_quoteUnicode"];
    _key = "";
    _worldspace = _this;

    // Convert WorldSpace to a string.
    if(typeName(_worldspace) != "STRING") then {
        _worldspace = str (_this);
        _tmpArray = toArray(_worldspace);
        _quoteUnicode = toArray("""") select 0;
        _tmpArray = _tmpArray - [_quoteUnicode];
        _worldspace = toString(_tmpArray);
    };

    // Call custom UID extension
    _key = "Arma2Net.Unmanaged" callExtension format["GenerateUID %1", _worldspace];

    // Return the generated key.
    _key
};

function dayz_objectUID3

Spoiler

dayz_objectUID3 = {
    private["_key"];
    _key = _this call dayz_objectUID2;    
    _key
};

function spawn_vehicles

This is a fix for the 0-0 position spawn of vehicles.

Find code:

Spoiler

_objPosition = getPosATL _veh;

After the above line, place the following check:

Spoiler

// Check if position is [0,0]
_objPosition select 0) == 0 && (_objPosition select 1) == 0) exitWith { diag_log("DEBUG: POSITION: Skip vehicle spawn at position 0-0"); };    

So end result will be:

Spoiler

_objPosition = getPosATL _veh;
        
// Check if position is [0,0]
if((_objPosition select 0) == 0 && (_objPosition select 1) == 0) exitWith { diag_log("DEBUG: POSITION: Skip vehicle spawn at position 0-0"); };

 

Database Fix:

If you already have a database which is used and contains conflicted ObjectUID's, you will need to fix them manually by changing them before restart or you could use a simple tool I created for this. The tool will be posted here soon. I will make it configurable so you can use it to fix the ObjectUID's in your database.

 

Credits:

You are not allowed to change any of the above code or distribute this without my knowledge and permission. Download this resource only from this page to avoid hacked versions. Suggestions for improvements are welcome.

 

Donations:

Donations for my work are always welcome. You can donate at http://paypal.me/fp4p. Thank you!

 

Downloads:

- ObjectUID Fix - GitHub Download

Link to comment
Share on other sites

4 hours ago, LunatikCH said:

Nive one but wrong forum maybe? this is 106 section 1051 is here: https://epochmod.com/forum/forum/34-a2-epoch-mods-1051/

This should be working with 1.0.6 too, but I have not tested it yet. I don't know if version 1.0.6 has this problem with ObjectUID's when using Vector Building and Plot Management, but will test that out soon or if someone already has this issue with 1.0.6, please feel free to test the fix and report it here.

Link to comment
Share on other sites

7 minutes ago, LunatikCH said:

Was fixed in 106 by default afaik

Also with vector building and plot management? I know some of them are included already, but I have not finished my 1.0.6 server yet to test it :P Does 1.0.6 include Vector Building by default and how does 1.0.6 handle same Worldspace values for the ObjectUID? Is the fix for 0-0 position vehicle spawning also fixed in there?

Link to comment
Share on other sites

2 hours ago, SKO85 said:

Also with vector building and plot management? I know some of them are included already, but I have not finished my 1.0.6 server yet to test it :P Does 1.0.6 include Vector Building by default and how does 1.0.6 handle same Worldspace values for the ObjectUID? Is the fix for 0-0 position vehicle spawning also fixed in there?

Regardless of modifications it's fixed in the HiveExt. SQF Key generation is temporary until restart, and is more robust than in 1.0.5.1, making collisions practically impossible.

https://github.com/icomrade/DayZhiveEpoch/blob/master/Hive/Source/HiveLib/DataSource/SqlObjDataSource.cpp#L98-L112

 

Edit: Also moved to 1.0.5.1 mods

Link to comment
Share on other sites

14 minutes ago, icomrade said:

Regardless of modifications it's fixed in the HiveExt. SQF Key generation is temporary until restart, and is more robust than in 1.0.5.1, making collisions practically impossible.

https://github.com/icomrade/DayZhiveEpoch/blob/master/Hive/Source/HiveLib/DataSource/SqlObjDataSource.cpp#L98-L112

 

Edit: Also moved to 1.0.5.1 mods

That's good to know, thanks. So ObjectUID's are always different on server restart, because a timestamp is included right? So this fix would only apply for 1.0.5.1 issues. I will will leave the testing part then of 1.0.6 ;)

Link to comment
Share on other sites

2 hours ago, SKO85 said:

That's good to know, thanks. So ObjectUID's are always different on server restart, because a timestamp is included right? So this fix would only apply for 1.0.5.1 issues. I will will leave the testing part then of 1.0.6 ;)

No, the only time an objectUID changes is the first server startup after a vehicle is created. Otherwise it will be ObjectID + 1, where ObjectID is an autoincremented value in the MySQL DB - ObjectID is never reused for any object. These changes cannot be implemented into 1.0.5.1, unless the hive DLL is rebuilt with the fix posted, but 1.0.6 contains other changes to the hive which make it unsuitable for direct replacement.

Link to comment
Share on other sites

1 minute ago, icomrade said:

No, the only time an objectUID changes is the first server startup after a vehicle is created. Otherwise it will be ObjectID + 1, where ObjectID is an autoincremented value in the MySQL DB - ObjectID is never reused for any object. These changes cannot be implemented into 1.0.5.1, unless the hive DLL is rebuilt with the fix posted, but 1.0.6 contains other changes to the hive which make it unsuitable for direct replacement.

Yeah, I've checked the code in 1.0.6 on this. It is much clear now. And the structure is different a bit in the DB, so I understand that the Hive DLL is also changed. But good to read that it is fixed by default in 1.0.6. Thanks for the update.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Discord

×
×
  • Create New...