From 06f32937b60b46279f5a725ce5427dfd67a46630 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 13 Jun 2026 13:49:16 +0100 Subject: [PATCH] Remove legacy catalog enumeration bridges --- .voidbot/state/aetheria.cc | Bin 30488 -> 30926 bytes .../CultCache/LegacyCatalogCache.cs | 80 ------------------ Assets/Scripts/ServerShared/ItemManager.cs | 45 ---------- .../Scripts/ServerShared/LoadoutGenerator.cs | 4 +- docs/aetheria-perfect-machine-map.md | 22 +++-- 5 files changed, 17 insertions(+), 134 deletions(-) diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index bce3484d0b4ffbc1e79e800e5a9c1e449ed51ee1..df5e0f10d95a959e5439d77accf4b0a22b2fc442 100644 GIT binary patch delta 1544 zcmZux&u<$=6edmy#0Wu3L!dom%8!&H$FU=qI8B9G#c7nPDH1p>$_2)|&%0C4&a7r; zof-*+h$AO77mif?k}5!;{R2>i;J^WKs?>@L7cTq|J#gpE?%FtrlkMku?|tw4zV|-( zbK=MQ6JLE=DmPZnHtN;JN^ST3iCOzy>Ahj3SqU?Ly^>qCWbNqw1^3ZcR$Mqv{1p_2qe0|)P!tdWsfX)}ni)38B-sAB(qc7C$` za>X9JK6|vf3FZRl=kRx4FtqPnn%#GqO97W1$_W!b+yG7XK)F^N4ER;jcF-ZBOgL!# z@X#H_`~V2kBu+SA>>`TIovjvPm%St=U8#tHD3*$<0co{gA>qI;IFf=7s{5ZA5E?1F zd*?MQ&tcIe=RFu^j=k50ab6(NS!E`)p~z{*d4+VDF%F^^g4fd((t(in86xl`K2(Y4 z7|Vy3ykPWAva^K>a^9hsL!3gK3+z>_$P;Zipgt{^ljt#doBxq^G+##aSv!bv8$-Hix z-I--KbPF4FsD`Y=$aZp1;J_h^tGB4|5caFk)jvP5o}O5Eaq8-oZ5ktdPby#M>oD?^ z{;%@?nxycTYnmC-Ef;43s_%ZJpnJD&|2i|5ep{I-+n>(QE-#M}L4-sX3Z#UK5zi9ADh`xuqUrAtgT&?Ug9umj|yD91m$q_;+Y~jB<(2{8xk_K^&#N)k?U3a+x5qe z7B{r9y8E%A0s5ku&b@J`bSy2VSR7L&{ewO_Jw3{>zx19S-r!Zd!E<)4_s#H3uQrP_ fJ!R*)ETU&>`SJdOAB-Z|yL3CcJv|K7>%0E|bonqn delta 1208 zcmZ8h-)j_C6mAkNCeV@=tX2dMZ6H+4W;eU}DO9jAx&^CpZ)Gtak&ZoeJ+ z{qFEseSWFhsMH!WYgFj9|MdhM=9aoM7u40%n;|?aG}%FrK`A=4no&bjzMeDiBJx zQA5ClFj;lt&=*aM$uhNlTY;tpDos!`oBgx$b@rsWZ_|LlHVeA+vaEv^Juicjq6?AI z-ii_-aA{Hu>~za@J$s7<>!xzgqBLB|*H1pMqA_9A0!%{D?M|*Xr^|6yn*@enEEfVc zHAaGH2R2$5vkgwV%jeHfcVuapxEqpXQaS3~q*|qfMqDxhsw3%{d!Z8>IQ^XymK4gk zjMEVd5Yz_MlzH|N^cE=Z&7|-Ws(@mV)>QsrK_S#kQo*UTnCzDy@R|kU44efMD@WsK zOob=baMdx*Xh#y^g9vC8PUNhoOzxm>h{lNvOYsurgV$0r!DSoxP7b|X$N=;ssoZBW zh?PEvk@@eVs%~m~Ab5lg*vlpB?1m`P#zPXX6iWgNG;sEQgxN9@eY*%kL+4UASF?66f(Guid guid) where T : DatabaseEntry; - IEnumerable GetAll() where T : DatabaseEntry; } public class LegacyCatalogCache : ILegacyCatalogReader @@ -24,36 +21,15 @@ public class LegacyCatalogCache : ILegacyCatalogReader private List _backingStores = new List(); - private readonly Dictionary _typeStores = new Dictionary(); private readonly Dictionary _storeTypes = new Dictionary(); private readonly Dictionary _entries = new Dictionary(); - private readonly Dictionary _globals = new Dictionary(); - private readonly Dictionary> _types = new Dictionary>(); - - public IEnumerable AllEntries => _entries.Values; - - public LegacyCatalogCache() - { - foreach (var type in typeof(DatabaseEntry).GetAllChildClasses()) - { - _types[type] = new HashSet(); - - if (type.GetCustomAttribute() != null) - { - _globals[type] = null; - AddInternal(Activator.CreateInstance(type) as DatabaseEntry); - } - } - } - public void AddBackingStore(CacheBackingStore store, params Type[] domain) { if (domain.Length > 0) { _storeTypes[store] = domain; - foreach (var t in domain) _typeStores[t] = store; } else { @@ -77,34 +53,11 @@ public class LegacyCatalogCache : ILegacyCatalogReader { if (entry != null) { - var exists = _entries.ContainsKey(entry.ID); - - var type = entry.GetType(); - - if (_globals.ContainsKey(type)) - { - if(_globals[type]!=null) - { - RemoveInternal(_globals[type]); - exists = true; - } - _globals[type] = entry; - } - _entries[entry.ID] = entry; - _types[type].Add(entry); - foreach (var parentType in type.GetParentTypes()) - { - if(_types.ContainsKey(parentType)) - _types[parentType].Add(entry); - } - } } } - public bool IsGlobal(DatabaseEntry entry) => _globals.ContainsKey(entry.GetType()); - public DatabaseEntry Get(Guid guid) { DatabaseEntry entry; @@ -116,39 +69,6 @@ public class LegacyCatalogCache : ILegacyCatalogReader { return Get(guid) as T; } - - public DatabaseEntry GetGlobal(Type type) - { - if (_globals.ContainsKey(type)) return _globals[type]; - return null; - } - - public T GetGlobal() where T : DatabaseEntry - { - return GetGlobal(typeof(T)) as T; - } - - public IEnumerable GetAll(Type type) - { - return !_types.ContainsKey(type) ? Enumerable.Empty() : _types[type]; - } - - public IEnumerable GetAll() where T : DatabaseEntry - { - var type = typeof(T); - return !_types.ContainsKey(type) ? Enumerable.Empty() : _types[type].Cast(); - } - - private void RemoveInternal(DatabaseEntry entry) - { - _entries.Remove(entry.ID); - var type = entry.GetType(); - foreach (var parentType in type.GetParentTypes()) - { - if(_types.ContainsKey(parentType)) - _types[parentType].Remove(entry); - } - } } public abstract class CacheBackingStore diff --git a/Assets/Scripts/ServerShared/ItemManager.cs b/Assets/Scripts/ServerShared/ItemManager.cs index 9533506a5..085b878bb 100644 --- a/Assets/Scripts/ServerShared/ItemManager.cs +++ b/Assets/Scripts/ServerShared/ItemManager.cs @@ -30,7 +30,6 @@ public class ItemManager // private Guid _forceLoadZone; - // public GlobalData GlobalData => _globalData ?? (_globalData = GetCatalogEntries().FirstOrDefault()); private readonly ILegacyCatalogReader _itemData; public GameplaySettings GameplaySettings { get; } @@ -59,55 +58,11 @@ public class ItemManager return _itemData.Get(id); } - public IEnumerable GetCatalogEntries() where T : DatabaseEntry - { - return _itemData.GetAll(); - } - public void Log(string s) { _logger(s); } - // public void Update() - // { - // foreach(var zone in _zones.Values) - // zone.Update((float) Time, _deltaTime); - // - // foreach (var corporation in Cache.GetAll()) - // { - // foreach (var tasks in corporation.Tasks - // .Select(id => Cache.Get(id)) // Fetch the tasks from the database cache - // .Where(task => !task.Reserved) // Filter out tasks that have already been reserved - // .GroupBy(task => task.Type)) // Group tasks by type - // { - // // Create a list of available controllers for this task type - // var availableControllers = CorporationControllers[corporation.ID] - // .Where(controller => controller.Available && controller.TaskType == tasks.Key).ToList(); - // - // // Iterate over the highest priority tasks for which controllers are available - // foreach (var task in tasks.OrderByDescending(task => task.Priority).Take(availableControllers.Count)) - // { - // // Find the nearest controller for this task - // IController nearestController = availableControllers[0]; - // List nearestControllerPath = FindPath(GalaxyZones[availableControllers.First().Zone.Data.ID], GalaxyZones[task.Zone], true); - // foreach (var controller in availableControllers.Skip(1)) - // { - // var path = FindPath(GalaxyZones[controller.Zone.Data.ID], GalaxyZones[task.Zone], true); - // if (path.Count < nearestControllerPath.Count) - // { - // nearestControllerPath = path; - // nearestController = controller; - // } - // } - // task.Reserved = true; - // nearestController.AssignTask(task.ID); - // } - // } - // } - // - // } - // public int ItemTier(CraftedItemData itemData) // { // if (Tier.ContainsKey(itemData)) return Tier[itemData]; diff --git a/Assets/Scripts/ServerShared/LoadoutGenerator.cs b/Assets/Scripts/ServerShared/LoadoutGenerator.cs index 7e94a720f..ad6be07dd 100644 --- a/Assets/Scripts/ServerShared/LoadoutGenerator.cs +++ b/Assets/Scripts/ServerShared/LoadoutGenerator.cs @@ -167,12 +167,12 @@ public class LoadoutGenerator if (requestedType == typeof(GearData)) { - return item.Category is "GearData" or "WeaponItemData"; + return item.Category == "GearData" || item.Category == "WeaponItemData"; } if (requestedType == typeof(CargoBayData)) { - return item.Category is "CargoBayData" or "DockingBayData"; + return item.Category == "CargoBayData" || item.Category == "DockingBayData"; } return string.Equals(item.Category, requestedType.Name, StringComparison.Ordinal); diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index 7f55fd063..05c5b760a 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -79,14 +79,16 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. `ILegacyCatalogReader`, so old MessagePack backing stores may hydrate in-memory domain objects for the current Unity runtime, but this path cannot push or delete legacy files. The legacy backing-store - write/realtime APIs and public cache mutation methods have been deleted; only - backing-store pull hydration can populate it. The backing-store serializer - methods are also deleted, so the legacy cache implementation exposes - deserialization only. UI code no longer reaches into + write/realtime APIs, public cache mutation methods, enumeration methods, and + global-setting lookup methods have been deleted; only backing-store pull + hydration can populate it, and only single-ID reads can consume it. The + backing-store serializer methods are also deleted, so the legacy cache + implementation exposes deserialization only. UI code no longer reaches into `LegacyCatalogBoundary.GetCatalog` directly. - `ItemManager` no longer exposes the raw `ILegacyCatalogReader` as public - gameplay/UI API. Temporary item instantiation bridges now go through narrow - `ItemManager.GetCatalogEntry` methods. This does not remove the legacy reader under + gameplay/UI API. Temporary item instantiation bridges now go through the + narrow `ItemManager.GetCatalogEntry` method. `ItemManager` no longer + exposes a legacy catalog enumeration API. This does not remove the legacy reader under the hood; it prevents old catalog authority from leaking into every caller that only needs a domain lookup. The item properties UI no longer uses `ItemManager` for manufacturer display; it resolves the manufacturer through @@ -267,7 +269,8 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. it still materializes `ItemManager`. Item properties manufacturer display is a typed snapshot consumer; the give console command, loadout generation, and trade debug are typed-selection consumers with temporary legacy item - instantiation or UI callback hydration. + instantiation or UI callback hydration. No live caller can enumerate legacy + catalog entries through `ItemManager` or `ILegacyCatalogReader`. - Inputs: Unity gameplay code, legacy catalog files, typed state documents, and CultMesh server state. - Outputs: `Aetheria.State` emits `.cc` state and CultMesh documents. Legacy @@ -427,6 +430,11 @@ First Aetheria surfaces to publish: checks and behavior construction. - Done: move `TradeMenuDebug` row selection to the typed trade catalog; legacy item DTO hydration remains only for old inspect/buy callbacks. + - Done: delete `ItemManager.GetCatalogEntries` after all live callers + moved to typed catalog selection. + - Done: delete `ILegacyCatalogReader.GetAll` and the type/global indexes + inside `LegacyCatalogCache`; the legacy cache is now only a pull-fed GUID + lookup bridge. - Replace `ActionGameManager` cache bootstrap with the new state runtime. - Convert domain references from GUID/base-class patterns to typed record refs.