Skip to content

Conversation

@Nico-Posada
Copy link

@Nico-Posada Nico-Posada commented Jan 3, 2024

Hashes in MWII and MWIII aren't truncated to 60 bits
image

There are many examples I could give as proof, but this is a snippet of the assembly that registers the lua C functions. The args are (luaVM, hash, func address). You can see with rdx being set to many different hash values, some (highlighted) are values that are higher than 0xFFFFFFFFFFFFFFF. Updating the decompiler so that it doesn't truncate the hashes for MWII and MWIII would make it much better to avoid confusion.

Edit: I was making this comment with the regular 0x7FFFFFFFFFFFFFFF truncation in mind, slight brain fart. Point still stands though, but now every single hash in that screenshot is proof except for the second one.

 - hashes in MWII and MWIII are not truncated to 60 bits, fix accordingly
 - string formatting fix so hashes are fully 0-padded to 16 chars
var idfk = Reader.ReadByte(); // Seems like hash type? 2 for material, 0 for array index, engine #
var hash = ((hi << 32) | lo) & 0xFFFFFFFFFFFFFFF;
var hash = ((hi << 32) | lo); //& 0xFFFFFFFFFFFFFFF;
if (Decompiler.HashEntries.ContainsKey(hash))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package index won't work if you don't apply the mask, you need to add it every time you're asking it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not seeing anywhere the hashes are forced to be truncated to 60 bits. Can you elaborate on this a bit?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hashes inside the wni files are 60 bits, so by only removing the mask, you won’t be able to query them

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah you're right, I had removed that truncation in my local build and forgot I did that. You just need to remove this mask here https://github.com/JariKCoding/CoDLuaDecompiler/blob/master/CoDLuaDecompiler.HashResolver/PackageIndex.cs#L47

Too lazy to add it to this PR especially since this repo is inactive.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it still doesn't work, like I said the hashes inside the wni files are 60 bits, so removing this mask won't work. Here are, for example, the first hashes in the bo4_file_names.wni file:

785e3fb024ffd43,ui/uieditor/widgets/playercontextualmenu_item
4bab6f9d42ee007,ui/uieditor/widgets/playercontextualmenu_item.lua
47803d0fb7647f2,ui/uieditor/widgets/pc/startmenu/dropdown/optiondropdown
c8285898a8a11d2,ui/uieditor/widgets/pc/startmenu/dropdown/optiondropdown.lua

They all have the mask

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My proposed changes would only affect the mw2 decomp. The wnis are fully capable of storing full 64 bit hashes and I've been using them with the full 64 bits this whole time.

@Nico-Posada Nico-Posada changed the title Fix hash truncation for MWII (and MWIII technically) Add more CLI options and add basic update for BO6 Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants