REDIVIVUS

Proposals / #994

NET_D2GS_SERVER_Send_0x15_WarpXY's nUnitType is an int: callers push the unit's whole type dword

approved · by Niehztog · submitted 2026-11-02, approved 2026-11-02

nUnitType (Stack[0x4]) is declared uint8_t, but the callers push the unit's type as a full dword read from offset 0: PacketUpdateForClient 0059829c MOV EDX,dword ptr [ESI] / 005982a3 PUSH EDX (call 005982a8); CLIENT_PlacePlayerInRoom 0053959e MOV ECX,dword ptr [ESI] / 005395a8 PUSH ECX (call 005395ad). With a byte parameter VC8 narrows the argument at each call (MOVZX), so the parameter was an int; storing only its low byte into the packet is what VC8 makes of an int stored into a byte field. Recompiled with VC8 SP1 (oracle, tree 3dba660), PacketUpdateForClient goes from 0.675 to 0.714; no function lost.

Changes 1, applied together

  1. Set prototype win 0x0053bc10

    signaturevoid NET_D2GS_SERVER_Send_0x15_WarpXY(D2ClientStrc * pClient, uint8_t nPacketId, uint8_t nUnitType, uint32_t nUnitGUID, uint16_t wX, uint16_t wY, uint8_t bWarpFade)→void NET_D2GS_SERVER_Send_0x15_WarpXY(D2ClientStrc * pClient, uint8_t nPacketId, int nUnitType, uint32_t nUnitGUID, uint16_t wX, uint16_t wY, uint8_t bWarpFade)
    convention__fastcall