From 5a3de59a7ec48ec13a026772781c1b173e22f68e Mon Sep 17 00:00:00 2001 From: Robert Paciorek Date: Tue, 11 Feb 2025 23:20:37 +0000 Subject: [PATCH] use service for step_missions to allow filtering by name also added api keys for lands --- src/Controllers/Common/ContentController.cs | 6 +- src/Resources/missions/step_missions.xml | 725 ++++++++++++++++++ src/Resources/missions/step_missions_mb.xml | 101 --- .../missions/step_missions_wojs_al.xml | 497 ------------ src/Schema/StepsMissionsGroup.cs | 16 + src/Services/MissionStoreSingleton.cs | 17 + src/Util/ClientVersion.cs | 19 +- src/sodoff.csproj | 5 +- 8 files changed, 778 insertions(+), 608 deletions(-) create mode 100644 src/Resources/missions/step_missions.xml delete mode 100644 src/Resources/missions/step_missions_mb.xml delete mode 100644 src/Resources/missions/step_missions_wojs_al.xml create mode 100644 src/Schema/StepsMissionsGroup.cs diff --git a/src/Controllers/Common/ContentController.cs b/src/Controllers/Common/ContentController.cs index 6b0a2d9..2bb7c48 100644 --- a/src/Controllers/Common/ContentController.cs +++ b/src/Controllers/Common/ContentController.cs @@ -2133,12 +2133,10 @@ public class ContentController : Controller { } [HttpPost] - // [Produces("application/xml")] + [Produces("application/xml")] [Route("MissionWebService.asmx/GetMission")] // old ("step") missions - used by MB and WoJS lands public IActionResult GetMission([FromForm] int gameId, [FromForm] string name) { - if (gameId == 1) return Ok(XmlUtil.ReadResourceXmlString("missions.step_missions_wojs_al")); - if (gameId == 5) return Ok(XmlUtil.ReadResourceXmlString("missions.step_missions_mb")); - return Ok(); + return Ok(missionStore.GetStepsMissions(gameId, name)); } [HttpPost] diff --git a/src/Resources/missions/step_missions.xml b/src/Resources/missions/step_missions.xml new file mode 100644 index 0000000..aa34e03 --- /dev/null +++ b/src/Resources/missions/step_missions.xml @@ -0,0 +1,725 @@ + + + + + 1 + _default_ + + + 4 + Lost Island Mission 1 + + + Welcome to Training Island + 1 + + + 1 + 1 + + + 2 + 2 + + + 3 + 3 + + + 4 + 4 + + + 5 + 5 + + + 179 + 349 + + + 6 + 6 + + + 7 + 7 + + + 8 + 8 + + + 9 + 9 + + + 10 + 10 + + + 23 + 18 + + + 24 + 19 + + + + 18 + Lost Island Mission 2 + + + Mission 2- Congrats! Take the ship to Lost Island and get familar with home base. + 1 + + + 26 + 250 + + + 27 + 251 + + + 28 + 252 + + + 106 + 348 + + + 29 + 253 + + + 30 + 254 + + + 31 + 255 + + + 32 + 256 + + + 33 + 257 + + + + 19 + Lost Island Mission 3 + + + Mission 3- Introduction to Lost Shores + 1 + + + 34 + 258 + + + 35 + 259 + + + 36 + 260 + + + 37 + 261 + + + 38 + 262 + + + 39 + 263 + + + 40 + 264 + + + + 20 + Lost Island Mission 4 + + + Mission 4- Explore Lost Island and intro to the store + 1 + + + 41 + 265 + + + 42 + 266 + + + 43 + 267 + + + 44 + 268 + + + 45 + 269 + + + + 21 + Lost Island Mission 5 + + + Mission 5- Explore the mountain with Hops + 1 + + + 46 + 270 + + + 47 + 271 + + + 48 + 272 + + + 49 + 273 + + + 50 + 274 + + + 51 + 275 + + + + 22 + Lost Island Mission 6 + + + Mission 6- Punk Punk invade- Time to clean house + 1 + + + 52 + 276 + + + 53 + 277 + + + 54 + 278 + + + 55 + 279 + 280 + 281 + 282 + 283 + + + 56 + 284 + + + 57 + 285 + + + 58 + 286 + + + + 23 + Lost Island Mission 7 + + + Mission 7- Get the Lost Shores ready for the celebration + 1 + + + 59 + 287 + + + 60 + 288 + + + 61 + 289 + 290 + 291 + + + 62 + 292 + 293 + 294 + + + 63 + 295 + + + 64 + 296 + + + 65 + 297 + + + 66 + 298 + + + 67 + 299 + + + + 24 + Lost Island Mission 8 + + + Mission 8- Lets Party + 1 + + + 68 + 300 + + + 69 + 301 + + + 70 + 302 + + + 71 + 303 + + + 72 + 304 + + + 73 + 305 + + + 74 + 306 + + + 75 + 307 + + + 76 + 308 + + + 77 + 309 + + + 78 + 310 + + + + 25 + Lost Island Mission 9 + + + Mission 9- Find where Punk Punks are coming from. + 1 + + + 79 + 311 + + + 80 + 312 + + + 81 + 313 + + + 82 + 314 + + + 83 + 315 + + + 84 + 316 + + + 85 + 317 + + + + 26 + Lost Island Mission 10 + + + Mission 10- Introduce Rabbit holes and get statue + 1 + + + 86 + 318 + + + 87 + 319 + + + 88 + 320 + + + 89 + 321 + + + 90 + 322 + + + 91 + 323 + + + 92 + 324 + 325 + + + 93 + 326 + + + + 27 + Lost Island Mission 11 + + + Mission 11- Protect Lost Island from the Punk Punks + 1 + + + 94 + 327 + + + 95 + 328 + + + 96 + 329 + + + 97 + 330 + + + 98 + 331 + + + 99 + 332 + + + 100 + 333 + + + + 28 + Lost Island Mission 12 + + + Mission 12- Need to take the statue back to the valley + 1 + + + 101 + 334 + + + 102 + 335 + + + 103 + 336 + + + 104 + 338 + + + 105 + 339 + + + + + + + 2 + FIXME + + + + + 4 + FIXME + + + + + 5 + MB Boys + + + 189 + Rescue a Larva + ADOPT A PET TO RAISE AND TRAIN. + + ADOPT A PET TO RAISE AND TRAIN. + -1 + + + 326 + 505 + + + + 213 + Larva Attachment + Play and Feed your larva + + Lets get emotionally attached to the larva + -1 + + DlgGCM213End + GC + RS_DATA/MBDirectedM213.unity3d + + + 350 + 529 + + + 351 + 530 + + + 354 + 533 + 534 + + + + 215 + MB Boy Visit Mutt Pod + Go to your Mutt Pod + + Visit Mutt Pod Boy + -1 + + DlgGCM215End + GC + RS_DATA/MBDirectedM215.unity3d + + + 358 + 539 + + + 360 + 541 + + + + 217 + MB Boy Visit Pod + Go to your Pod + + Visit Pod Boy + -1 + + DlgGCM217End + GC + RS_DATA/MBDirectedM217.unity3d + + + 366 + 547 + + + 368 + 549 + + + 370 + 551 + + + + 220 + MB Boy Play Hyperblast + Play Hyperblast + + Play Hyperblast Boy + -1 + + + 373 + 554 + + + + + + + 5 + MB Girls + + + 189 + Rescue a Larva + ADOPT A PET TO RAISE AND TRAIN. + + ADOPT A PET TO RAISE AND TRAIN. + -1 + + + 326 + 505 + + + + 213 + Larva Attachment + Play and Feed your larva + + Lets get emotionally attached to the larva + -1 + + DlgGCM213End + GC + RS_DATA/MBDirectedM213.unity3d + + + 350 + 529 + + + 351 + 530 + + + 354 + 533 + 534 + + + + 216 + MB Girl Visit Mutt Pod + Go to your Mutt Pod + + Visit Mutt Pod Girl + -1 + + DlgGCM216End + GC + RS_DATA/MBDirectedM216.unity3d + + + 359 + 540 + + + 361 + 542 + + + + 218 + MB Girl Visit Pod + Go to your Pod + + Visit Pod Girl + -1 + + DlgGCM218End + GC + RS_DATA/MBDirectedM218.unity3d + + + 367 + 548 + + + 369 + 550 + + + 371 + 552 + + + + 219 + MB Girl Play Hyperblast + Play Hyperblast + + Play Hyperblast Girl + -1 + + + 372 + 553 + + + + + diff --git a/src/Resources/missions/step_missions_mb.xml b/src/Resources/missions/step_missions_mb.xml deleted file mode 100644 index d3613a6..0000000 --- a/src/Resources/missions/step_missions_mb.xml +++ /dev/null @@ -1,101 +0,0 @@ - - - - 189 - Rescue a Larva - ADOPT A PET TO RAISE AND TRAIN. - - ADOPT A PET TO RAISE AND TRAIN. - -1 - - - 326 - 505 - - - - 213 - Larva Attachment - Play and Feed your larva - - Lets get emotionally attached to the larva - -1 - - DlgGCM213End - GC - RS_DATA/MBDirectedM213.unity3d - - - 350 - 529 - - - 351 - 530 - - - 354 - 533 - 534 - - - - 215 - MB Boy Visit Mutt Pod - Go to your Mutt Pod - - Visit Mutt Pod Boy - -1 - - DlgGCM215End - GC - RS_DATA/MBDirectedM215.unity3d - - - 358 - 539 - - - 360 - 541 - - - - 217 - MB Boy Visit Pod - Go to your Pod - - Visit Pod Boy - -1 - - DlgGCM217End - GC - RS_DATA/MBDirectedM217.unity3d - - - 366 - 547 - - - 368 - 549 - - - 370 - 551 - - - - 220 - MB Boy Play Hyperblast - Play Hyperblast - - Play Hyperblast Boy - -1 - - - 373 - 554 - - - \ No newline at end of file diff --git a/src/Resources/missions/step_missions_wojs_al.xml b/src/Resources/missions/step_missions_wojs_al.xml deleted file mode 100644 index a135623..0000000 --- a/src/Resources/missions/step_missions_wojs_al.xml +++ /dev/null @@ -1,497 +0,0 @@ - - - - 4 - Lost Island Mission 1 - - - Welcome to Training Island - 1 - - - 1 - 1 - - - 2 - 2 - - - 3 - 3 - - - 4 - 4 - - - 5 - 5 - - - 179 - 349 - - - 6 - 6 - - - 7 - 7 - - - 8 - 8 - - - 9 - 9 - - - 10 - 10 - - - 23 - 18 - - - 24 - 19 - - - - 18 - Lost Island Mission 2 - - - Mission 2- Congrats! Take the ship to Lost Island and get familar with home base. - 1 - - - 26 - 250 - - - 27 - 251 - - - 28 - 252 - - - 106 - 348 - - - 29 - 253 - - - 30 - 254 - - - 31 - 255 - - - 32 - 256 - - - 33 - 257 - - - - 19 - Lost Island Mission 3 - - - Mission 3- Introduction to Lost Shores - 1 - - - 34 - 258 - - - 35 - 259 - - - 36 - 260 - - - 37 - 261 - - - 38 - 262 - - - 39 - 263 - - - 40 - 264 - - - - 20 - Lost Island Mission 4 - - - Mission 4- Explore Lost Island and intro to the store - 1 - - - 41 - 265 - - - 42 - 266 - - - 43 - 267 - - - 44 - 268 - - - 45 - 269 - - - - 21 - Lost Island Mission 5 - - - Mission 5- Explore the mountain with Hops - 1 - - - 46 - 270 - - - 47 - 271 - - - 48 - 272 - - - 49 - 273 - - - 50 - 274 - - - 51 - 275 - - - - 22 - Lost Island Mission 6 - - - Mission 6- Punk Punk invade- Time to clean house - 1 - - - 52 - 276 - - - 53 - 277 - - - 54 - 278 - - - 55 - 279 - 280 - 281 - 282 - 283 - - - 56 - 284 - - - 57 - 285 - - - 58 - 286 - - - - 23 - Lost Island Mission 7 - - - Mission 7- Get the Lost Shores ready for the celebration - 1 - - - 59 - 287 - - - 60 - 288 - - - 61 - 289 - 290 - 291 - - - 62 - 292 - 293 - 294 - - - 63 - 295 - - - 64 - 296 - - - 65 - 297 - - - 66 - 298 - - - 67 - 299 - - - - 24 - Lost Island Mission 8 - - - Mission 8- Lets Party - 1 - - - 68 - 300 - - - 69 - 301 - - - 70 - 302 - - - 71 - 303 - - - 72 - 304 - - - 73 - 305 - - - 74 - 306 - - - 75 - 307 - - - 76 - 308 - - - 77 - 309 - - - 78 - 310 - - - - 25 - Lost Island Mission 9 - - - Mission 9- Find where Punk Punks are coming from. - 1 - - - 79 - 311 - - - 80 - 312 - - - 81 - 313 - - - 82 - 314 - - - 83 - 315 - - - 84 - 316 - - - 85 - 317 - - - - 26 - Lost Island Mission 10 - - - Mission 10- Introduce Rabbit holes and get statue - 1 - - - 86 - 318 - - - 87 - 319 - - - 88 - 320 - - - 89 - 321 - - - 90 - 322 - - - 91 - 323 - - - 92 - 324 - 325 - - - 93 - 326 - - - - 27 - Lost Island Mission 11 - - - Mission 11- Protect Lost Island from the Punk Punks - 1 - - - 94 - 327 - - - 95 - 328 - - - 96 - 329 - - - 97 - 330 - - - 98 - 331 - - - 99 - 332 - - - 100 - 333 - - - - 28 - Lost Island Mission 12 - - - Mission 12- Need to take the statue back to the valley - 1 - - - 101 - 334 - - - 102 - 335 - - - 103 - 336 - - - 104 - 338 - - - 105 - 339 - - - - diff --git a/src/Schema/StepsMissionsGroup.cs b/src/Schema/StepsMissionsGroup.cs new file mode 100644 index 0000000..cf97ca6 --- /dev/null +++ b/src/Schema/StepsMissionsGroup.cs @@ -0,0 +1,16 @@ +using System.Xml.Serialization; + +namespace sodoff.Schema; + +[XmlRoot(ElementName = "StepsMissionsGroup", Namespace = "")] +[Serializable] +public class StepsMissionsGroup { + [XmlElement(ElementName = "GameId")] + public int GameId; + + [XmlElement(ElementName = "WorldName")] + public string WorldName; + + [XmlElement(ElementName = "MissionData")] + public MissionData MissionData; +} diff --git a/src/Services/MissionStoreSingleton.cs b/src/Services/MissionStoreSingleton.cs index c5ccd2d..09da06f 100644 --- a/src/Services/MissionStoreSingleton.cs +++ b/src/Services/MissionStoreSingleton.cs @@ -8,6 +8,7 @@ namespace sodoff.Services; public class MissionStoreSingleton { private Dictionary missions = new(); + private Dictionary<(int, string), MissionData> stepsMissions = new(); private Dictionary steps = new(); private int[] activeMissions; private int[] upcomingMissions; @@ -48,6 +49,11 @@ public class MissionStoreSingleton { activeMissionsWoJS = defaultMissions.Active; upcomingMissionsWoJS = defaultMissions.Upcoming; + var stepsMissionsArray = XmlUtil.DeserializeXml(XmlUtil.ReadResourceXmlString("missions.step_missions")); + foreach (var missionGroup in stepsMissionsArray) { + stepsMissions.Add((missionGroup.GameId, missionGroup.WorldName), missionGroup.MissionData); + } + var stepArray = XmlUtil.DeserializeXml(XmlUtil.ReadResourceXmlString("missions.step_missions_steps")); foreach (var step in stepArray) { steps.Add(step.StepID.Value, step); @@ -91,6 +97,17 @@ public class MissionStoreSingleton { return new int[0]; } + public MissionData GetStepsMissions(int gameId, string worldName) { + if (stepsMissions.ContainsKey((gameId, worldName))) { + return stepsMissions[(gameId, worldName)]; + } else if (stepsMissions.ContainsKey((gameId, "_default_"))) { + return stepsMissions[(gameId, "_default_")]; + } else { + Console.WriteLine($"Can't find missions for gameId={gameId} worldName={worldName}"); + return new MissionData(); + } + } + public Step GetStep(int stepID) { return steps[stepID]; } diff --git a/src/Util/ClientVersion.cs b/src/Util/ClientVersion.cs index b9e66e7..d1f0702 100644 --- a/src/Util/ClientVersion.cs +++ b/src/Util/ClientVersion.cs @@ -7,8 +7,11 @@ public class ClientVersion { public const uint EMD = 0x04000000; public const uint SS = 0x02000000; public const uint WoJS = 0x01000000; - public const uint WoJS_AdvLand = 0x01000100; // World of JumpStart -- Adventureland - public const uint WoJS_NewAvatar = 0x01010000; // World of JumpStart with new avatars (e.g. 1.21) + public const uint WoJS_AdvLand = 0x01000100; // World of JumpStart -- Adventureland + public const uint WoJS_FutureLand = 0x01000200; // World of JumpStart -- Futureland + public const uint WoJS_MarineLand = 0x01000300; // World of JumpStart -- Marineland + 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 GetVersion(string apiKey) { if ( @@ -49,6 +52,18 @@ public class ClientVersion { apiKey == "b4e0f71a-1cda-462a-97b3-0b355e87e0c8" ) { return WoJS_AdvLand; + } else if ( + apiKey == "4fb5e29f-64e7-4cbb-8554-6f6c54b57597" + ) { + return WoJS_FutureLand; + } else if ( + apiKey == "dc37ef0d-e1f8-4718-8239-73e68424e384" + ) { + return WoJS_MarineLand; + } else if ( + apiKey == "bd69b6b9-a921-4741-a2a0-92fc40cc2e58" + ) { + return WoJS_StoryLand; } Console.WriteLine($"Unknown apiKey value: {apiKey}"); return 0; diff --git a/src/sodoff.csproj b/src/sodoff.csproj index f3d9568..b8fe201 100644 --- a/src/sodoff.csproj +++ b/src/sodoff.csproj @@ -148,10 +148,7 @@ PreserveNewest - - PreserveNewest - - + PreserveNewest