REDIVIVUS

Proposals / #1103

Type the tile lookup chain as D2TileLibraryEntryStrc pointers, including FindHTile's return

checked · by dtchitt · submitted 2026-11-03

The tile lookup passes tile library entries around as int. FINDTILE_Lookup stores entries from its hash chains into pResultArray (int32_t), TILEPROJECT_LookupTilesInAllProjects passes its int * pnFoundTiles on to it, and DRLG_FindHTile fills its int[40] aTileResults that way and returns one entry as int. Its callers cast the return to D2TileLibraryEntryStrc * at 8 of 11 sites. The entries are read as that struct: TILEPROJECT_GetAnimatedTileDataPtr returns nFrame_Rarity (00604c46 MOV EAX,[EAX+0x20]), which FindHTile sums as the rarity, and TILEPROJECT_GetTileCount returns nFlags (00604be6 MOVZX EAX,word ptr [EAX+6]); their call sites name the results nRarityEntry and nTileFlags. So all six become D2TileLibraryEntryStrc * (or ** or [40]). The two getters' names look wrong too (they return the rarity and the flags), which the tool can't change.

Changes 6, applied together

  1. Set prototype win 0x0066d820

    signatureint DRLG_FindHTile(D2RoomExStrc * pRoomEx, int nTileType, uint nGridFlags)→D2TileLibraryEntryStrc * DRLG_FindHTile(D2RoomExStrc * pRoomEx, int nTileType, uint nGridFlags)
    convention__fastcall
  2. Retype variable win 0x0066d820 Stack[-0xa4]

    typeundefined1[160]→D2TileLibraryEntryStrc *[40]
  3. Retype variable win 0x00604ae0 Stack[0x14]

    typeint *→D2TileLibraryEntryStrc * *
  4. Retype variable win 0x0060d040 EDX

    typeint32_t→D2TileLibraryEntryStrc * *
  5. Retype variable win 0x00604c20 Stack[0x4]

    typeint32_t→D2TileLibraryEntryStrc *
  6. Retype variable win 0x00604bc0 Stack[0x4]

    typeint32_t→D2TileLibraryEntryStrc *