From 6afcb279dc43ba57cdfc9c491a4afe23d39af16c Mon Sep 17 00:00:00 2001 From: Nico Posada Date: Wed, 3 Jan 2024 13:15:04 -0600 Subject: [PATCH] Minor Updates: - 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 --- CoDLuaDecompiler.Decompiler/IR/Expression/Constant.cs | 2 +- .../Structures/LuaFunction/LuaJit/LuaJitFunctionMw2.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CoDLuaDecompiler.Decompiler/IR/Expression/Constant.cs b/CoDLuaDecompiler.Decompiler/IR/Expression/Constant.cs index faba4d6..d43628d 100644 --- a/CoDLuaDecompiler.Decompiler/IR/Expression/Constant.cs +++ b/CoDLuaDecompiler.Decompiler/IR/Expression/Constant.cs @@ -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: diff --git a/CoDLuaDecompiler.Decompiler/LuaFile/Structures/LuaFunction/LuaJit/LuaJitFunctionMw2.cs b/CoDLuaDecompiler.Decompiler/LuaFile/Structures/LuaFunction/LuaJit/LuaJitFunctionMw2.cs index 228dc50..f11f5f3 100644 --- a/CoDLuaDecompiler.Decompiler/LuaFile/Structures/LuaFunction/LuaJit/LuaJitFunctionMw2.cs +++ b/CoDLuaDecompiler.Decompiler/LuaFile/Structures/LuaFunction/LuaJit/LuaJitFunctionMw2.cs @@ -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); @@ -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);