mirror of
https://github.com/SoDOff-Project/sodoff.git
synced 2025-11-27 10:06:53 -08:00
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.
This commit is contained in:
parent
b2560300cc
commit
d15db80188
@ -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,
|
||||
|
||||
@ -31,7 +31,6 @@ builder.Services.AddSingleton<StoreService>();
|
||||
builder.Services.AddSingleton<XmlDataService>();
|
||||
builder.Services.AddSingleton<MMOConfigService>();
|
||||
builder.Services.AddSingleton<PartyService>();
|
||||
builder.Services.AddSingleton<WorldIdService>();
|
||||
|
||||
builder.Services.AddScoped<KeyValueService>();
|
||||
builder.Services.AddScoped<MissionService>();
|
||||
|
||||
@ -19,7 +19,6 @@
|
||||
<Descriptor>Block</Descriptor>
|
||||
</Party>
|
||||
<Party>
|
||||
<ItemID></ItemID>
|
||||
<Version>0x01000000</Version>
|
||||
<Location>MyVIPRoomInt</Location>
|
||||
<Type>VIPRoom</Type>
|
||||
|
||||
@ -8,6 +8,8 @@ namespace sodoff.Services;
|
||||
public class XmlDataService {
|
||||
Dictionary<int, string> displayNames = new();
|
||||
Dictionary<string, int> worlds_id = new();
|
||||
Dictionary<uint, Dictionary<string, PartyInfo>> partyData = new();
|
||||
Dictionary<string, string> partyLocations;
|
||||
|
||||
public XmlDataService(IOptions<ApiServerConfig> 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<PartiesInfo>(XmlUtil.ReadResourceXmlString("parties_info"));
|
||||
foreach (PartyInfo party in parties.Parties) {
|
||||
if (partyData.TryGetValue(party.GameID, out Dictionary<string, PartyInfo>? partyDict)) {
|
||||
partyDict.TryAdd(party.Type, party);
|
||||
} else {
|
||||
partyDict = new Dictionary<string, PartyInfo> {
|
||||
{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<string, PartyInfo>? 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;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user