borderlands2
borderlands2 copied to clipboard
Parse issue or invalid data representation
In unwrap_item_info, there is an issue when parsing something like the Legendary Psycho Classmod that it returns 256 for the library rather than 0. This might be an issue where python doesn't support uint or some invalid offset issue. I'm not sure.
Thanks for the report, I haven't had time to try out Krieg yet but I'll take a look at the problem at the weekend. My guess would be that the code is mistakenly reading a value as a byte rather than as a varint.
I've taken a look and it seems that when the item set ID isn't 0 the top bit of the library number indicates whether the remaining bits reference a library in the item's set, or in set 0. For example, the Legendary Psycho Class Mod has a set ID of 6 and the following raw prefix and title entries:
- library 32, asset 37
- library 1, asset 0
As the item part library values are 6 bits wide, these end up interpreted as:
- set 6, library 0, asset 37 ("Legendary Psycho")
- set 0, library 1, asset 0 ("Class Mod")
Not sure how to represent this in the JSON structure yet, possibly {"lib": 0, "asset": 37, "use_set": true}
So when set id != 0, the left most bit of the 6 library bits determine if it is referencing the assets in the base set or the assets in its currents set. So 0b100000, so it only has 5 significant bits for the library? Basically if > 255 it means that the offsets change?
The size of the library number varies:
item type: 9 bits weapon type: 7 bits part: 6 bits manufacturer: 4 bits balance: 10 bits
It appears that the library numbers are all one bit larger than they need to be to represent all existing values, so what I suggested earlier could be simplified to:
set = 0 if top bit clear, else the set ID of the item/weapon (which might also be 0) library = raw library number with the top bit cleared
Does this apply for assets as well?
For example with the legendary psycho item. 'is_weapon': 0, 'set': 6 'type': {'asset': 11, 'lib': 256} where asset is 8 bits, and lib is 9 bits.
Since the int value 11 does not have a bit in the 8th position (left most), asset uses set 0. Since the int value 256 has a bin in the 9th position (left most), library uses set 6 ?