From 50eb39853cd70c5b4163e73336022ee023e6b2e4 Mon Sep 17 00:00:00 2001 From: guiyomu-dev <22749537+guiyomu-dev@users.noreply.github.com> Date: Sat, 14 Feb 2026 23:59:20 +0100 Subject: [PATCH] remove unecessary code due to bad game update --- cmd/gennames/main.go | 24 +----------------------- pkg/data/item/name.go | 30 ++++++------------------------ pkg/data/items.go | 12 +----------- pkg/memory/game_reader.go | 1 - pkg/memory/item.go | 2 +- pkg/memory/player.go | 1 - pkg/nip/rule.go | 9 ++------- 7 files changed, 11 insertions(+), 68 deletions(-) diff --git a/cmd/gennames/main.go b/cmd/gennames/main.go index fca0ece..fdd6d25 100644 --- a/cmd/gennames/main.go +++ b/cmd/gennames/main.go @@ -106,17 +106,6 @@ func run() error { import "strings" -const ( - ExpCharItemIDThreshold = 508 - ExpCharItemIDOffset = 15 -) - -var ExpChar uint16 - -func SetExpChar(expChar uint16) { - ExpChar = expChar -} - const ( ScrollOfTownPortal = "ScrollOfTownPortal" ScrollOfIdentify = "ScrollOfIdentify" @@ -126,22 +115,12 @@ const ( ) func GetNameByEnum(itemNumber uint) Name { - idx := int(itemNumber) - if ExpChar >= 3 && idx >= ExpCharItemIDThreshold { - idx += ExpCharItemIDOffset - } - if idx < 0 || idx >= len(Names) { - return Name("") - } - return Name(Names[idx]) + return Name(Names[itemNumber]) } func GetIDByName(itemName string) int { for i, name := range Names { if strings.EqualFold(name, itemName) { - if ExpChar >= 3 && i >= ExpCharItemIDThreshold+ExpCharItemIDOffset { - return i - ExpCharItemIDOffset - } return i } } @@ -151,7 +130,6 @@ func GetIDByName(itemName string) int { type Name string - var Names = []string{ `) for _, n := range names { diff --git a/pkg/data/item/name.go b/pkg/data/item/name.go index 278a3e9..8dc00b8 100644 --- a/pkg/data/item/name.go +++ b/pkg/data/item/name.go @@ -1,15 +1,6 @@ package item -import ( - "strings" - - "github.com/hectorgimenez/d2go/pkg/data/game" -) - -const ( - ExpCharItemIDThreshold = 508 - ExpCharItemIDOffset = 15 -) +import "strings" const ( ScrollOfTownPortal = "ScrollOfTownPortal" @@ -19,27 +10,18 @@ const ( Key = "Key" ) -func GetNameByEnumWithExpChar(expChar uint16, itemNumber uint) Name { - idx := int(itemNumber) - if expChar >= game.CharDLC && idx >= ExpCharItemIDThreshold { - idx += ExpCharItemIDOffset - } - if idx < 0 || idx >= len(Names) { - return Name("") - } - return Name(Names[idx]) +func GetNameByEnum(itemNumber uint) Name { + return Name(Names[itemNumber]) } -// DescIDByName returns the internal description/index ID for an item name. -// This ID matches the keys used by Desc and the indices in the Names slice. -func DescIDByName(itemName string) (int, bool) { +func GetIDByName(itemName string) int { for i, name := range Names { if strings.EqualFold(name, itemName) { - return i, true + return i } } - return -1, false + return -1 } type Name string diff --git a/pkg/data/items.go b/pkg/data/items.go index 374f0ca..ebc5265 100644 --- a/pkg/data/items.go +++ b/pkg/data/items.go @@ -121,17 +121,7 @@ type Drop struct { } func (i Item) Desc() item.Description { - if descID, ok := item.DescIDByName(string(i.Name)); ok { - if desc, found := item.Desc[descID]; found { - return desc - } - } - - if desc, found := item.Desc[i.ID]; found { - return desc - } - - return item.Description{} + return item.Desc[i.ID] } func (i Item) Type() item.Type { diff --git a/pkg/memory/game_reader.go b/pkg/memory/game_reader.go index e8b720a..0e65efb 100644 --- a/pkg/memory/game_reader.go +++ b/pkg/memory/game_reader.go @@ -20,7 +20,6 @@ type GameReader struct { monstersLastUpdate time.Time inventoryLastUpdate time.Time objectsLastUpdate time.Time - ExpChar uint16 cachedMonsters data.Monsters cachedInventory data.Inventory diff --git a/pkg/memory/item.go b/pkg/memory/item.go index bc86c5b..6f833e0 100644 --- a/pkg/memory/item.go +++ b/pkg/memory/item.go @@ -131,7 +131,7 @@ func (gd *GameReader) Inventory(rawPlayerUnits RawPlayerUnits, hover data.HoverD itm := &data.Item{ ID: int(txtFileNo), UnitID: data.UnitID(unitID), - Name: item.GetNameByEnumWithExpChar(gd.ExpChar, txtFileNo), + Name: item.GetNameByEnum(txtFileNo), Quality: item.Quality(itemQuality), Position: data.Position{ X: int(itemX), diff --git a/pkg/memory/player.go b/pkg/memory/player.go index c187b4d..9d1204a 100644 --- a/pkg/memory/player.go +++ b/pkg/memory/player.go @@ -39,7 +39,6 @@ func (gd *GameReader) GetRawPlayerUnits() RawPlayerUnits { expCharPtr := uintptr(gd.Process.ReadUInt(gd.moduleBaseAddressPtr+gd.offset.Expansion, Uint64)) expChar := gd.Process.ReadUInt(expCharPtr+0x5C, Uint16) - gd.ExpChar = uint16(expChar) isMainPlayer := gd.Process.ReadUInt(inventoryAddr+0x30, Uint16) if expChar >= uint(game.CharLoD) { isMainPlayer = gd.Process.ReadUInt(inventoryAddr+0x70, Uint16) diff --git a/pkg/nip/rule.go b/pkg/nip/rule.go index ff8a1e4..0ec5de8 100644 --- a/pkg/nip/rule.go +++ b/pkg/nip/rule.go @@ -250,11 +250,7 @@ func (r Rule) Evaluate(it data.Item) (RuleResult, error) { case "class": stage1Props["class"] = int(it.Desc().Tier()) case "name": - if descID, ok := item.DescIDByName(string(it.Name)); ok { - stage1Props["name"] = descID - } else { - stage1Props["name"] = it.ID - } + stage1Props["name"] = it.ID case "flag": // 0x400000 (eth) | 0x4000000 (runeword) kolbot style currentFlag := 0 @@ -491,8 +487,7 @@ func replaceStringPropertiesInStage1(stage1 string) (string, error) { case "class": replaceWith = strings.ReplaceAll(prop[0], prop[4], fmt.Sprintf("%d", classAliases[prop[4]])) case "name": - descID, _ := item.DescIDByName(prop[4]) - replaceWith = strings.ReplaceAll(prop[0], prop[4], fmt.Sprintf("%d", descID)) + replaceWith = strings.ReplaceAll(prop[0], prop[4], fmt.Sprintf("%d", item.GetIDByName(prop[4]))) case "flag": val := 0 switch strings.ToLower(prop[4]) {