REDIVIVUS

Proposals / #682

Return a unit pointer from the Mac next-unit getter

applied · by Commit-Will · submitted 2026-11-01, applied 2026-11-01

Ghidra vmac 105 · 3bccb89

Complete65-byte GetNextUnit returns full EAX=[pUnit+0xe4], the existing D2UnitStrc.pListNext pointer, at its only RET. All eight direct callers are audited: unit-table loops retain the returned address, test it for NULL and either continue traversal or pass units to FreeServerUnit. FreeMonsters also stores the returned pointer back into the game's same unit-table slot. No numeric result is produced. The extra DATA reference is nonexecutable LINKEDIT metadata. Restore only undefined4 return to D2UnitStrc*, preserving the existing unit input, name, cdecl, stack slot and error path. Original Mac database bytes and complete caller bodies were independently decoded; Windows already has the same return contract. No shared field change, execution or matching gain claimed.

Changes 1, applied together

  1. Set prototype mac 0x00277d9a

    signatureundefined4 GetNextUnit(D2UnitStrc * pUnit)→D2UnitStrc * GetNextUnit(D2UnitStrc * pUnit)
    convention__cdecl