I was asked for some clarification on my code so I thought I'd just post a short explanation on what it does below. There might be some mistakes, however combined with the source it should be understandable. It should help anyone trying to make tools to unid stuff.
Below is an UNID item link
Code:
|HItem:2,1565456761:-146123031:1273837477,-2012337763,1951515674,-334812892:-1:0:130756:9:8:8:523:523:0:0:6:0:-648496672:|h[가시 투구]|h
There are 18 fields separated by colons.
The difference between the ID version of this link and the UNID version (above) is field 3(0-indexed) has a reversed comma separated list field 9 has a different flag, and the last numeric field has a different hash. To transform an UNID link to an ID link you do the following:
Take the affix list and reverse it
Code:
|HItem:2,1565456761:-146123031:1273837477,-2012337763,1951515674,-334812892:-1:0:130756:9:8:8:523:523:0:0:6:0:-648496672:|h[가시 투구]|h
becomes
|HItem:2,1565456761:-146123031:-334812892,1951515674,-2012337763,1273837477:-1:0:130756:9:8:8:523:523:0:0:6:0:-648496672:|h[가시 투구]|h
set the least significant bit of field 9
Code:
|HItem:2,1565456761:-146123031:]-334812892,1951515674,-2012337763,1273837477:-1:0:130756:9:8:8:523:523:0:0:6:0:-648496672:|h[가시 투구]|h
becomes
|HItem:2,1565456761:-146123031:]-334812892,1951515674,-2012337763,1273837477:-1:0:130756:9:8:9:523:523:0:0:6:0:-648496672:|h[가시 투구]|h
and the slightly tricky part of it, you have to recalculate the hash of the new string.
The input to the hash function is simply all the numerics in the item link before the hash, so you take the hash of
Code:
2,1565456761:-146123031:-334812892,1951515674,-2012337763,1273837477:-1:0:130756:9:8:9:523:523:0:0:6:0
which is 1941137377 and you insert it in place of the old hash
so
Code:
|HItem:2,1565456761:-146123031:]-334812892,1951515674,-2012337763,1273837477:-1:0:130756:9:8:9:523:523:0:0:6:0:-648496672:|h[가시 투구]|h
becomes
|HItem:2,1565456761:-146123031:]-334812892,1951515674,-2012337763,1273837477:-1:0:130756:9:8:9:523:523:0:0:6:0:1941137377:|h[가시 투구]|h
The above is represented by the Python code:
Code:
def IDLink(s):
parts = s.split(":")
affixes = parts[3].split(',')
affixes.reverse()
parts[3] = ','.join(affixes)
parts[9] = str(int(parts[9]) | 0x1)
hash_input = ':'.join(parts[1:-2]) + ':'
link_hash = c_int32(hashString(hash_input)).value
parts[-2] = str(link_hash)
id = ':'.join(parts)
return id
parts[9] = str(int(parts[9]) | 0x1)
hash_input = ':'.join(parts[1:-2]) + ':'
link_hash = c_int32(hashString(hash_input)).value
parts[-2] = str(link_hash)