From d1b27d8b7aa17cc33ab6a9e0e794878c43f5ba76 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Mon, 25 May 2020 01:01:47 -0700 Subject: [PATCH] Only process journey research updates for SSC mode This commit changes the logic for sending and accepting journey research requests -- only processing those requests in SSC makes sense. This stops sending extra data to clients that may not know what to do with it when it's not relevant (not in both SSC and journey mode). This also stops us from accepting erroneous journey mode NPC spawn rate update requests when journey mode isn't on but SSC is on due to a weird client glitch in 1.4.0.4. --- TShockAPI/GetDataHandlers.cs | 8 +++++++- TShockAPI/PlayerData.cs | 20 +++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 0dbb3547..e7fa1874 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -3237,6 +3237,12 @@ namespace TShockAPI } case CreativePowerTypes.SetSpawnRate: { + // This is a monkeypatch because the 1.4.0.4 seemingly at random sends NPC spawn rate changes even outside of journey mode + // (with SSC on) -- particles, May 25, 2 Reiwa + if (!Main.GameModeInfo.IsJourneyMode) + { + return true; + } if (!args.Player.HasPermission(Permissions.journey_setspawnrate)) { args.Player.SendErrorMessage("You don't have permission to modify the NPC spawn rate of the server!"); @@ -3249,7 +3255,7 @@ namespace TShockAPI return true; } } - } else if (moduleId == (int)NetModulesTypes.CreativeUnlocksPlayerReport) + } else if (moduleId == (int)NetModulesTypes.CreativeUnlocksPlayerReport && Main.GameModeInfo.IsJourneyMode) { var unknownField = args.Data.ReadByte(); diff --git a/TShockAPI/PlayerData.cs b/TShockAPI/PlayerData.cs index 6e649768..562dea80 100644 --- a/TShockAPI/PlayerData.cs +++ b/TShockAPI/PlayerData.cs @@ -484,18 +484,20 @@ namespace TShockAPI NetMessage.SendData(39, player.Index, -1, NetworkText.Empty, 400); - - var sacrificedItems = TShock.ResearchDatastore.GetSacrificedItems(); - for(int i = 0; i < ItemID.Count; i++) + if (Main.GameModeInfo.IsJourneyMode) { - var amount = 0; - if (sacrificedItems.ContainsKey(i)) + var sacrificedItems = TShock.ResearchDatastore.GetSacrificedItems(); + for(int i = 0; i < ItemID.Count; i++) { - amount = sacrificedItems[i]; - } + var amount = 0; + if (sacrificedItems.ContainsKey(i)) + { + amount = sacrificedItems[i]; + } - var response = NetCreativeUnlocksModule.SerializeItemSacrifice(i, amount); - NetManager.Instance.SendToClient(response, player.TPlayer.whoAmI); + var response = NetCreativeUnlocksModule.SerializeItemSacrifice(i, amount); + NetManager.Instance.SendToClient(response, player.TPlayer.whoAmI); + } } } }