Files
Ananta-ps/internal/catalogs/uber_sim_catalog4229938.go

131 lines
4.0 KiB
Go

package catalogs
import (
"encoding/json"
"os"
"path/filepath"
"sync"
)
var _ = json.RawMessage{}
var _ = sync.Mutex{}
var _ = os.ReadFile
var _ = filepath.Join
// One UberSimRandomOrdersConfig row — a kind of delivery order.
type UberSimOrderTypeRow struct {
Id uint32 `json:"id"`
EventId uint32 `json:"eventId"`
}
// One UberSimRandomGoodsConfig row — what gets carried.
type UberSimCargoRow struct {
Id uint32 `json:"id"`
DisasterLevel int32 `json:"disasterLevel"`
UnlockStage uint32 `json:"unlockStage"`
}
//
// One authored order from UberSimOrderConfig — the scripted ones that carry a named NPC.
// Only the fields the order board can actually show are kept.
//
type UberSimScriptedOrderRow struct {
Id uint32 `json:"id"`
EventId uint32 `json:"eventId"`
RandomGoods uint32 `json:"randomGoods"`
Pickup uint32 `json:"pickup"`
Delivery uint32 `json:"delivery"`
DeliveryNpc uint32 `json:"deliveryNpc"`
Rude uint32 `json:"rude"`
Character uint32 `json:"character"`
Time int32 `json:"time"`
RewardPoint int32 `json:"rewardPoint"`
IsTeach bool `json:"isTeach"`
ProfileId uint32 `json:"profileId"`
}
//
// Reads the UberSim (= Cat Express / 蓝猫物流) authored tables out of the client-data directory.
// Why this file exists: the panels need rows that exist nowhere else. The client resolves cargo
// names from UberSimRandomGoodsConfig, area names from UberSimRandomOrdersConfig ->
// TaskEvent -> Raid, and the consignee portrait from UberSimOrderConfig.ProfileId — all
// client-side lookups keyed by ids we publish. The server therefore only has to combine ids that
// exist in these tables; inventing any of them produces rows whose labels are blank.
// Loaded lazily and never thrown: a missing table degrades to an empty board (with a logged
// reason) rather than taking the session down — same contract as TuiteCatalog4229938.
//
var (
UberSimCatalog4229938_cacheLock sync.RWMutex
UberSimCatalog4229938_cached = false
UberSimCatalog4229938_entries []any
)
// LoadUberSimCatalog4229938 loads catalog records from client config directory
func LoadUberSimCatalog4229938(configDir string) ([]any, error) {
UberSimCatalog4229938_cacheLock.RLock()
if UberSimCatalog4229938_cached {
defer UberSimCatalog4229938_cacheLock.RUnlock()
return UberSimCatalog4229938_entries, nil
}
UberSimCatalog4229938_cacheLock.RUnlock()
UberSimCatalog4229938_cacheLock.Lock()
defer UberSimCatalog4229938_cacheLock.Unlock()
if UberSimCatalog4229938_cached { return UberSimCatalog4229938_entries, nil }
filePath := filepath.Join(configDir, "UberSimCatalog.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)
}
}
UberSimCatalog4229938_entries = result
UberSimCatalog4229938_cached = true
return result, nil
}
func UberSimCatalog4229938_ReadRecords(root string, file string, missing []string) []any {
// Catalog helper UberSimCatalog4229938_ReadRecords
return nil
}
func UberSimCatalog4229938_U32(node any, name string) uint32 {
// Catalog helper UberSimCatalog4229938_U32
return 0
}
func UberSimCatalog4229938_Num(node any, name string, fallback int32) int32 {
// Catalog helper UberSimCatalog4229938_Num
return 0
}
type Cache struct {
OrderTypes []UberSimOrderTypeRow `json:"orderTypes"`
Cargos []UberSimCargoRow `json:"cargos"`
ScriptedOrders []UberSimScriptedOrderRow `json:"scriptedOrders"`
PickupIds []uint32 `json:"pickupIds"`
DeliveryIds []uint32 `json:"deliveryIds"`
CanReceiveRaid []uint32 `json:"canReceiveRaid"`
InitAcceptCount int32 `json:"initAcceptCount"`
TakeOrderRefreshTime int32 `json:"takeOrderRefreshTime"`
InitAcceptTime int32 `json:"initAcceptTime"`
InitOrdersCountIfTodayFirst int32 `json:"initOrdersCountIfTodayFirst"`
Error *string `json:"error"`
}