Conversation
📝 WalkthroughWalkthroughAdds a Lua checksum feature: a hook invoking a new lua_dochecksum, MD5-based dumping of Lua state via lua_dump and Md5_Writer, new Lua/MD5 symbol declarations, and default template parameters added to Changes
Sequence Diagram(s)sequenceDiagram
participant Hook as Hook (0x004CEE33)
participant LuaFunc as lua_dochecksum
participant LuaState as Lua State
participant LuaDump as lua_dump
participant MD5 as MD5Context
Hook->>LuaFunc: invoke
LuaFunc->>LuaState: get global userdata (sim)
alt userdata present
LuaFunc->>MD5: obtain MD5Context (Offset(sim, 0x50))
LuaFunc->>LuaDump: lua_dump(L, Md5_Writer, MD5)
loop per chunk
LuaDump->>LuaFunc: chunk (data, size)
LuaFunc->>MD5: Md5_Writer -> Update(data, size)
end
else userdata null
LuaFunc->>LuaState: delegate to Lua (no args)
end
LuaFunc-->>Hook: return (xor eax, eax at 0x00914BD7)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Right now it requires some changes since it also includes source file in dump function which may differ accross players. |
There was a problem hiding this comment.
🧹 Nitpick comments (3)
section/LuaSimCheckSum/LuaSimCheckSum.h (2)
10-10: Missing newline at end of file.Some compilers emit a warning for files not ending with a newline. Add a trailing newline after line 10.
Fix
void __thiscall gpg__MD5Context__Update(/* gpg::MD5Context */ void *_this, const void *block, size_t size) asm("0x008E5870"); +🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@section/LuaSimCheckSum/LuaSimCheckSum.h` at line 10, The file ends without a trailing newline; open the header containing the declaration for gpg__MD5Context__Update (the line with "void __thiscall gpg__MD5Context__Update(... ) asm(\"0x008E5870\");") and add a single newline character at the end of the file so the file ends with a newline.
7-7:lua_pcallFis declared but unused.This function is declared here but not referenced in
LuaSimCheckSum.cxx. If it's intended for future use or debugging, consider adding a brief comment noting that; otherwise it could be removed to keep the header minimal.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@section/LuaSimCheckSum/LuaSimCheckSum.h` at line 7, The header declares an unused function symbol lua_pcallF; remove this declaration from LuaSimCheckSum.h if it's not used anywhere, or if you intend to keep it for future use/debugging, add a one-line comment above the declaration clarifying its purpose (e.g., "kept for future debugging/extern reference") and optionally add an explicit // FIXME or TODO tag; also scan LuaSimCheckSum.cxx for planned references to lua_pcallF and update those callers if needed.section/LuaSimCheckSum/LuaSimCheckSum.cxx (1)
9-24: Unchecked return value fromlua_dump.
lua_dumpcan return non-zero if the writer callback errors. Currently the return is ignored, so a partial/failed dump would silently produce an incomplete checksum. Consider at least logging a warning on failure to aid debugging desync issues.Suggested improvement
- lua_dump(L, Md5_Writer, md5); + if (lua_dump(L, Md5_Writer, md5) != 0) + { + WarningF("lua_dochecksum: lua_dump failed"); + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@section/LuaSimCheckSum/LuaSimCheckSum.cxx` around lines 9 - 24, In lua_dochecksum, lua_dump’s return value is ignored; capture its int result when calling lua_dump(L, Md5_Writer, md5) and if non-zero log a warning including the return code and context (e.g., function name and sim/md5 identifiers) to aid debugging, then proceed safely (still call lua_call to preserve behavior) or bail if appropriate; reference the lua_dochecksum function, the lua_dump call, the Md5_Writer callback and the md5 local to locate where to add the check and LogF (or existing logger) call.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@section/LuaSimCheckSum/LuaSimCheckSum.cxx`:
- Around line 9-24: In lua_dochecksum, lua_dump’s return value is ignored;
capture its int result when calling lua_dump(L, Md5_Writer, md5) and if non-zero
log a warning including the return code and context (e.g., function name and
sim/md5 identifiers) to aid debugging, then proceed safely (still call lua_call
to preserve behavior) or bail if appropriate; reference the lua_dochecksum
function, the lua_dump call, the Md5_Writer callback and the md5 local to locate
where to add the check and LogF (or existing logger) call.
In `@section/LuaSimCheckSum/LuaSimCheckSum.h`:
- Line 10: The file ends without a trailing newline; open the header containing
the declaration for gpg__MD5Context__Update (the line with "void __thiscall
gpg__MD5Context__Update(... ) asm(\"0x008E5870\");") and add a single newline
character at the end of the file so the file ends with a newline.
- Line 7: The header declares an unused function symbol lua_pcallF; remove this
declaration from LuaSimCheckSum.h if it's not used anywhere, or if you intend to
keep it for future use/debugging, add a one-line comment above the declaration
clarifying its purpose (e.g., "kept for future debugging/extern reference") and
optionally add an explicit // FIXME or TODO tag; also scan LuaSimCheckSum.cxx
for planned references to lua_pcallF and update those callers if needed.
Include loaded lua files into sim checksum. It uses lua's bytecode for checksum via
lua_dumpfunction.Downsides of this change include:
GetFocusArmy,IsReplayand etc will desync across players.Summary by CodeRabbit
New Features
Chores