From 48ea956724378eb25c9af0138e8217017c4db5ac Mon Sep 17 00:00:00 2001 From: Deathmax Date: Sat, 4 Jun 2011 14:19:22 +0800 Subject: [PATCH 01/20] Added spawn protection. Prevents any tile from being placed/killed within a 5 block radius. /protectspawn - Toggle spawn protection. --- TShockAPI/Commands.cs | 7 +++++ TShockAPI/ConfigFile.cs | 1 + TShockAPI/ConfigurationManager.cs | 3 ++ TShockAPI/TShock.cs | 51 ++++++++++++++++++++++++++++--- 4 files changed, 58 insertions(+), 4 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index f9829ee1..599a27d8 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -55,6 +55,7 @@ namespace TShockAPI TShock.admincommandList.Add("help", new CommandDelegate(Help)); TShock.admincommandList.Add("slap", new CommandDelegate(Slap)); TShock.admincommandList.Add("off-nosave", new CommandDelegate(OffNoSave)); + TShock.admincommandList.Add("protectspawn", new CommandDelegate(ProtectSpawn)); TShock.commandList.Add("help", new CommandDelegate(Help)); TShock.commandList.Add("kill", new CommandDelegate(Kill)); } @@ -559,6 +560,12 @@ namespace TShockAPI else Tools.SendMessage(args.PlayerID, "Invalid syntax! Proper syntax: /slap [dmg]", new float[] { 255f, 0f, 0f }); } + + public static void ProtectSpawn(CommandArgs args) + { + ConfigurationManager.spawnProtect = (ConfigurationManager.spawnProtect == false); + Tools.SendMessage(args.PlayerID, "Spawn is now " + (ConfigurationManager.spawnProtect ? "protected" : "open") + "."); + } #endregion } } diff --git a/TShockAPI/ConfigFile.cs b/TShockAPI/ConfigFile.cs index 1ce76424..72ed278c 100644 --- a/TShockAPI/ConfigFile.cs +++ b/TShockAPI/ConfigFile.cs @@ -23,5 +23,6 @@ namespace TShockAPI public bool KickKillTileAbusers = false; public bool BanExplosives = true; public bool KickExplosives = true; + public bool SpawnProtection = true; } } diff --git a/TShockAPI/ConfigurationManager.cs b/TShockAPI/ConfigurationManager.cs index aacce18c..a53db9de 100644 --- a/TShockAPI/ConfigurationManager.cs +++ b/TShockAPI/ConfigurationManager.cs @@ -29,6 +29,7 @@ namespace TShockAPI public static bool kickTnt = false; public static bool banBoom = true; public static bool kickBoom = true; + public static bool spawnProtect = true; public enum NPCList : int { @@ -58,6 +59,7 @@ namespace TShockAPI kickTnt = cfg.KickKillTileAbusers; banBoom = cfg.BanExplosives; kickBoom = cfg.KickExplosives; + spawnProtect = cfg.SpawnProtection; } public static void WriteJsonConfiguration() @@ -87,6 +89,7 @@ namespace TShockAPI cfg.KickKillTileAbusers = true; cfg.BanExplosives = true; cfg.KickExplosives = true; + cfg.SpawnProtection = true; string json = JsonConvert.SerializeObject(cfg, Formatting.Indented); TextWriter tr = new StreamWriter(FileTools.SaveDir + "config.json"); diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 9ed1bcfe..d5292119 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -137,8 +137,6 @@ namespace TShockAPI NetHooks.OnPreGetData -= GetData; NetHooks.OnGreetPlayer -= new NetHooks.GreetPlayerD(OnGreetPlayer); NpcHooks.OnStrikeNpc -= new NpcHooks.StrikeNpcD(NpcHooks_OnStrikeNpc); - ConfigurationManager.WriteJsonConfiguration(); - Log.Info("Shutting down..."); } /* @@ -178,10 +176,20 @@ namespace TShockAPI int y = br.ReadInt32(); byte typetile = br.ReadByte(); + if (type == 0 || type == 1) + if (ConfigurationManager.spawnProtect) + if (!players[e.Msg.whoAmI].IsAdmin()) + { + var flag = CheckSpawn(x, y); + if (flag) + { + Tools.SendMessage(e.Msg.whoAmI, "The spawn is protected!", new float[] { 255f, 0f, 0f }); + e.Handled = true; + } + } + if (type == 0 && BlacklistTiles[Main.tile[x, y].type] && Main.player[e.Msg.whoAmI].active) - { players[e.Msg.whoAmI].tileThreshold++; - } } return; } @@ -332,6 +340,30 @@ namespace TShockAPI e.Handled = true; } } + else if (e.MsgID == 0x30) + { + int x; + int y; + byte liquid; + bool lava; + using (var br = new BinaryReader(new MemoryStream(e.Msg.readBuffer, e.Index, e.Length))) + { + x = br.ReadInt32(); + y = br.ReadInt32(); + liquid = br.ReadByte(); + lava = br.ReadBoolean(); + } + if (ConfigurationManager.spawnProtect) + if (!players[e.Msg.whoAmI].IsAdmin()) + { + var flag = CheckSpawn(x, y); + if (flag) + { + Tools.SendMessage(e.Msg.whoAmI, "The spawn is protected!", new float[] { 255f, 0f, 0f }); + e.Handled = true; + } + } + } } catch (Exception ex) { @@ -683,5 +715,16 @@ namespace TShockAPI } return false; } + + public static bool CheckSpawn(int x, int y) + { + Vector2 tile = new Vector2((float)x, (float)y); + Vector2 spawn = new Vector2((float)Main.spawnTileX, (float)Main.spawnTileY); + var distance = Vector2.Distance(spawn, tile); + if (distance > 5) + return false; + else + return true; + } } } \ No newline at end of file From b9ff874351296e45cebbc8746f701d7c3a1238cf Mon Sep 17 00:00:00 2001 From: Deathmax Date: Sat, 4 Jun 2011 14:25:47 +0800 Subject: [PATCH 02/20] Added spawn protection radius to config. --- TShockAPI/ConfigFile.cs | 1 + TShockAPI/ConfigurationManager.cs | 3 +++ TShockAPI/TShock.cs | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/TShockAPI/ConfigFile.cs b/TShockAPI/ConfigFile.cs index 72ed278c..868bcb2b 100644 --- a/TShockAPI/ConfigFile.cs +++ b/TShockAPI/ConfigFile.cs @@ -24,5 +24,6 @@ namespace TShockAPI public bool BanExplosives = true; public bool KickExplosives = true; public bool SpawnProtection = true; + public int SpawnProtectionRadius = 5; } } diff --git a/TShockAPI/ConfigurationManager.cs b/TShockAPI/ConfigurationManager.cs index a53db9de..800d03a2 100644 --- a/TShockAPI/ConfigurationManager.cs +++ b/TShockAPI/ConfigurationManager.cs @@ -30,6 +30,7 @@ namespace TShockAPI public static bool banBoom = true; public static bool kickBoom = true; public static bool spawnProtect = true; + public static int spawnProtectRadius = 5; public enum NPCList : int { @@ -60,6 +61,7 @@ namespace TShockAPI banBoom = cfg.BanExplosives; kickBoom = cfg.KickExplosives; spawnProtect = cfg.SpawnProtection; + spawnProtectRadius = cfg.SpawnProtectionRadius; } public static void WriteJsonConfiguration() @@ -90,6 +92,7 @@ namespace TShockAPI cfg.BanExplosives = true; cfg.KickExplosives = true; cfg.SpawnProtection = true; + cfg.SpawnProtectionRadius = 5; string json = JsonConvert.SerializeObject(cfg, Formatting.Indented); TextWriter tr = new StreamWriter(FileTools.SaveDir + "config.json"); diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index d5292119..351b0faf 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -721,7 +721,7 @@ namespace TShockAPI Vector2 tile = new Vector2((float)x, (float)y); Vector2 spawn = new Vector2((float)Main.spawnTileX, (float)Main.spawnTileY); var distance = Vector2.Distance(spawn, tile); - if (distance > 5) + if (distance > (float)ConfigurationManager.spawnProtectRadius) return false; else return true; From d26cd3bd16ad28c02a36c49673ccbb0f7d9fcf23 Mon Sep 17 00:00:00 2001 From: Deathmax Date: Sun, 5 Jun 2011 00:02:56 +0800 Subject: [PATCH 03/20] Some KillTile prevention thingy --- TShockAPI/TShock.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 351b0faf..8571b9a1 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -364,6 +364,8 @@ namespace TShockAPI } } } + else if (e.MsgID == 0x22) // Client only KillTile + e.Handled = true; // Client only uses it for chests, but sends regular 17 as well. } catch (Exception ex) { From 95a066d145062fc62db27995f2116a6d71a4ce35 Mon Sep 17 00:00:00 2001 From: Shank Date: Sat, 4 Jun 2011 20:28:29 -0600 Subject: [PATCH 04/20] Fixing spawn rates --- TShockAPI/Commands.cs | 4 ++-- TShockAPI/ConfigurationManager.cs | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 599a27d8..fd2611a8 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -421,7 +421,7 @@ namespace TShockAPI public static void MaxSpawns(CommandArgs args) { int ply = args.PlayerID; - int amount = 4;//Convert.ToInt32(args.Message.Remove(0, 10)); + int amount = Convert.ToInt32(args.Message.Remove(0, 10)); int.TryParse(args.Message.Remove(0, 10), out amount); NPC.maxSpawns = amount; Tools.Broadcast(Tools.FindPlayer(ply) + " changed the maximum spawns to: " + amount); @@ -430,7 +430,7 @@ namespace TShockAPI public static void SpawnRate(CommandArgs args) { int ply = args.PlayerID; - int amount = 700;//Convert.ToInt32(args.Message.Remove(0, 10)); + int amount = Convert.ToInt32(args.Message.Remove(0, 10)); int.TryParse(args.Message.Remove(0, 10), out amount); NPC.spawnRate = amount; Tools.Broadcast(Tools.FindPlayer(ply) + " changed the spawn rate to: " + amount); diff --git a/TShockAPI/ConfigurationManager.cs b/TShockAPI/ConfigurationManager.cs index 980791fc..b23ef101 100644 --- a/TShockAPI/ConfigurationManager.cs +++ b/TShockAPI/ConfigurationManager.cs @@ -62,6 +62,9 @@ namespace TShockAPI kickBoom = cfg.KickExplosives; spawnProtect = cfg.SpawnProtection; spawnProtectRadius = cfg.SpawnProtectionRadius; + + Terraria.NPC.maxSpawns = defaultMaxSpawns; + Terraria.NPC.defaultSpawnRate = defaultSpawnRate; } public static void WriteJsonConfiguration() From 68014b4853f3f5e3ce71325987872dc855092c02 Mon Sep 17 00:00:00 2001 From: Shank Date: Sat, 4 Jun 2011 20:38:45 -0600 Subject: [PATCH 05/20] SpawnRate now uses default spawn rate --- TShockAPI/Commands.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index fd2611a8..ee5addd5 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -423,7 +423,7 @@ namespace TShockAPI int ply = args.PlayerID; int amount = Convert.ToInt32(args.Message.Remove(0, 10)); int.TryParse(args.Message.Remove(0, 10), out amount); - NPC.maxSpawns = amount; + NPC.defaultSpawnRate = amount; Tools.Broadcast(Tools.FindPlayer(ply) + " changed the maximum spawns to: " + amount); } @@ -432,7 +432,7 @@ namespace TShockAPI int ply = args.PlayerID; int amount = Convert.ToInt32(args.Message.Remove(0, 10)); int.TryParse(args.Message.Remove(0, 10), out amount); - NPC.spawnRate = amount; + NPC.defaultSpawnRate = amount; Tools.Broadcast(Tools.FindPlayer(ply) + " changed the spawn rate to: " + amount); } From dc374f9051c727056831853dc0dcba4a98908e78 Mon Sep 17 00:00:00 2001 From: Deathmax Date: Sun, 5 Jun 2011 11:10:14 +0800 Subject: [PATCH 06/20] Log no longer outputs to console. (Some things are calling it too fast) --- TShockAPI/Log.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/Log.cs b/TShockAPI/Log.cs index d2d6f354..de1ca59e 100644 --- a/TShockAPI/Log.cs +++ b/TShockAPI/Log.cs @@ -84,7 +84,7 @@ namespace TShockAPI String text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture) + " - " + caller + message; - Console.WriteLine(text); + //Console.WriteLine(text); if (!MayWriteType(level)) { From 3f3b1cc40e3bda448e49ae2f761455c1977d8f0a Mon Sep 17 00:00:00 2001 From: Shank Date: Sat, 4 Jun 2011 21:56:24 -0600 Subject: [PATCH 07/20] Added /debug-config Added Version codename Added version tick early --- TShockAPI/Commands.cs | 30 ++++++++++++++++++++++++++++++ TShockAPI/ConfigurationManager.cs | 3 +++ TShockAPI/TShock.cs | 11 +++++++---- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index ee5addd5..443c99d6 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -56,11 +56,41 @@ namespace TShockAPI TShock.admincommandList.Add("slap", new CommandDelegate(Slap)); TShock.admincommandList.Add("off-nosave", new CommandDelegate(OffNoSave)); TShock.admincommandList.Add("protectspawn", new CommandDelegate(ProtectSpawn)); + TShock.admincommandList.Add("debug-config", new CommandDelegate(DebugConfiguration)); TShock.commandList.Add("help", new CommandDelegate(Help)); TShock.commandList.Add("kill", new CommandDelegate(Kill)); } #region Command Methods + + public static void DebugConfiguration(CommandArgs args) + { + int ply = args.PlayerID; + var commands = TShock.commandList; + if (TShock.players[ply].IsAdmin()) + commands = TShock.admincommandList; + Tools.SendMessage(ply, "TShock Config:"); + string lineOne = ""; + lineOne += "KickCheater : " + ConfigurationManager.kickCheater + ", "; + lineOne += "BanCheater : " + ConfigurationManager.banCheater + ", "; + lineOne += "KickGriefer : " + ConfigurationManager.kickGriefer + ", "; + lineOne += "BanGriefer : " + ConfigurationManager.banGriefer; + Tools.SendMessage(ply, lineOne, new float[] { 255f, 255f, 0f }); + string lineTwo = ""; + lineTwo += "BanTnt : " + ConfigurationManager.banTnt + ", "; + lineTwo += "KickTnt : " + ConfigurationManager.kickTnt + ", "; + lineTwo += "BanBoom : " + ConfigurationManager.banBoom + ", "; + lineTwo += "KickBoom : " + ConfigurationManager.kickBoom; + Tools.SendMessage(ply, lineTwo, new float[] { 255f, 255f, 0f }); + string lineThree = ""; + lineThree += "InvMultiplier : " + ConfigurationManager.invasionMultiplier + ", "; + lineThree += "SpawnProtect : " + ConfigurationManager.spawnProtect + ", "; + lineThree += "SpawnProtectR : " + ConfigurationManager.spawnProtectRadius + ", "; + lineThree += "DefaultMaxSpawns : " + ConfigurationManager.defaultMaxSpawns + ", "; + lineThree += "SpawnRate: " + ConfigurationManager.defaultSpawnRate + ", "; + Tools.SendMessage(ply, lineThree, new float[] { 255f, 255f, 0f}); + } + public static void Kick(CommandArgs args) { string plStr = args.Message.Remove(0, 5).Trim(); diff --git a/TShockAPI/ConfigurationManager.cs b/TShockAPI/ConfigurationManager.cs index 0edfdaa2..dc792931 100644 --- a/TShockAPI/ConfigurationManager.cs +++ b/TShockAPI/ConfigurationManager.cs @@ -31,6 +31,7 @@ namespace TShockAPI public static bool kickBoom = true; public static bool spawnProtect = true; public static int spawnProtectRadius = 5; + public static ConfigFile config = null; public enum NPCList : int { @@ -44,6 +45,8 @@ namespace TShockAPI TextReader tr = new StreamReader(FileTools.SaveDir + "config.json"); ConfigFile cfg = JsonConvert.DeserializeObject(tr.ReadToEnd()); tr.Close(); + + config = cfg; invasionMultiplier = cfg.InvasionMultiplier; defaultMaxSpawns = cfg.DefaultMaximumSpawns; diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index d68dabdc..4ccf714f 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -15,7 +15,9 @@ namespace TShockAPI public static string saveDir = "./tshock/"; - public static Version VersionNum = new Version(1, 6, 0, 0); + public static Version VersionNum = new Version(1, 7, 0, 0); + + public static string VersionCodename = "Bugless Beast"; public static bool shownVersion = false; @@ -111,6 +113,7 @@ namespace TShockAPI { Console.WriteLine(ex.ToString()); } + Console.WriteLine("TShock Version " + Version.Major + "." + Version.Minor + "." + Version.Build + "." + Version.Revision + " (" + VersionCodename + ") now running."); Log.Initialize(FileTools.SaveDir + "log.txt", LogLevel.All, true); Log.Info("Starting..."); GameHooks.OnPreInitialize += OnPreInit; @@ -372,11 +375,11 @@ namespace TShockAPI } } } -<<<<<<< HEAD +<<<<<<< HEAD else if (e.MsgID == 0x22) // Client only KillTile e.Handled = true; // Client only uses it for chests, but sends regular 17 as well. -======= ->>>>>>> master +======= +>>>>>>> master } catch (Exception ex) { From b786c80bb044a1952e77bd3d5395b6f1494af6cd Mon Sep 17 00:00:00 2001 From: Shank Date: Sat, 4 Jun 2011 21:56:24 -0600 Subject: [PATCH 08/20] Added /debug-config Added Version codename Added version tick early Closes #15 --- TShockAPI/Commands.cs | 30 ++++++++++++++++++++++++++++++ TShockAPI/ConfigurationManager.cs | 3 +++ TShockAPI/TShock.cs | 11 +++++++---- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index ee5addd5..443c99d6 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -56,11 +56,41 @@ namespace TShockAPI TShock.admincommandList.Add("slap", new CommandDelegate(Slap)); TShock.admincommandList.Add("off-nosave", new CommandDelegate(OffNoSave)); TShock.admincommandList.Add("protectspawn", new CommandDelegate(ProtectSpawn)); + TShock.admincommandList.Add("debug-config", new CommandDelegate(DebugConfiguration)); TShock.commandList.Add("help", new CommandDelegate(Help)); TShock.commandList.Add("kill", new CommandDelegate(Kill)); } #region Command Methods + + public static void DebugConfiguration(CommandArgs args) + { + int ply = args.PlayerID; + var commands = TShock.commandList; + if (TShock.players[ply].IsAdmin()) + commands = TShock.admincommandList; + Tools.SendMessage(ply, "TShock Config:"); + string lineOne = ""; + lineOne += "KickCheater : " + ConfigurationManager.kickCheater + ", "; + lineOne += "BanCheater : " + ConfigurationManager.banCheater + ", "; + lineOne += "KickGriefer : " + ConfigurationManager.kickGriefer + ", "; + lineOne += "BanGriefer : " + ConfigurationManager.banGriefer; + Tools.SendMessage(ply, lineOne, new float[] { 255f, 255f, 0f }); + string lineTwo = ""; + lineTwo += "BanTnt : " + ConfigurationManager.banTnt + ", "; + lineTwo += "KickTnt : " + ConfigurationManager.kickTnt + ", "; + lineTwo += "BanBoom : " + ConfigurationManager.banBoom + ", "; + lineTwo += "KickBoom : " + ConfigurationManager.kickBoom; + Tools.SendMessage(ply, lineTwo, new float[] { 255f, 255f, 0f }); + string lineThree = ""; + lineThree += "InvMultiplier : " + ConfigurationManager.invasionMultiplier + ", "; + lineThree += "SpawnProtect : " + ConfigurationManager.spawnProtect + ", "; + lineThree += "SpawnProtectR : " + ConfigurationManager.spawnProtectRadius + ", "; + lineThree += "DefaultMaxSpawns : " + ConfigurationManager.defaultMaxSpawns + ", "; + lineThree += "SpawnRate: " + ConfigurationManager.defaultSpawnRate + ", "; + Tools.SendMessage(ply, lineThree, new float[] { 255f, 255f, 0f}); + } + public static void Kick(CommandArgs args) { string plStr = args.Message.Remove(0, 5).Trim(); diff --git a/TShockAPI/ConfigurationManager.cs b/TShockAPI/ConfigurationManager.cs index 0edfdaa2..dc792931 100644 --- a/TShockAPI/ConfigurationManager.cs +++ b/TShockAPI/ConfigurationManager.cs @@ -31,6 +31,7 @@ namespace TShockAPI public static bool kickBoom = true; public static bool spawnProtect = true; public static int spawnProtectRadius = 5; + public static ConfigFile config = null; public enum NPCList : int { @@ -44,6 +45,8 @@ namespace TShockAPI TextReader tr = new StreamReader(FileTools.SaveDir + "config.json"); ConfigFile cfg = JsonConvert.DeserializeObject(tr.ReadToEnd()); tr.Close(); + + config = cfg; invasionMultiplier = cfg.InvasionMultiplier; defaultMaxSpawns = cfg.DefaultMaximumSpawns; diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index d68dabdc..4ccf714f 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -15,7 +15,9 @@ namespace TShockAPI public static string saveDir = "./tshock/"; - public static Version VersionNum = new Version(1, 6, 0, 0); + public static Version VersionNum = new Version(1, 7, 0, 0); + + public static string VersionCodename = "Bugless Beast"; public static bool shownVersion = false; @@ -111,6 +113,7 @@ namespace TShockAPI { Console.WriteLine(ex.ToString()); } + Console.WriteLine("TShock Version " + Version.Major + "." + Version.Minor + "." + Version.Build + "." + Version.Revision + " (" + VersionCodename + ") now running."); Log.Initialize(FileTools.SaveDir + "log.txt", LogLevel.All, true); Log.Info("Starting..."); GameHooks.OnPreInitialize += OnPreInit; @@ -372,11 +375,11 @@ namespace TShockAPI } } } -<<<<<<< HEAD +<<<<<<< HEAD else if (e.MsgID == 0x22) // Client only KillTile e.Handled = true; // Client only uses it for chests, but sends regular 17 as well. -======= ->>>>>>> master +======= +>>>>>>> master } catch (Exception ex) { From 549728b5105c874606da78139f2822145b7eca00 Mon Sep 17 00:00:00 2001 From: Shank Date: Sat, 4 Jun 2011 22:28:13 -0600 Subject: [PATCH 09/20] Added DistributionAgent to configuration file. Default is facepunch. Change it to terraria-online for cheat removal. --- TShockAPI/Commands.cs | 13 +++++++++---- TShockAPI/ConfigFile.cs | 1 + TShockAPI/ConfigurationManager.cs | 5 ++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 443c99d6..f0821396 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -44,14 +44,11 @@ namespace TShockAPI TShock.admincommandList.Add("tp", new CommandDelegate(TP)); TShock.admincommandList.Add("tphere", new CommandDelegate(TPHere)); TShock.admincommandList.Add("spawnmob", new CommandDelegate(SpawnMob)); - TShock.admincommandList.Add("item", new CommandDelegate(Item)); - TShock.admincommandList.Add("give", new CommandDelegate(Give)); - TShock.admincommandList.Add("heal", new CommandDelegate(Heal)); TShock.admincommandList.Add("butcher", new CommandDelegate(Butcher)); TShock.admincommandList.Add("maxspawns", new CommandDelegate(MaxSpawns)); TShock.admincommandList.Add("spawnrate", new CommandDelegate(SpawnRate)); TShock.admincommandList.Add("time", new CommandDelegate(Time)); - TShock.admincommandList.Add("kill", new CommandDelegate(Kill)); + TShock.admincommandList.Add("help", new CommandDelegate(Help)); TShock.admincommandList.Add("slap", new CommandDelegate(Slap)); TShock.admincommandList.Add("off-nosave", new CommandDelegate(OffNoSave)); @@ -59,6 +56,14 @@ namespace TShockAPI TShock.admincommandList.Add("debug-config", new CommandDelegate(DebugConfiguration)); TShock.commandList.Add("help", new CommandDelegate(Help)); TShock.commandList.Add("kill", new CommandDelegate(Kill)); + if (ConfigurationManager.distributationAgent != "terraria-online") + { + TShock.admincommandList.Add("kill", new CommandDelegate(Kill)); + TShock.admincommandList.Add("item", new CommandDelegate(Item)); + TShock.admincommandList.Add("give", new CommandDelegate(Give)); + TShock.admincommandList.Add("heal", new CommandDelegate(Heal)); + + } } #region Command Methods diff --git a/TShockAPI/ConfigFile.cs b/TShockAPI/ConfigFile.cs index 868bcb2b..3cc9ebc9 100644 --- a/TShockAPI/ConfigFile.cs +++ b/TShockAPI/ConfigFile.cs @@ -25,5 +25,6 @@ namespace TShockAPI public bool KickExplosives = true; public bool SpawnProtection = true; public int SpawnProtectionRadius = 5; + public string DistributationAgent = "facepunch"; } } diff --git a/TShockAPI/ConfigurationManager.cs b/TShockAPI/ConfigurationManager.cs index dc792931..5090e0e9 100644 --- a/TShockAPI/ConfigurationManager.cs +++ b/TShockAPI/ConfigurationManager.cs @@ -31,7 +31,7 @@ namespace TShockAPI public static bool kickBoom = true; public static bool spawnProtect = true; public static int spawnProtectRadius = 5; - public static ConfigFile config = null; + public static string distributationAgent = "facepunch"; public enum NPCList : int { @@ -46,8 +46,6 @@ namespace TShockAPI ConfigFile cfg = JsonConvert.DeserializeObject(tr.ReadToEnd()); tr.Close(); - config = cfg; - invasionMultiplier = cfg.InvasionMultiplier; defaultMaxSpawns = cfg.DefaultMaximumSpawns; defaultSpawnRate = cfg.DefaultSpawnRate; @@ -65,6 +63,7 @@ namespace TShockAPI kickBoom = cfg.KickExplosives; spawnProtect = cfg.SpawnProtection; spawnProtectRadius = cfg.SpawnProtectionRadius; + distributationAgent = cfg.DistributationAgent; Terraria.NPC.maxSpawns = defaultMaxSpawns; Terraria.NPC.defaultSpawnRate = defaultSpawnRate; } From 422d2cfdb3ecfd27b8c89430bb2f23d9339ddd3e Mon Sep 17 00:00:00 2001 From: Deathmax Date: Sun, 5 Jun 2011 13:14:58 +0800 Subject: [PATCH 10/20] Added some extra logging when kicking for cheating/griefing. --- TShockAPI/TShock.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 9e283a61..d0cb4a8a 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -252,8 +252,8 @@ namespace TShockAPI if (maxLife > Main.player[ply].statLifeMax + 20 || life > maxLife) if (players[ply].syncHP) { - if (maxLife > Main.player[ply].statLifeMax + 20 || life > maxLife) - Tools.HandleCheater(ply); + Tools.HandleCheater(ply); + Log.Info(Tools.FindPlayer(ply) + " had increased max life by more than 20 or increased life more than max"); } else players[ply].syncHP = true; @@ -271,8 +271,8 @@ namespace TShockAPI if (maxmana > Main.player[ply].statManaMax + 20 || mana > maxmana) if (players[ply].syncMP) { - if (maxmana > Main.player[ply].statManaMax + 20 || mana > maxmana) - Tools.HandleCheater(ply); + Tools.HandleCheater(ply); + Log.Info(Tools.FindPlayer(ply) + " had increased max mana by more than 20 or increased mana more than max"); } else players[ply].syncMP = true; @@ -287,6 +287,7 @@ namespace TShockAPI if (e.Msg.whoAmI != ply) { //fuck you faggot + Log.Info(Tools.FindPlayer(e.Msg.whoAmI) + " was kicked for trying to fake chat as someone else."); Tools.HandleCheater(ply); } } @@ -345,6 +346,7 @@ namespace TShockAPI if (id != e.Msg.whoAmI) { Tools.HandleGriefer(e.Msg.whoAmI); + Log.Info(Tools.FindPlayer(e.Msg.whoAmI) + " was kicked for trying to execute KillMe on someone else."); e.Handled = true; } } From 8d375506b439f11d9b79d9ade71341253cb44e8d Mon Sep 17 00:00:00 2001 From: Deathmax Date: Sun, 5 Jun 2011 13:21:10 +0800 Subject: [PATCH 11/20] Fail auto-merge, fixed. --- TShockAPI/TShock.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index f1852ed0..7d3769c4 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -377,11 +377,8 @@ namespace TShockAPI } } } -<<<<<<< HEAD else if (e.MsgID == 0x22) // Client only KillTile e.Handled = true; // Client only uses it for chests, but sends regular 17 as well. -======= ->>>>>>> master } catch (Exception ex) { From 5b655f00de17a1e85679e39d940bacbba3930e6d Mon Sep 17 00:00:00 2001 From: Deathmax Date: Sun, 5 Jun 2011 13:32:55 +0800 Subject: [PATCH 12/20] Added broadcast for /ban. (thanks rjhazelwood) Changed broadcast for /kick as it now takes partial matches. --- TShockAPI/Commands.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index f0821396..ea4c2fba 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -105,7 +105,7 @@ namespace TShockAPI if (!TShock.players[Tools.FindPlayer(plStr)].IsAdmin()) { Tools.Kick(Tools.FindPlayer(plStr), "You were kicked."); - Tools.Broadcast(plStr + " was kicked by " + Tools.FindPlayer(ply)); + Tools.Broadcast(Tools.FindPlayer(Tools.FindPlayer(plStr)) + " was kicked by " + Tools.FindPlayer(ply)); } else Tools.SendMessage(ply, "You can't kick another admin!", new float[] { 255f, 0f, 0f }); @@ -126,6 +126,7 @@ namespace TShockAPI { FileTools.WriteBan(Tools.FindPlayer(plStr)); Tools.Kick(Tools.FindPlayer(plStr), "You were banned."); + Tools.Broadcast(Tools.FindPlayer(ply) + " banned " + Tools.FindPlayer(Tools.FindPlayer(plStr)) + "!"); } else Tools.SendMessage(ply, "You can't ban another admin!", new float[] { 255f, 0f, 0f }); From 2a2fbe62d526b228fde2039bbbcabf1afa96c6c8 Mon Sep 17 00:00:00 2001 From: Deathmax Date: Sun, 5 Jun 2011 13:49:10 +0800 Subject: [PATCH 13/20] . --- TShockAPI/Commands.cs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index ea4c2fba..91e9e712 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -100,12 +100,13 @@ namespace TShockAPI { string plStr = args.Message.Remove(0, 5).Trim(); int ply = args.PlayerID; - if (!(Tools.FindPlayer(plStr) == -1 || Tools.FindPlayer(plStr) == -2 || plStr == "")) + int player = Tools.FindPlayer(plStr); + if (!(player == -1 || player == -2 || plStr == "")) { - if (!TShock.players[Tools.FindPlayer(plStr)].IsAdmin()) + if (!TShock.players[player].IsAdmin()) { - Tools.Kick(Tools.FindPlayer(plStr), "You were kicked."); - Tools.Broadcast(Tools.FindPlayer(Tools.FindPlayer(plStr)) + " was kicked by " + Tools.FindPlayer(ply)); + Tools.Kick(player, "You were kicked."); + Tools.Broadcast(Tools.FindPlayer(player) + " was kicked by " + Tools.FindPlayer(ply)); } else Tools.SendMessage(ply, "You can't kick another admin!", new float[] { 255f, 0f, 0f }); @@ -120,13 +121,14 @@ namespace TShockAPI { string plStr = args.Message.Remove(0, 4).Trim(); int ply = args.PlayerID; - if (!(Tools.FindPlayer(plStr) == -1 || Tools.FindPlayer(plStr) == -2 || plStr == "")) + int player = Tools.FindPlayer(plStr); + if (!(player == -1 || player == -2 || plStr == "")) { - if (!TShock.players[Tools.FindPlayer(plStr)].IsAdmin()) + if (!TShock.players[player].IsAdmin()) { - FileTools.WriteBan(Tools.FindPlayer(plStr)); - Tools.Kick(Tools.FindPlayer(plStr), "You were banned."); - Tools.Broadcast(Tools.FindPlayer(ply) + " banned " + Tools.FindPlayer(Tools.FindPlayer(plStr)) + "!"); + FileTools.WriteBan(player); + Tools.Kick(player, "You were banned."); + Tools.Broadcast(Tools.FindPlayer(ply) + " banned " + Tools.FindPlayer(player) + "!"); } else Tools.SendMessage(ply, "You can't ban another admin!", new float[] { 255f, 0f, 0f }); From 39edac96b05daa0521bcf62b79fbb3c218e186f6 Mon Sep 17 00:00:00 2001 From: Deathmax Date: Sun, 5 Jun 2011 14:16:58 +0800 Subject: [PATCH 14/20] Kill tile abuse now reverts the tiles. Water acts glitchy (as if there was no tiles) Things like trees and doors are not reverted --- TShockAPI/TSPlayer.cs | 1 + TShockAPI/TShock.cs | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 60103e5b..7980fe16 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -8,6 +8,7 @@ namespace TShockAPI public class TSPlayer { public uint tileThreshold; + public Dictionary tilesDestroyed = new Dictionary(); public bool syncHP = false; public bool syncMP = false; diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 7d3769c4..046a4ee0 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -200,7 +200,10 @@ namespace TShockAPI } if (type == 0 && BlacklistTiles[Main.tile[x, y].type] && Main.player[e.Msg.whoAmI].active) + { players[e.Msg.whoAmI].tileThreshold++; + players[e.Msg.whoAmI].tilesDestroyed.Add(new Position((float)x, (float)y), Main.tile[x, y]); + } } return; } @@ -510,6 +513,7 @@ namespace TShockAPI FileTools.WriteGrief((int)i); Tools.Kick((int)i, "Kill tile abuse detected."); Tools.Broadcast(Main.player[i].name + " was " + (ConfigurationManager.banTnt ? "banned" : "kicked") + " for kill tile abuse."); + RevertKillTile((int)i); } } players[i].tileThreshold = 0; @@ -733,5 +737,25 @@ namespace TShockAPI else return true; } + + public class Position + { + public float X; + public float Y; + public Position(float x, float y) { X = x; Y = y; } + } + + public static void RevertKillTile(int ply) + { + Tile[] tiles = new Tile[players[ply].tilesDestroyed.Count]; + players[ply].tilesDestroyed.Values.CopyTo(tiles, 0); + Position[] positions = new Position[players[ply].tilesDestroyed.Count]; + players[ply].tilesDestroyed.Keys.CopyTo(positions, 0); + for (int i = (players[ply].tilesDestroyed.Count - 1); i >= 0; i--) + { + Main.tile[(int)positions[i].X, (int)positions[i].Y] = tiles[i]; + NetMessage.SendData(17, -1, -1, "", 1, positions[i].X, positions[i].Y, (float)0); + } + } } } \ No newline at end of file From 974dbc242406d5f7cbf7ea69b0e46dc0180db7b7 Mon Sep 17 00:00:00 2001 From: Deathmax Date: Sun, 5 Jun 2011 14:23:32 +0800 Subject: [PATCH 15/20] Forgot to clear the dictionary after each check. We don't want it revert ALL changes do we. --- TShockAPI/TShock.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 046a4ee0..66195597 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -517,10 +517,12 @@ namespace TShockAPI } } players[i].tileThreshold = 0; + players[i].tilesDestroyed.Clear(); } else if (players[i].tileThreshold > 0) { players[i].tileThreshold = 0; + players[i].tilesDestroyed.Clear(); } } } From ae42278f1689ce426db5f2845a0687b6004b48a1 Mon Sep 17 00:00:00 2001 From: Deathmax Date: Sun, 5 Jun 2011 16:33:45 +0800 Subject: [PATCH 16/20] test fix for teleport. --- TShockAPI/TShock.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 66195597..8fd41d0f 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -570,17 +570,22 @@ namespace TShockAPI public static void Teleport(int ply, int x, int y) { - Main.player[ply].velocity = new Vector2(0, 0); + /*Main.player[ply].velocity = new Vector2(0, 0); NetMessage.SendData(0x0d, -1, -1, "", ply); Main.player[ply].position.X = x; Main.player[ply].position.Y = y - 0x2a; NetMessage.SendData(0x0d, -1, -1, "", ply); - UpdatePlayers(); + UpdatePlayers();*/ + Main.player[ply].position.X = (float)x; + Main.player[ply].position.Y = (float)y; + NetMessage.SendData(0x0d, -1, ply, "", ply); + NetMessage.SendData(0x0d, -1, -1, "", ply); + NetMessage.syncPlayers(); } public static void Teleport(int ply, float x, float y) { - Main.player[ply].position.X = x; + /*Main.player[ply].position.X = x; Main.player[ply].position.Y = y - 0x2a; NetMessage.SendData(0x14, -1, -1, "", 10, x, y); NetMessage.SendData(0x0d, -1, -1, "", ply); @@ -591,7 +596,12 @@ namespace TShockAPI NetMessage.SendData(0xC, -1, -1, "", ply); Main.player[ply].SpawnX = oldx; Main.player[ply].SpawnY = oldy; - UpdatePlayers(); + UpdatePlayers();*/ + Main.player[ply].position.X = x; + Main.player[ply].position.Y = y; + NetMessage.SendData(0x0d, -1, ply, "", ply); + NetMessage.SendData(0x0d, -1, -1, "", ply); + NetMessage.syncPlayers(); } public static void StartInvasion() From 9a68676392598f5fb5d7673f41017e4b1087a825 Mon Sep 17 00:00:00 2001 From: Shank Date: Sun, 5 Jun 2011 03:23:28 -0600 Subject: [PATCH 17/20] Added /playing --- TShockAPI/Commands.cs | 8 +++++++- TShockAPI/TShock.cs | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 91e9e712..2ebd5f02 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -48,14 +48,15 @@ namespace TShockAPI TShock.admincommandList.Add("maxspawns", new CommandDelegate(MaxSpawns)); TShock.admincommandList.Add("spawnrate", new CommandDelegate(SpawnRate)); TShock.admincommandList.Add("time", new CommandDelegate(Time)); - TShock.admincommandList.Add("help", new CommandDelegate(Help)); TShock.admincommandList.Add("slap", new CommandDelegate(Slap)); TShock.admincommandList.Add("off-nosave", new CommandDelegate(OffNoSave)); TShock.admincommandList.Add("protectspawn", new CommandDelegate(ProtectSpawn)); TShock.admincommandList.Add("debug-config", new CommandDelegate(DebugConfiguration)); + TShock.admincommandList.Add("playing", new CommandDelegate(Playing)); TShock.commandList.Add("help", new CommandDelegate(Help)); TShock.commandList.Add("kill", new CommandDelegate(Kill)); + TShock.commandList.Add("playing", new CommandDelegate(Playing)); if (ConfigurationManager.distributationAgent != "terraria-online") { TShock.admincommandList.Add("kill", new CommandDelegate(Kill)); @@ -68,6 +69,11 @@ namespace TShockAPI #region Command Methods + public static void Playing(CommandArgs args) + { + Tools.SendMessage(args.PlayerID, Tools.GetPlayers()); + } + public static void DebugConfiguration(CommandArgs args) { int ply = args.PlayerID; diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 8fd41d0f..74a6c450 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -17,7 +17,7 @@ namespace TShockAPI public static Version VersionNum = new Version(1, 7, 0, 0); - public static string VersionCodename = "Bugless Beast"; + public static string VersionCodename = "Facepunch"; public static bool shownVersion = false; From 30e46173c2aed5bdd0a1fcbf3d3e6a2ec8a55295 Mon Sep 17 00:00:00 2001 From: Deathmax Date: Sun, 5 Jun 2011 17:23:52 +0800 Subject: [PATCH 18/20] Log player inventory flags. --- TShockAPI/TShock.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 8fd41d0f..1538c36c 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -734,7 +734,10 @@ namespace TShockAPI for (int i = 0; i < 44; i++) { if (Main.player[plr].inventory[i].stack > Main.player[plr].inventory[i].maxStack) + { + Log.Info(Tools.FindPlayer(plr) + " had " + Main.player[plr].inventory[i].stack.ToString() + " of " + Main.player[plr].inventory[i].name + " which has a max stack of " + Main.player[plr].inventory[i].maxStack.ToString()); return true; + } } return false; } From 436b50f26e78d24c5b2735652578c8925f6d2edf Mon Sep 17 00:00:00 2001 From: Deathmax Date: Sun, 5 Jun 2011 17:27:18 +0800 Subject: [PATCH 19/20] some checks for tp --- TShockAPI/Commands.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 91e9e712..49bc8598 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -268,7 +268,7 @@ namespace TShockAPI { int ply = args.PlayerID; string player = args.Message.Remove(0, 3).Trim(); - if (Tools.FindPlayer(player) != -1 && player != "") + if (Tools.FindPlayer(player) != -1 && Tools.FindPlayer(player) != -2 && player != "") { TShock.Teleport(ply, Main.player[Tools.FindPlayer(player)].position.X, Main.player[Tools.FindPlayer(player)].position.Y); Tools.SendMessage(ply, "Teleported to " + player); @@ -281,7 +281,7 @@ namespace TShockAPI { int ply = args.PlayerID; string player = args.Message.Remove(0, 7).Trim(); - if (Tools.FindPlayer(player) != -1 && player != "") + if (Tools.FindPlayer(player) != -1 && Tools.FindPlayer(player) != -2 && player != "") { TShock.Teleport(Tools.FindPlayer(player), Main.player[ply].position.X, Main.player[ply].position.Y); Tools.SendMessage(Tools.FindPlayer(player), "You were teleported to " + Tools.FindPlayer(ply) + "."); From c7d69f42fd7aa902ac90555998c714ae7f3b74a0 Mon Sep 17 00:00:00 2001 From: Shank Date: Sun, 5 Jun 2011 03:28:48 -0600 Subject: [PATCH 20/20] Names are limited to 32 characters. --- TShockAPI/Commands.cs | 6 +++--- TShockAPI/TShock.cs | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 2ebd5f02..05e03e96 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -95,9 +95,9 @@ namespace TShockAPI Tools.SendMessage(ply, lineTwo, new float[] { 255f, 255f, 0f }); string lineThree = ""; lineThree += "InvMultiplier : " + ConfigurationManager.invasionMultiplier + ", "; - lineThree += "SpawnProtect : " + ConfigurationManager.spawnProtect + ", "; - lineThree += "SpawnProtectR : " + ConfigurationManager.spawnProtectRadius + ", "; - lineThree += "DefaultMaxSpawns : " + ConfigurationManager.defaultMaxSpawns + ", "; + lineThree += "ProtectS : " + ConfigurationManager.spawnProtect + ", "; + lineThree += "ProtectR : " + ConfigurationManager.spawnProtectRadius + ", "; + lineThree += "DMS : " + ConfigurationManager.defaultMaxSpawns + ", "; lineThree += "SpawnRate: " + ConfigurationManager.defaultSpawnRate + ", "; Tools.SendMessage(ply, lineThree, new float[] { 255f, 255f, 0f}); } diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 74a6c450..a10ab88b 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -459,6 +459,11 @@ namespace TShockAPI { if (Main.netMode != 2) { return; } string ip = Tools.GetRealIP((Convert.ToString(Netplay.serverSock[ply].tcpClient.Client.RemoteEndPoint))); + if (Tools.FindPlayer(ply).Length > 32) + { + Tools.Kick(ply, "Your name was too long."); + Tools.Broadcast(ip + " was kicked because their name exceeded 32 characters."); + } if (FileTools.CheckBanned(ip)) { Tools.Kick(ply, "You are banned."); @@ -733,7 +738,7 @@ namespace TShockAPI { for (int i = 0; i < 44; i++) { - if (Main.player[plr].inventory[i].stack > Main.player[plr].inventory[i].maxStack) + if (Main.player[plr].inventory[i].stack > 255) return true; } return false;