REDIVIVUS

Proposals / #1092

ClickItemRight's two register parameters are the mouse Y and X, not an item and an inventory

checked · by dtchitt · submitted 2026-11-03

ClickItemRight types ECX as D2UnitStrc * pItem and EDX as D2InventoryStrc * pGridCoords, but neither is ever dereferenced. They are only screen coordinates: ECX is copied to ESI (0048774b) and EDX to EDI (0048774d), then EDI minus the grid's nPixelLeft is divided by nCellWidth (0048776d MOV EAX,EDI; 0048776f SUB EAX,[0x7bcb8c]; 00487777 DIV ECX), and ESI minus nTop gives the row (0048777b MOV EAX,ESI; 0048777d SUB EAX,[0x7bcb94]). The same is repeated for the two bank grids. Both callers pass the mouse position: the generated source reads ClickItemRight((D2UnitStrc*)nMouseY, (D2InventoryStrc*)nMouseX, ...). This retypes both to int32_t. Their names are wrong too (nMouseY, nMouseX), but the tool will not rename chosen names, so that is left to review.

Changes 2, applied together

  1. Retype variable win 0x00487740 ECX

    typeD2UnitStrc *→int32_t
  2. Retype variable win 0x00487740 EDX

    typeD2InventoryStrc *→int32_t