Skip to content

Commit

Permalink
Minor Updates:
Browse files Browse the repository at this point in the history
 - 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
  • Loading branch information
Nico-Posada committed Jan 3, 2024
1 parent dd3e263 commit 6afcb27
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
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

0 comments on commit 6afcb27

Please sign in to comment.