From 00d4aa146a576e90f2c50c9d11156a55034231ad Mon Sep 17 00:00:00 2001 From: Robert Paciorek Date: Sun, 22 Jun 2025 14:44:47 +0000 Subject: [PATCH] ClientVersion.GetGameID to get internal game id (without version / sub-app info) --- src/Controllers/Common/AchievementController.cs | 6 +++--- src/Controllers/Common/ContentController.cs | 9 ++++----- src/Controllers/Common/ItemStoreController.cs | 6 +++--- src/Services/AchievementStoreSingleton.cs | 12 ++---------- src/Util/ClientVersion.cs | 11 +++++++++++ 5 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/Controllers/Common/AchievementController.cs b/src/Controllers/Common/AchievementController.cs index 5bc48dc..b7ccab7 100644 --- a/src/Controllers/Common/AchievementController.cs +++ b/src/Controllers/Common/AchievementController.cs @@ -43,10 +43,10 @@ public class AchievementController : Controller { //[Produces("application/xml")] [Route("AchievementWebService.asmx/GetAllRanks")] public IActionResult GetAllRanks([FromForm] string apiKey) { - uint gameVersion = ClientVersion.GetVersion(apiKey); - if (gameVersion <= ClientVersion.Max_OldJS && (gameVersion & ClientVersion.WoJS) != 0) + uint gameID = ClientVersion.GetGameID(apiKey); + if (gameID == ClientVersion.WoJS) return Ok(XmlUtil.ReadResourceXmlString("ranks.allranks_wojs")); - if (gameVersion == ClientVersion.MB) + if (gameID == ClientVersion.MB) return Ok(XmlUtil.ReadResourceXmlString("ranks.allranks_mb")); return Ok(XmlUtil.ReadResourceXmlString("ranks.allranks_sod")); } diff --git a/src/Controllers/Common/ContentController.cs b/src/Controllers/Common/ContentController.cs index 52dea2b..49e0f18 100644 --- a/src/Controllers/Common/ContentController.cs +++ b/src/Controllers/Common/ContentController.cs @@ -529,8 +529,7 @@ public class ContentController : Controller { raisedPetData.PetTypeID = petTypeID; raisedPetData.RaisedPetID = 0; // Initially make zero, so the db auto-fills raisedPetData.EntityID = Guid.Parse(dragonId); - uint gameVersion = ClientVersion.GetVersion(apiKey); - if (gameVersion > ClientVersion.Max_OldJS || (gameVersion & ClientVersion.WoJS) == 0) + if (ClientVersion.GetGameID(apiKey) != ClientVersion.WoJS) raisedPetData.Name = string.Concat("Dragon-", dragonId.AsSpan(0, 8)); // Start off with a random name (if game isn't WoJS) raisedPetData.IsSelected = false; // The api returns false, not sure why raisedPetData.CreateDate = new DateTime(DateTime.Now.Ticks); @@ -1428,14 +1427,14 @@ public class ContentController : Controller { } } - uint gameVersion = ClientVersion.GetVersion(apiKey); + uint gameID = ClientVersion.GetGameID(apiKey); // Send only JumpStart parties to JumpStart - if (gameVersion <= ClientVersion.Max_OldJS && (gameVersion & ClientVersion.WoJS) != 0 + if (gameID == ClientVersion.WoJS && (party.Location == "MyNeighborhood" || party.Location == "MyVIPRoomInt")) { userParties.Add(userParty); // Send only Math Blaster parties to Math Blaster - } else if (gameVersion == ClientVersion.MB + } else if (gameID == ClientVersion.MB && party.Location == "MyPodInt") { userParties.Add(userParty); } diff --git a/src/Controllers/Common/ItemStoreController.cs b/src/Controllers/Common/ItemStoreController.cs index f7bb205..dc7e0c5 100644 --- a/src/Controllers/Common/ItemStoreController.cs +++ b/src/Controllers/Common/ItemStoreController.cs @@ -77,10 +77,10 @@ public class ItemStoreController : Controller { public IActionResult GetAnnouncements([FromForm] string apiKey, [FromForm] int worldObjectID) { // TODO: This is a placeholder, although this endpoint seems to be only used to send announcements to the user (such as the server shutdown), so this might be sufficient. - uint gameVersion = ClientVersion.GetVersion(apiKey); - if (gameVersion <= ClientVersion.Max_OldJS && (gameVersion & ClientVersion.WoJS) != 0) { + uint gameID = ClientVersion.GetGameID(apiKey); + if (gameID == ClientVersion.WoJS) { return Ok(XmlUtil.DeserializeXml(XmlUtil.ReadResourceXmlString("announcements_wojs"))); - } else if (gameVersion == ClientVersion.SS && worldObjectID == 6) { + } else if (gameID == ClientVersion.SS && worldObjectID == 6) { return Ok(XmlUtil.DeserializeXml(XmlUtil.ReadResourceXmlString("announcements_ss"))); } diff --git a/src/Services/AchievementStoreSingleton.cs b/src/Services/AchievementStoreSingleton.cs index 17a02f1..d3a56e3 100644 --- a/src/Services/AchievementStoreSingleton.cs +++ b/src/Services/AchievementStoreSingleton.cs @@ -73,14 +73,14 @@ namespace sodoff.Services { } public ReadOnlyDictionary GetAchievementsGroupIdToTaskId(uint gameVersion) { - gameVersion = GameVersionForTasks(gameVersion); + gameVersion = ClientVersion.GetGameID(gameVersion); if (achievementsTasks.ContainsKey(gameVersion)) return achievementsTasks[gameVersion].achievementsGroupIdToTaskId; return new ReadOnlyDictionary(new Dictionary()); } public List? GetAllAchievementTaskInfo(int taskID, uint gameVersion) { - gameVersion = GameVersionForTasks(gameVersion); + gameVersion = ClientVersion.GetGameID(gameVersion); if (achievementsTasks.ContainsKey(gameVersion) && achievementsTasks[gameVersion].achievementsRewardByTask.ContainsKey(taskID)) { return achievementsTasks[gameVersion].achievementsRewardByTask[taskID]; } @@ -121,13 +121,5 @@ namespace sodoff.Services { } return dragonXP; } - - private uint GameVersionForTasks(uint gameVersion) { - // all SoD version of SoD using the same Tasks database - if ((gameVersion & ClientVersion.Min_SoD) == 0xa0000000) return ClientVersion.Min_SoD; - // all version of WoJS (including lands) using the same Tasks database - if (gameVersion <= ClientVersion.Max_OldJS && (gameVersion & ClientVersion.WoJS) != 0) return ClientVersion.WoJS; - return gameVersion; - } } } diff --git a/src/Util/ClientVersion.cs b/src/Util/ClientVersion.cs index d1f0702..1fbb25f 100644 --- a/src/Util/ClientVersion.cs +++ b/src/Util/ClientVersion.cs @@ -13,6 +13,17 @@ public class ClientVersion { public const uint WoJS_StoryLand = 0x01000400; // World of JumpStart -- Storyland public const uint WoJS_NewAvatar = 0x01010000; // World of JumpStart with new avatars (e.g. 1.21) + public static uint GetGameID(uint gameVersion) { + if (gameVersion > ClientVersion.Max_OldJS) + return gameVersion & 0xf0000000; + else + return gameVersion & 0x0f000000; + } + + public static uint GetGameID(string apiKey) { + return GetGameID(GetVersion(apiKey)); + } + public static uint GetVersion(string apiKey) { if ( apiKey == "b99f695c-7c6e-4e9b-b0f7-22034d799013" || // PC / Windows