From af3f03b38ee0bea40d190dca67157ed1ca12d964 Mon Sep 17 00:00:00 2001 From: Shank Date: Mon, 6 Jun 2011 17:39:50 -0600 Subject: [PATCH 1/6] Fixed PlayerDamage hole. Thanks to Minic --- TShockAPI/TShock.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index b0a0812b..3a044197 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -398,7 +398,7 @@ namespace TShockAPI } } } - else if (e.MsgID == 0x1b) //PlayerDamage + else if (e.MsgID == 0x1a) //PlayerDamage { using (var br = new BinaryReader(new MemoryStream(e.Msg.readBuffer, e.Index, e.Length))) { From a7e912c9f42f4d01d88f99b9c58aae8825816e7e Mon Sep 17 00:00:00 2001 From: high Date: Mon, 6 Jun 2011 19:55:04 -0400 Subject: [PATCH 2/6] Fixed impossible placing --- TShockAPI/TSPlayer.cs | 60 +++++++++++++++++++++---------------------- TShockAPI/TShock.cs | 36 +++++++++++++++----------- 2 files changed, 50 insertions(+), 46 deletions(-) diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 679bc559..18416a60 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -1,32 +1,30 @@ -using System.Collections.Generic; -using Terraria; - -namespace TShockAPI -{ - public class TSPlayer - { - public uint tileThreshold; - public Dictionary tilesDestroyed = new Dictionary(); - public bool syncHP; - public bool syncMP; - public Group group; - public int lavaCount = 0; - public int waterCount = 0; - private int player; - - public TSPlayer(int ply) - { - player = ply; - } - - public Player GetPlayer() - { - return Main.player[player]; - } - - public int GetPlayerID() - { - return player; - } - } +using System.Collections.Generic; +using Terraria; + +namespace TShockAPI +{ + public class TSPlayer + { + public uint tileThreshold; + public Dictionary tilesDestroyed = new Dictionary(); + public bool syncHP; + public bool syncMP; + public Group group; + private int player; + + public TSPlayer(int ply) + { + player = ply; + } + + public Player GetPlayer() + { + return Main.player[player]; + } + + public int GetPlayerID() + { + return player; + } + } } \ No newline at end of file diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 3a044197..6bc85336 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -209,15 +209,15 @@ namespace TShockAPI byte typetile = br.ReadByte(); if (type == 1 || type == 3) { - int plyX = Math.Abs((int) Main.player[e.Msg.whoAmI].position.X/16); - int plyY = Math.Abs((int) Main.player[e.Msg.whoAmI].position.Y/16); - int tileX = Math.Abs(x/16); - int tileY = Math.Abs(y/16); + int plyX = Math.Abs((int)Main.player[e.Msg.whoAmI].position.X / 16); + int plyY = Math.Abs((int)Main.player[e.Msg.whoAmI].position.Y / 16); + int tileX = Math.Abs(x / 16); + int tileY = Math.Abs(y / 16); - if ((plyX - tileX > 6) || (plyY - tileY > 6)) + if ((Math.Abs(plyX - tileX) > 6) || (Math.Abs(plyY - tileY) > 6)) TShock.Ban(e.Msg.whoAmI, "Placing impossible to place blocks."); - Tools.Broadcast(Main.player[e.Msg.whoAmI].name + " was banned for placing impossible to place blocks."); - e.Handled = true; + Tools.Broadcast(Main.player[e.Msg.whoAmI].name + " was banned for placing impossible to place blocks."); + e.Handled = true; } if (type == 0 || type == 1) @@ -420,33 +420,39 @@ namespace TShockAPI byte liquid = br.ReadByte(); bool lava = br.ReadBoolean(); - int plyX = Math.Abs((int)Main.player[e.Msg.whoAmI].position.X/16); - int plyY = Math.Abs((int)Main.player[e.Msg.whoAmI].position.Y/16); + int plyX = Math.Abs((int)Main.player[e.Msg.whoAmI].position.X / 16); + int plyY = Math.Abs((int)Main.player[e.Msg.whoAmI].position.Y / 16); int tileX = Math.Abs(x); int tileY = Math.Abs(y); + int lavacount = 0; + int watercount = 0; + for (int i = 0; i < 44; i++) { if (Main.player[e.Msg.whoAmI].inventory[i].name == "Lava Bucket") - TShock.players[e.Msg.whoAmI].lavaCount++; + lavacount++; else if (Main.player[e.Msg.whoAmI].inventory[i].name == "Water Bucket") - TShock.players[e.Msg.whoAmI].waterCount++; + watercount++; } - if (lava && TShock.players[e.Msg.whoAmI].lavaCount <= 0) + if (lava && lavacount <= 0) { TShock.Ban(e.Msg.whoAmI, "Placing lava they didn't have."); e.Handled = true; } - else if (!lava && TShock.players[e.Msg.whoAmI].waterCount <= 0) + else if (!lava && watercount <= 0) { TShock.Ban(e.Msg.whoAmI, "Placing water they didn't have."); e.Handled = true; } - if ((plyX - tileX > 6) || (plyY - tileY > 6)) + if ((Math.Abs(plyX - tileX) > 6) || (Math.Abs(plyY - tileY) > 6)) + { TShock.Ban(e.Msg.whoAmI, "Placing impossible to place liquid."); - Tools.Broadcast(Main.player[e.Msg.whoAmI].name + " was banned for placing impossible to place liquid."); + Tools.Broadcast(Main.player[e.Msg.whoAmI].name + + " was banned for placing impossible to place liquid."); e.Handled = true; + } if (ConfigurationManager.spawnProtect) { From 9deb1e9a44c7b029cd070a9d0ed18d6069a3081f Mon Sep 17 00:00:00 2001 From: high Date: Mon, 6 Jun 2011 20:09:20 -0400 Subject: [PATCH 3/6] Shank forgot braces around a ban if statement --- TShockAPI/TShock.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 6bc85336..76235f08 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -215,9 +215,12 @@ namespace TShockAPI int tileY = Math.Abs(y / 16); if ((Math.Abs(plyX - tileX) > 6) || (Math.Abs(plyY - tileY) > 6)) + { TShock.Ban(e.Msg.whoAmI, "Placing impossible to place blocks."); - Tools.Broadcast(Main.player[e.Msg.whoAmI].name + " was banned for placing impossible to place blocks."); - e.Handled = true; + Tools.Broadcast(Main.player[e.Msg.whoAmI].name + + " was banned for placing impossible to place blocks."); + e.Handled = true; + } } if (type == 0 || type == 1) From df9e2bb423d23e695e18ab4348880fbcf27aafa1 Mon Sep 17 00:00:00 2001 From: Maverick Motherfucker Date: Mon, 6 Jun 2011 17:11:49 -0700 Subject: [PATCH 4/6] fixed kicking and banning, and removed a unused variable --- TShockAPI/ConfigurationManager.cs | 1 - TShockAPI/TShock.cs | 7 +++++-- TShockAPI/Tools.cs | 9 ++++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/TShockAPI/ConfigurationManager.cs b/TShockAPI/ConfigurationManager.cs index 93fa6fa7..2b06d766 100644 --- a/TShockAPI/ConfigurationManager.cs +++ b/TShockAPI/ConfigurationManager.cs @@ -17,7 +17,6 @@ namespace TShockAPI public static bool infiniteInvasion; public static bool permaPvp; public static int killCount; - public static bool startedInvasion; public static bool kickCheater = true; public static bool banCheater = true; public static bool kickGriefer = true; diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 6bc85336..7f28b468 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -840,8 +840,11 @@ namespace TShockAPI public static void Ban(int plr, string reason = "") { - Tools.Kick(plr, reason); - Bans.AddBan(Tools.GetPlayerIP(plr), Main.player[plr].name, reason); + if (!players[plr].group.HasPermission("immunetoban")) + { + Tools.Kick(plr,"Banned: " + reason); + Bans.AddBan(Tools.GetPlayerIP(plr), Main.player[plr].name, reason); + } } public class Position diff --git a/TShockAPI/Tools.cs b/TShockAPI/Tools.cs index 2a2bee95..513e3961 100644 --- a/TShockAPI/Tools.cs +++ b/TShockAPI/Tools.cs @@ -215,9 +215,12 @@ namespace TShockAPI /// string reason public static void Kick(int ply, string reason) { - string displayName = FindPlayer(ply).Equals("") ? GetPlayerIP(ply) : FindPlayer(ply); - NetMessage.SendData(0x2, ply, -1, reason, 0x0, 0f, 0f, 0f); - Log.Info("Kicked " + displayName + " for : " + reason); + if (!TShock.players[ply].group.HasPermission("immunetokick") || reason.Contains("Banned: ")) + { + string displayName = FindPlayer(ply).Equals("") ? GetPlayerIP(ply) : FindPlayer(ply); + NetMessage.SendData(0x2, ply, -1, reason, 0x0, 0f, 0f, 0f); + Log.Info("Kicked " + displayName + " for : " + reason); + } } /// From 114f5ff34bfb19e84efcc97ac8bf2cea61f33174 Mon Sep 17 00:00:00 2001 From: high Date: Mon, 6 Jun 2011 20:19:42 -0400 Subject: [PATCH 5/6] Shank was dividing the tilex and tiley by 16 --- TShockAPI/TShock.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 76235f08..ea282016 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -211,8 +211,8 @@ namespace TShockAPI { int plyX = Math.Abs((int)Main.player[e.Msg.whoAmI].position.X / 16); int plyY = Math.Abs((int)Main.player[e.Msg.whoAmI].position.Y / 16); - int tileX = Math.Abs(x / 16); - int tileY = Math.Abs(y / 16); + int tileX = Math.Abs(x); + int tileY = Math.Abs(y); if ((Math.Abs(plyX - tileX) > 6) || (Math.Abs(plyY - tileY) > 6)) { From cfc05e1663d203e038aa92a307db6ae1200f23fc Mon Sep 17 00:00:00 2001 From: high Date: Mon, 6 Jun 2011 20:24:21 -0400 Subject: [PATCH 6/6] Mav why did you remove ConfigurationManager.startedInvasion without removing its use. --- TShockAPI/TShock.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index f85aafd3..58b64efc 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -501,8 +501,7 @@ namespace TShockAPI Main.player[who].hostile = true; NetMessage.SendData(30, -1, -1, "", who); } - if (players[who].group.HasPermission("causeevents") && ConfigurationManager.infiniteInvasion && - !ConfigurationManager.startedInvasion) + if (players[who].group.HasPermission("causeevents") && ConfigurationManager.infiniteInvasion) { StartInvasion(); } @@ -845,7 +844,7 @@ namespace TShockAPI { if (!players[plr].group.HasPermission("immunetoban")) { - Tools.Kick(plr,"Banned: " + reason); + Tools.Kick(plr, "Banned: " + reason); Bans.AddBan(Tools.GetPlayerIP(plr), Main.player[plr].name, reason); } }