From d15db80188da5d6c337af8bf95eca8e1f5f8ca3c Mon Sep 17 00:00:00 2001 From: Hipposgrumm Date: Thu, 23 Oct 2025 20:37:58 -0600 Subject: [PATCH] Moved party data into XmlDataService Also fixed an oversight that caused the first party listed for a game to not be added to the data. --- src/Controllers/Common/ContentController.cs | 7 ++---- src/Program.cs | 1 - src/Resources/parties_info.xml | 1 - src/Services/XmlDataService.cs | 27 +++++++++++++++++++++ 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/Controllers/Common/ContentController.cs b/src/Controllers/Common/ContentController.cs index 8809f34..2f364e3 100644 --- a/src/Controllers/Common/ContentController.cs +++ b/src/Controllers/Common/ContentController.cs @@ -18,7 +18,6 @@ public class ContentController : Controller { private MissionStoreSingleton missionStore; private MissionService missionService; private RoomService roomService; - private PartyService partyService; private AchievementService achievementService; private InventoryService inventoryService; private GameDataService gameDataService; @@ -34,7 +33,6 @@ public class ContentController : Controller { MissionStoreSingleton missionStore, MissionService missionService, RoomService roomService, - PartyService partyService, AchievementService achievementService, InventoryService inventoryService, GameDataService gameDataService, @@ -48,7 +46,6 @@ public class ContentController : Controller { this.missionStore = missionStore; this.missionService = missionService; this.roomService = roomService; - this.partyService = partyService; this.achievementService = achievementService; this.inventoryService = inventoryService; this.gameDataService = gameDataService; @@ -1489,7 +1486,7 @@ public class ContentController : Controller { uint gameID = ClientVersion.GetGameID(apiKey); - PartyInfo? info = partyService.GetParty(gameID, partyType); + PartyInfo? info = xmlDataService.GetParty(gameID, partyType); if (info == null) return Ok(null); // check if party already exists @@ -1499,7 +1496,7 @@ public class ContentController : Controller { Party party = new Party { Location = info.Location, IconAsset = info.Icon, - LocationIconAsset = partyService.GetLocation(info) ?? "", + LocationIconAsset = xmlDataService.GetPartyLocation(info) ?? "", AssetBundle = info.Bundle, PrivateParty = false, GameID = gameID, diff --git a/src/Program.cs b/src/Program.cs index 3b9cf59..2ec6b86 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -31,7 +31,6 @@ builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); -builder.Services.AddSingleton(); builder.Services.AddScoped(); builder.Services.AddScoped(); diff --git a/src/Resources/parties_info.xml b/src/Resources/parties_info.xml index 13e87ab..ab208b2 100644 --- a/src/Resources/parties_info.xml +++ b/src/Resources/parties_info.xml @@ -19,7 +19,6 @@ Block - 0x01000000 MyVIPRoomInt VIPRoom diff --git a/src/Services/XmlDataService.cs b/src/Services/XmlDataService.cs index e5c169f..6e626d8 100644 --- a/src/Services/XmlDataService.cs +++ b/src/Services/XmlDataService.cs @@ -8,6 +8,8 @@ namespace sodoff.Services; public class XmlDataService { Dictionary displayNames = new(); Dictionary worlds_id = new(); + Dictionary> partyData = new(); + Dictionary partyLocations; public XmlDataService(IOptions config) { if (!config.Value.LoadNonSoDData) @@ -23,6 +25,20 @@ public class XmlDataService { foreach (var w in worlds) { worlds_id[w.Scene] = w.ID; } + + var parties = XmlUtil.DeserializeXml(XmlUtil.ReadResourceXmlString("parties_info")); + foreach (PartyInfo party in parties.Parties) { + if (partyData.TryGetValue(party.GameID, out Dictionary? partyDict)) { + partyDict.TryAdd(party.Type, party); + } else { + partyDict = new Dictionary { + {party.Type, party} + }; + partyData.Add(party.GameID, partyDict); + } + } + + partyLocations = parties.LocationIcons; } public string GetDisplayName(int firstNameID, int secondNameID, int thirdNameID) { @@ -34,4 +50,15 @@ public class XmlDataService { return worlds_id[mapName]; return 0; } + + public PartyInfo? GetParty(uint gameID, string partyType) { + if (!partyData.TryGetValue(gameID, out Dictionary? partyDict)) return null; + partyDict.TryGetValue(partyType, out PartyInfo? party); + return party; + } + + public string? GetPartyLocation(PartyInfo party) { + partyLocations.TryGetValue(party.Location, out string? value); + return value; + } }