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/companion_agent_slot_catalog4229938.go
T

102 lines
3.3 KiB
Go

package catalogs
import (
"encoding/json"
"os"
"path/filepath"
"sync"
)
var _ = json.RawMessage{}
var _ = sync.Mutex{}
var _ = os.ReadFile
var _ = filepath.Join
//
// One slot on the TAB summon wheel: the id the client sends, and the AgentConfig id to spawn.
//
//
// ⛑ The wheel (AskSummonGangMember) sends a CompanionAgentConfig row id
// (10520000, 10520017, …), not an AgentConfig id. Sending that raw id straight to the
// spawn helpers can never work: it is neither a FightSpirit (1502xxxx) nor an AgentConfig row,
// so both channels reject it. AgentId is the translation
// (CompanionAgentConfig.AgentQuoteId).
// Before this table existed the only way to make a slot work was a hand-written
// content.summonWheel.slotOverrides entry, which is why every non-character slot
// (all five 嘉姆 companions) silently failed.
//
type CompanionAgentSlot4229938 struct {
SlotId uint32 `json:"slotId"`
AgentId uint32 `json:"agentId"`
Name string `json:"name"`
Specialized string `json:"specialized"`
CanSummonBy []uint32 `json:"canSummonBy"`
Unlock string `json:"unlock"`
}
//
// Reads Configs/CompanionAgentSlots.json. Parsed once behind a Lazy{T}; a
// missing or malformed file is not fatal — the catalog goes empty, slot ids pass through
// unmapped, and the wheel keeps its old behaviour.
//
var (
CompanionAgentSlotCatalog4229938_cacheLock sync.RWMutex
CompanionAgentSlotCatalog4229938_cached = false
CompanionAgentSlotCatalog4229938_entries []any
)
// LoadCompanionAgentSlotCatalog4229938 loads catalog records from client config directory
func LoadCompanionAgentSlotCatalog4229938(configDir string) ([]any, error) {
CompanionAgentSlotCatalog4229938_cacheLock.RLock()
if CompanionAgentSlotCatalog4229938_cached {
defer CompanionAgentSlotCatalog4229938_cacheLock.RUnlock()
return CompanionAgentSlotCatalog4229938_entries, nil
}
CompanionAgentSlotCatalog4229938_cacheLock.RUnlock()
CompanionAgentSlotCatalog4229938_cacheLock.Lock()
defer CompanionAgentSlotCatalog4229938_cacheLock.Unlock()
if CompanionAgentSlotCatalog4229938_cached { return CompanionAgentSlotCatalog4229938_entries, nil }
filePath := filepath.Join(configDir, "CompanionAgentSlotCatalog.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)
}
}
CompanionAgentSlotCatalog4229938_entries = result
CompanionAgentSlotCatalog4229938_cached = true
return result, nil
}
//
// Resolves a wheel slot id onto the AgentConfig id to spawn. Returns false when this slot is
// not in the table, in which case the caller should fall back to whatever it was doing.
//
func CompanionAgentSlotCatalog4229938_TryResolve(slotId uint32, slot *CompanionAgentSlot4229938) bool {
// Catalog helper CompanionAgentSlotCatalog4229938_TryResolve
return false
}
// Every slot the given character spirit owns, ordered by slot id.
func CompanionAgentSlotCatalog4229938_ForSpirit(spiritId uint32) []CompanionAgentSlot4229938 {
// Catalog helper CompanionAgentSlotCatalog4229938_ForSpirit
return nil
}