remove unecessary code due to bad game update

This commit is contained in:
guiyomu-dev
2026-02-14 23:59:20 +01:00
parent eb0948dbea
commit 50eb39853c
7 changed files with 11 additions and 68 deletions

View File

@@ -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 {

View File

@@ -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

View File

@@ -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 {

View File

@@ -20,7 +20,6 @@ type GameReader struct {
monstersLastUpdate time.Time
inventoryLastUpdate time.Time
objectsLastUpdate time.Time
ExpChar uint16
cachedMonsters data.Monsters
cachedInventory data.Inventory

View File

@@ -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),

View File

@@ -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)

View File

@@ -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]) {