Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughAdds assembly hook snippets and two new C++ sources: one initializes unit boolean flags during construction; the other exposes a Lua binding to set a unit's isForceReclaim flag and an assembly hook that checks that flag and clears storage-full indicators before resuming original execution. Changes
Sequence DiagramsequenceDiagram
participant Lua as "Lua"
participant Cpp as "ForceReclaim()"
participant Memory as "Unit Memory"
participant Asm as "asm__IsForceReclaim"
Lua->>Cpp: Call ForceReclaim(unit, flag)
Cpp->>Cpp: validate args, resolve Unit pointer
Cpp->>Memory: write boolean -> unit + 0x11E (isForceReclaim)
Note over Memory,Asm: Later execution hits hooked address
Memory-->>Asm: asm__IsForceReclaim invoked
Asm->>Memory: read isForceReclaim flag
alt flag == true
Asm->>Memory: clear energy/mass storage-full bits
end
Asm->>Asm: jump to original/default code path
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 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. 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@section/MohoUnitConstructor.cpp`:
- Around line 2-10: asm__UnitConstructor is currently compiled with a normal
prologue/epilogue so its use of ebp+0x687/0x688 targets the wrong stack slot;
mark the function as naked and C-linked to preserve caller frame layout (e.g.
declare with extern "C" and __attribute__((naked))) and change the inline
assembly to use __asm__ __volatile__ with the same instructions so the compiler
does not emit prologue/epilogue code; apply the same change to the analogous
function in UnitForceReclaim.cpp.
🧹 Nitpick comments (1)
section/UnitForceReclaim.cpp (1)
25-36: Extract the0x687field offset into a named constant.Keeping the offset as a magic number makes future layout changes easy to miss. A shared constant (even if only used on the C++ side) improves auditability.
Suggested refactor
+#if !defined(__UNIT_FORCE_RECLAIM_OFFSETS__) +#define __UNIT_FORCE_RECLAIM_OFFSETS__ +namespace { +constexpr int kUnitForceReclaimOffset = 0x687; +} +#endif @@ - GetField<bool>(unit, 0x687) = flag; + GetField<bool>(unit, kUnitForceReclaimOffset) = flag;
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@section/UnitForceReclaim.cpp`:
- Around line 6-22: Mark the naked assembly hook functions so the compiler won’t
emit prologue/epilogue: add __attribute__((naked)) to asm__IsForceReclaim (and
apply the same change to other hook functions asm__UnitConstructor and
asm__GetFootprint) so they don't generate push ebp/mov ebp,esp; also standardize
redundant segment prefixes in the inline asm (remove or make consistent between
ds: and ss: for stack/heap accesses) to avoid confusion while keeping the same
memory operands and the final jmp target intact.
🧹 Nitpick comments (1)
section/UnitForceReclaim.cpp (1)
42-46: Consider adding documentation for the Lua binding.The registration has an empty documentation string. A brief description would help modders understand the function's purpose.
📝 Suggested documentation
UnitMethodReg ForceReclaimReg{ "ForceReclaim", - "", + "Unit:ForceReclaim(bool) - When enabled, engineer continues reclaiming even if storage is full", ForceReclaim, "Unit"};
Addded Unit:ForceReclaim(bool) When enabled engineer will continue reclaiming even if storage is full.
Added Unit:ForceReclaim(bool)
When enabled engineer will continue reclaiming even if storage is full.
Summary by CodeRabbit
New Features
Behaviour Changes
Chores
✏️ Tip: You can customize this high-level summary in your review settings.