https://github.com/HerculesWS/Hercules/pull/1046
the way it calculate the unique ID is
https://github.com/HerculesWS/Hercules/blob/09a2201e0d8563608a421378970f9d9ae6bc38bc/src/map/itemdb.c#L1922
return ((uint64)sd->status.char_id << 32) | sd->status.uniqueitem_counter++;which is, there is an upper value and lower value
the upper value is the char ID, move 32 bits left
and the left over, lower value is unique item counter
you can try this in your test server
SELECT char_id, unique_id, unique_id >>32, unique_id & ((1<<32)-1) FROM inventory where unique_id <> 0;SELECT char_id, unique_id, unique_id >> 32 & 0xffffffff, unique_id & 0xffffffff FROM inventory where unique_id <> 0;the reason why its implement this way has explained by Haru and hemagx, its for multiple map-server supportsince there can be only 1 char can connect to a map-server at a time
in other words, I think this unique ID should be split into 2 value
@inventorylist_uid_char = return the upper value of unique ID
@inventorylist_uid_counter = return the lower value of unique ID
the way rathena return the value in 64bits is just ... hilarious to me
*getitem return a value
since the upper value is always its char ID, I guess can make it return the sd->status.uniqueitem_counter instead
EDIT: just tested, the counter start from 0, so it has to return -1 for error
*hasuniqueid, deleteuniqueid
this is tough, it has to search through `inventory`, `cart_inventory`, `storage`, `guild_storage`, `mail` and `auction` table
its better to do this via SQL