Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hash truncation for MWII (and MWIII technically) #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CoDLuaDecompiler.Decompiler/IR/Expression/Constant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public override string ToString()
case Identifiers.ValueType.Boolean:
return Boolean ? "true" : "false";
case Identifiers.ValueType.Hash:
return $"0x{Hash & 0xFFFFFFFFFFFFFFF:X}";
return $"0x{Hash/* & 0xFFFFFFFFFFFFFFF*/:X016}";
case Identifiers.ValueType.Table:
return "{}";
case Identifiers.ValueType.VarArgs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected override ILuaJitConstant ReadComplexConstant()
var hi = Reader.ReadULEB128();
var lo = Reader.ReadULEB128();
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))
return new LuaJitConstant(Decompiler.HashEntries[hash]);
return new LuaJitConstant(hash);
Expand All @@ -71,7 +71,7 @@ protected override ILuaJitConstant ReadTableItem()
var hi = Reader.ReadULEB128();
var lo = Reader.ReadULEB128();
Reader.ReadByte();
var hash = ((hi << 32) | lo) & 0xFFFFFFFFFFFFFFF;
var hash = ((hi << 32) | lo);// & 0xFFFFFFFFFFFFFFF;
if (Decompiler.HashEntries.ContainsKey(hash))
return new LuaJitConstant(Decompiler.HashEntries[hash]);
return new LuaJitConstant(hash);
Expand Down