REDIVIVUS

Proposals / #1160

Mac MONSTERAI_FindSwitchAiTarget: BOOL __fastcc (pGame, pUnit, pSwitchParam, bRequireLOS, ppOutUnit, pOutDistance)

approved · by KierTaylor · submitted 2026-11-05, approved 2026-11-05

Mac 0x001a63fa is "undefined (void)", convention unknown. Entry: EBX=ECX (game: FindUnitFromTable/ForEach arg 1), EDI=EDX (unit: NULL and [EDI]==1 monster checks, AI_GetSwitchAiParam1/2). Stack: [EBP+8] secondary unit (stored as the LOS/secondary unit in the ForEach params), [EBP+0xc] LOS flag (tested before TestCollisionWithUnit), [EBP+0x10] out unit ptr, [EBP+0x14] out distance ptr; returns 0/1; plain RET. Caller MONSTERAI_FindBestTarget loads ECX=[EBP+8] (pGame), EDX=EDI (unit), stores [ESP], [ESP+4]=0, [ESP+8]=LEA local, [ESP+0xc], then TEST EAX,EAX (0x001a5e97-0x001a5ec3). Windows twin 0x005dd610 has the same six values: BOOL (D2UnitStrc* pSwitchParam, int32_t bRequireLOS, D2UnitStrc** ppOutUnit, int* pOutDistance, pGame, pUnit).

Changes 1, applied together

  1. Set prototype mac 0x001a63fa

    signatureundefined MONSTERAI_FindSwitchAiTarget(void)→BOOL MONSTERAI_FindSwitchAiTarget(D2GameStrc * pGame, D2UnitStrc * pUnit, D2UnitStrc * pSwitchParam, int32_t bRequireLOS, D2UnitStrc * * ppOutUnit, int * pOutDistance)
    conventionunknown→__fastcc