From 5f647f087ca74905ae0bc01bef9782b52dfd5534 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Thu, 14 Dec 2017 08:08:57 -0700 Subject: [PATCH] (Probably) fix invasions started by TShock being weird TShock used to call the StartInvasion method in Main with a type and a size, but then in some update it stopped taking a size. So you have to change a field to change the size, but the problem is that the field is reset when StartInavsion is called. This means that any effort to manually change the size would have failed due to the fact that the field is reset at the end. The order has been changed to account for this. In addition, the start size is now set, so the game can report progress correctly on the current invasion. --- CHANGELOG.md | 1 + TShockAPI/Utils.cs | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8a7890a..4c6df366 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,7 @@ Putting this stuff down here so things don't conflict as often. * Removed `TShock.CheckProjectilePermission` and replaced it with `TSPlayer.HasProjectilePermission` and `TSPlayer.LacksProjectilePermission` respectively. (@hakusaro) * Added `TSPlayer` object to `GetDataHandlers.LiquidSetEventArgs`. (@hakusaro) * Removed `TShock.StartInvasion` for public use (moved to Utils and marked internal). (@hakusaro) +* Fixed invasions started by TShock not reporting size correctly and probably not working at all. (@hakusaro) ## TShock 4.3.25 * Fixed a critical exploit in the Terraria protocol that could cause massive unpreventable world corruption as well as a number of other problems. Thanks to @bartico6 for reporting. Fixed by the efforts of @QuiCM, @hakusaro, and tips in the right directioon from @bartico6. diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs index f831a249..b27bee5d 100644 --- a/TShockAPI/Utils.cs +++ b/TShockAPI/Utils.cs @@ -1465,6 +1465,7 @@ namespace TShockAPI if (TShock.Config.InfiniteInvasion) { + // Not really an infinite size invasionSize = 20000000; } else @@ -1472,10 +1473,15 @@ namespace TShockAPI invasionSize = 100 + (TShock.Config.InvasionMultiplier * ActivePlayers()); } - // Note: This is a workaround to previously providing the size as a parameter in StartInvasion - Main.invasionSize = invasionSize; + // Order matters + // StartInvasion will reset the invasion size Main.StartInvasion(type); + + // Note: This is a workaround to previously providing the size as a parameter in StartInvasion + // Have to set start size to report progress correctly + Main.invasionSizeStart = invasionSize; + Main.invasionSize = invasionSize; } /// Verifies that each stack in each chest is valid and not over the max stack count.