Skip to content
This repository has been archived by the owner on Dec 21, 2022. It is now read-only.

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
joffreybesos committed May 22, 2022
1 parent 1edac38 commit e82b0a9
Show file tree
Hide file tree
Showing 5 changed files with 171 additions and 44 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ All notable changes to this project will be documented in this file.
## [2.9.0] - 2021-05-22 - Bug fixes

- Fixed issue where UI would flash up while in menus/inventory
- Fixed issue where scrolls/keys in personal stash would be counted

- Fixed issue where scrolls/keys were incorrectly counted
- Moved item log text down a little (thanks @updawg)
- Fixed quality translation for zhTW (thanks @ckhoho)

## [2.8.9] - 2021-05-20 - Number of scrolls/keys in inventory shows on right

Expand Down
2 changes: 1 addition & 1 deletion src/d2r-map.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ While 1 {
, frameCount := 0
, fpsTimer := A_TickCount
if (isInGame) {
readInvItems(d2rprocess, offsets["unitTable"], HUDItems)
readInvItems(d2rprocess, offsets["unitTable"], HUDItems, gameMemoryData["unitId"])
itemCounterLayer.drawItemCounter(HUDItems)
gameInfoLayer.drawInfoText(currentFPS)
partyInfoLayer.drawInfoText(gameMemoryData["partyList"], gameMemoryData["unitId"])
Expand Down
Binary file modified src/localization.ini
Binary file not shown.
202 changes: 164 additions & 38 deletions src/memory/readInvItems.ahk
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@

ReadInvItems(ByRef d2rprocess, startingOffset, ByRef HUDItems) {
ReadInvItems(ByRef d2rprocess, startingOffset, ByRef HUDItems, ByRef unitId) {

HUDItems := { idscrolls : 0, tpscrolls : 0, keys : 0 }

; items
SetFormat Integer, D
items := []
, baseAddress := d2rprocess.BaseAddress + startingOffset + (4 * 1024)
baseAddress := d2rprocess.BaseAddress + startingOffset + (4 * 1024)
, d2rprocess.readRaw(baseAddress, unitTableBuffer, 128*8)
Loop, 128
{
Expand All @@ -25,44 +24,58 @@ ReadInvItems(ByRef d2rprocess, startingOffset, ByRef HUDItems) {
pUnitDataPtr := NumGet(&itemStructData , 0x10, "Int64")
d2rprocess.readRaw(pUnitDataPtr, pUnitData, 80)
; check if in vendor store
, dwOwnerId := NumGet(&pUnitData, 0x0C, "UInt")
, flags := NumGet(&pUnitData, 0x18, "UInt")
if (!(0x00002000 & flags)) {

; get quanitity
pStatsListExPtr := NumGet(&itemStructData , 0x88, "Int64")
, d2rprocess.readRaw(pStatsListExPtr, pStatsListEx, 144)
, statPtr := NumGet(&pStatsListEx , 0x30, "Int64")
, statCount := NumGet(&pStatsListEx , 0x38, "Int64")
, d2rprocess.readRaw(statPtr + 0x2, statBuffer, statCount*8)

; get quantity
, statList := ""
, quantity := 1
Loop, %statCount%
{
offset := (A_Index -1) * 8
statEnum := NumGet(&statBuffer, offset, Type := "UShort")
statValue := NumGet(&statBuffer , offset + 0x2, Type := "UInt")
switch (statEnum) {
case 70: quantity := statValue
;, invPage := NumGet(&pUnitData, 0x55, "UChar")
invPage := d2rprocess.read(pUnitDataPtr + 0x55, "UChar")
, itemQuality := NumGet(&pUnitData, 0x00, "UInt")
, uniqueOrSetId := NumGet(&pUnitData, 0x34, "UInt")
, flags := NumGet(&pUnitData, 0x18, "UInt")
; , pPathPtr := NumGet(&itemStructData , 0x38, "Int64")
; , d2rprocess.readRaw(pPathPtr, pPath, 144)
; , itemx := NumGet(&pPath , 0x10, "UShort")
; , itemy := NumGet(&pPath , 0x14, "UShort")
flagText := getFlags(flags)
if (unitId == dwOwnerId and invPage == 0) {
if (!(0x00002000 & flags)) {

; get quanitity
pStatsListExPtr := NumGet(&itemStructData , 0x88, "Int64")
, d2rprocess.readRaw(pStatsListExPtr, pStatsListEx, 144)
, statPtr := NumGet(&pStatsListEx , 0x30, "Int64")
, statCount := NumGet(&pStatsListEx , 0x38, "Int64")
, d2rprocess.readRaw(statPtr + 0x2, statBuffer, statCount*8)

; get quantity
, statList := ""
, quantity := 1
Loop, %statCount%
{
offset := (A_Index -1) * 8
statEnum := NumGet(&statBuffer, offset, Type := "UShort")
statValue := NumGet(&statBuffer , offset + 0x2, Type := "UInt")
switch (statEnum) {
case 70: quantity := statValue
}
; OutputDebug, % txtFileNo " " statEnum " " statValue
}
}
; OutputDebug, % quantity " keys found"
; OutputDebug, % quantity " keys found"
; 543 is key
; 529 is TP scroll
; 530 is ID scroll
; 518 is tome of TP
; 519 is tome of ID
if (txtFileNo == 543) {
HUDItems.keys := HUDItems.keys + quantity
} else if (txtFileNo == 529) {
HUDItems.tpscrolls := HUDItems.tpscrolls + quantity
} else if (txtFileNo == 530) {
HUDItems.idscrolls := HUDItems.idscrolls + quantity
} else if (txtFileNo == 518) {
HUDItems.tpscrolls := HUDItems.tpscrolls + quantity
} else if (txtFileNo == 519) {
HUDItems.idscrolls := HUDItems.idscrolls + quantity
; 529 is TP scroll
; 530 is ID scroll
; 518 is tome of TP
; 519 is tome of ID
if (txtFileNo == 543) {
HUDItems.keys := HUDItems.keys + quantity
} else if (txtFileNo == 529) {
HUDItems.tpscrolls := HUDItems.tpscrolls + quantity
} else if (txtFileNo == 530) {
HUDItems.idscrolls := HUDItems.idscrolls + quantity
} else if (txtFileNo == 518) {
HUDItems.tpscrolls := HUDItems.tpscrolls + quantity
} else if (txtFileNo == 519) {
HUDItems.idscrolls := HUDItems.idscrolls + quantity
}
}
}
}
Expand Down Expand Up @@ -90,4 +103,117 @@ ItemToTrack(txtFileNo) {
case 519: return true
}
return false
}


getFlags(flags) {
flagsList := []
SetFormat Integer, H
hexFlags := flags + 0
SetFormat Integer, D

if (0x00000001 & flags) { ; IFLAG_TARGET
flagsList.push("IN PERSONAL STASH")
}
if (0x00000002 & flags) { ; IFLAG_TARGET
flagsList.push("IFLAG_TARGET")
}
if (0x00000004 & flags) { ; IFLAG_TARGETING
flagsList.push("IFLAG_TARGETING")
}
if (0x00000008 & flags) { ; IFLAG_TARGET
flagsList.push("IFLAG_TARGET")
}
if (0x00000010 & flags) { ; IFLAG_IDENTIFIED
flagsList.push("IFLAG_IDENTIFIED")
}
if (0x00000020 & flags) { ; IFLAG_QUANTITY
flagsList.push("IFLAG_QUANTITY")
}
if (0x00000040 & flags) { ; IFLAG_SWITCHIN
flagsList.push("IFLAG_SWITCHIN")
}
if (0x00000080 & flags) { ; IFLAG_SWITCHOUT
flagsList.push("IFLAG_SWITCHOUT")
}
if (0x00000100 & flags) { ; IFLAG_BROKEN
flagsList.push("IFLAG_BROKEN")
}
if (0x00000200 & flags) { ; IFLAG_REPAIRED
flagsList.push("IFLAG_REPAIRED")
}
if (0x00000400 & flags) { ; IFLAG_UNK1
flagsList.push("IFLAG_UNK1")
}
if (0x00000800 & flags) { ; IFLAG_SOCKETED
flagsList.push("IFLAG_SOCKETED")
}
if (0x00001000 & flags) { ; IFLAG_NOSELL
flagsList.push("IFLAG_NOSELL")
}
if (0x00002000 & flags) { ; IFLAG_INSTORE
flagsList.push("IFLAG_INSTORE")
}
if (0x00004000 & flags) { ; IFLAG_NOEQUIP
flagsList.push("IFLAG_NOEQUIP")
}
if (0x00008000 & flags) { ; IFLAG_NAMED
flagsList.push("IFLAG_NAMED")
}
if (0x00010000 & flags) { ; IFLAG_ISEAR
flagsList.push("IFLAG_ISEAR")
}
if (0x00020000 & flags) { ; IFLAG_STARTITEM
flagsList.push("IFLAG_STARTITEM")
}
if (0x00040000 & flags) { ; IFLAG_STARTITEM
flagsList.push("0x00040000")
}
if (0x00080000 & flags) { ; IFLAG_INIT
flagsList.push("IFLAG_INIT")
}
if (0x00100000 & flags) { ; IFLAG_ETHEREAL
flagsList.push("0x00100000")
}
if (0x00200000 & flags) { ; IFLAG_ETHEREAL
flagsList.push("0x00200000")
}
if (0x00400000 & flags) { ; IFLAG_ETHEREAL
flagsList.push("0x00400000")
}
if (0x00800000 & flags) { ; IFLAG_ETHEREAL
flagsList.push("0x00800000")
}
if (0x01000000 & flags) { ; IFLAG_PERSONALIZED
flagsList.push("IFLAG_PERSONALIZED")
}
if (0x02000000 & flags) { ; IFLAG_LOWQUALITY
flagsList.push("IFLAG_LOWQUALITY")
}
if (0x04000000 & flags) { ; IFLAG_RUNEWORD
flagsList.push("IFLAG_RUNEWORD")
}
if (0x08000000 & flags) { ; IFLAG_ITEM
flagsList.push("IFLAG_ITEM")
}


if (0x10000000 & flags) { ; IFLAG_ITEM
flagsList.push("0x10000000")
}
if (0x20000000 & flags) { ; IFLAG_ITEM
flagsList.push("0x20000000")
}
if (0x40000000 & flags) { ; IFLAG_ITEM
flagsList.push("0x40000000")
}
if (0x80000000 & flags) { ; IFLAG_ITEM
flagsList.push("0x80000000")
}

sep := ","
for index,param in flagsList
str .= sep . param
flagsText := SubStr(str, StrLen(sep)+1)
return flagsList
}
6 changes: 3 additions & 3 deletions src/ui/gdip/ItemLogLayer.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ class ItemLogLayer {

if ((gameWindowWidth / gameWindowHeight) > 2) { ;if ultrawide
this.leftMargin := gameWindowX + 5 ; padding
this.topMargin := gameWindowY + (gameWindowHeight / 12)
this.topMargin := gameWindowY + (gameWindowHeight / 10)
} else {
this.leftMargin := gameWindowX + (gameWindowHeight / 10) + 5
this.topMargin := gameWindowY + (gameWindowHeight / 12)
this.topMargin := gameWindowY + (gameWindowHeight / 10)
}

this.itemLogFontSize := settings["itemLogFontSize"]
this.textBoxWidth := 450
this.textBoxWidth := 500
this.textBoxHeight := this.itemLogFontSize * 10
this.xoffset := 0
this.yoffset := 0
Expand Down

0 comments on commit e82b0a9

Please sign in to comment.