REDIVIVUS

Proposals / #1702

Use signed operands for percentage scaling on Windows and Mac

checked · by eejitgames · submitted 2026-11-08

Windows D2ApplyPercent 00483360 declares its divisor uint32_t although every arithmetic path uses signed division: CDQ/IDIV or a CDQ-sign-extended divisor for the 64-bit path, plus signed comparisons. Mac MONSTER_ApplyDifficultyScaling 0017d635 inlines that calculation but explicitly types nDivisor, nPercent and its table cursor as unsigned. Its corresponding paths use SAR sign extension, signed branches and IDIV. Retype the Windows divisor and these three Mac locals as int32_t/int32_t*. The paired scaling functions process identical three-row, five-int tables with 20-byte strides; the Windows table is already int[3][5]. Preserve all widths, names and ABIs. The Mac table's scalar definitions/interior labels require a separate layout repair, documented in evidence; this proposal does not claim to complete that repair.

Changes 4, applied together

  1. Retype variable win 0x00483360 Stack[0x4]

    typeuint32_t→int32_t
  2. Retype variable mac 0x0017d635 EBX

    typeuint32_t *→int32_t *
  3. Retype variable mac 0x0017d635 HASH:5fe5d95415

    typeuint32_t→int32_t
  4. Retype variable mac 0x0017d635 HASH:5fb6c430de

    typeuint32_t→int32_t