update item owner

This commit is contained in:
vietdungdev
2026-05-24 22:37:32 +07:00
parent 41abbe5217
commit e8a41dc79c
3 changed files with 18 additions and 14 deletions

View File

@@ -13,7 +13,7 @@ import (
"github.com/hectorgimenez/d2go/pkg/utils"
)
func (gd *GameReader) Inventory(rawPlayerUnits RawPlayerUnits, merc OwnMercenary, hover data.HoverData) data.Inventory {
func (gd *GameReader) Inventory(rawPlayerUnits RawPlayerUnits, hover data.HoverData) data.Inventory {
mainPlayer := rawPlayerUnits.GetMainPlayer()
baseAddr := gd.Process.moduleBaseAddressPtr + gd.offset.UnitTable + (4 * 1024)
unitTableBuffer := gd.Process.ReadBytesFromMemory(baseAddr, 128*8)
@@ -55,7 +55,6 @@ func (gd *GameReader) Inventory(rawPlayerUnits RawPlayerUnits, merc OwnMercenary
StashedGold: stashedGold,
SharedStashPages: len(stashPlayerUnitOrder),
PlayerID: mainPlayer.UnitID,
MercID: merc.UnitID,
}
belt := data.Belt{}
@@ -268,15 +267,26 @@ func (gd *GameReader) Inventory(rawPlayerUnits RawPlayerUnits, merc OwnMercenary
if page, ok := stashUnitIDToPage[itemOwnerNPC]; ok {
location = item.LocationSharedStash
invPage = page
// In party mode / current memory layout:
// shared stash page 1 belongs to the current character.
// Other pages are other shared stash containers and should keep raw owner.
if page == 1 {
itm.Owner = mainPlayer.UnitID
}
} else if itemOwnerNPC == 2 && len(stashUnitIDToPage) == 0 {
location = item.LocationSharedStash
invPage = 1
itm.Owner = mainPlayer.UnitID
} else if itemOwnerNPC == 3 && len(stashUnitIDToPage) == 0 {
location = item.LocationSharedStash
invPage = 2
itm.Owner = mainPlayer.UnitID
} else if itemOwnerNPC == 4 && len(stashUnitIDToPage) == 0 {
location = item.LocationSharedStash
invPage = 3
itm.Owner = mainPlayer.UnitID
} else if itemOwnerNPC == 4294967295 {
if 0x00002000&flags != 0 {
location = item.LocationVendor