This repository has been archived on 2026-10-31. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Ananta-ps/internal/catalogs/item_catalog4229938.go
T

82 lines
2.2 KiB
Go

package catalogs
import (
"encoding/json"
"os"
"path/filepath"
"sync"
)
var _ = json.RawMessage{}
var _ = sync.Mutex{}
var _ = os.ReadFile
var _ = filepath.Join
// One grantable item row surfaced by the 道具 panel section.
type ItemCatalogEntry4229938 struct {
Id uint32 `json:"id"`
Name string `json:"name"`
Quality uint32 `json:"quality"`
SubType uint32 `json:"subType"`
}
//
// Build-4229938 backpack item catalog, read from ItemCatalog.json in the configured client-data
// directory.
// That file is a slim projection of the client's ConsumableConfig.json — the only table in the
// config dump whose rows carry the LT.ConfigGen.ICommonItemConfig interface fields, i.e.
// the real backpack item table (Id / Name / Quality / SubType). Ids live in 36000000..36999999,
// which also contains the three wallet currencies (36920001/2/3); callers that grant "everything"
// must skip those so the wallet and the backpack do not disagree.
//
var (
ItemCatalog4229938_cacheLock sync.RWMutex
ItemCatalog4229938_cached = false
ItemCatalog4229938_entries []any
)
// LoadItemCatalog4229938 loads catalog records from client config directory
func LoadItemCatalog4229938(configDir string) ([]any, error) {
ItemCatalog4229938_cacheLock.RLock()
if ItemCatalog4229938_cached {
defer ItemCatalog4229938_cacheLock.RUnlock()
return ItemCatalog4229938_entries, nil
}
ItemCatalog4229938_cacheLock.RUnlock()
ItemCatalog4229938_cacheLock.Lock()
defer ItemCatalog4229938_cacheLock.Unlock()
if ItemCatalog4229938_cached { return ItemCatalog4229938_entries, nil }
filePath := filepath.Join(configDir, "ItemCatalog.json.json")
data, err := os.ReadFile(filePath)
if err != nil {
return nil, err
}
var raw struct {
Records []json.RawMessage `json:"records"`
}
if err := json.Unmarshal(data, &raw); err != nil {
return nil, err
}
var result []any
for _, item := range raw.Records {
var m map[string]any
if err := json.Unmarshal(item, &m); err == nil {
result = append(result, m)
}
}
ItemCatalog4229938_entries = result
ItemCatalog4229938_cached = true
return result, nil
}
func ItemCatalog4229938_Find(id uint32) *ItemCatalogEntry4229938 {
// Catalog helper ItemCatalog4229938_Find
return nil
}