From ea80dd48c3bdcd4d905b5303637d5c3b68391916 Mon Sep 17 00:00:00 2001 From: ricky Date: Wed, 15 Jun 2011 00:39:39 +1000 Subject: [PATCH] Using Tile Send Square message instead of multiple Tile Send Section message to revert player changes. --- TShockAPI/TShock.cs | 58 +++++++++++++-------------------------------- 1 file changed, 16 insertions(+), 42 deletions(-) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 37379744..4f3dc101 100755 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -342,31 +342,28 @@ namespace TShockAPI )); return Tools.HandleGriefer(e.Msg.whoAmI, "Placing impossible to place blocks."); } - } - if (type == 0 || type == 1 || type == 2 || type == 3) + } + if (ConfigurationManager.disableBuild) { - if (ConfigurationManager.disableBuild) + if (!players[e.Msg.whoAmI].group.HasPermission("editspawn")) { - if (!players[e.Msg.whoAmI].group.HasPermission("editspawn")) + Tools.SendMessage(e.Msg.whoAmI, "World protected from changes.", Color.Red); + RevertPlayerChanges(e.Msg.whoAmI, type, x, y); + return true; + } + } + if (ConfigurationManager.spawnProtect) + { + if (!players[e.Msg.whoAmI].group.HasPermission("editspawn")) + { + var flag = CheckSpawn(x, y); + if (flag) { - Tools.SendMessage(e.Msg.whoAmI, "World protected from changes.", Color.Red); + Tools.SendMessage(e.Msg.whoAmI, "Spawn protected from changes.", Color.Red); RevertPlayerChanges(e.Msg.whoAmI, type, x, y); return true; } } - if (ConfigurationManager.spawnProtect) - { - if (!players[e.Msg.whoAmI].group.HasPermission("editspawn")) - { - var flag = CheckSpawn(x, y); - if (flag) - { - Tools.SendMessage(e.Msg.whoAmI, "Spawn protected from changes.", Color.Red); - RevertPlayerChanges(e.Msg.whoAmI, type, x, y); - return true; - } - } - } } if (type == 0 && BlacklistTiles[Main.tile[x, y].type] && Main.player[e.Msg.whoAmI].active) @@ -380,30 +377,7 @@ namespace TShockAPI private static void RevertPlayerChanges(int player, byte action, int x, int y) { - int revertAction = 0; - float revertType = 0f; - switch (action) - { - case 0: - revertAction = 1; - revertType = Main.tile[x, y].type; - break; - case 1: - revertAction = 0; - revertType = 0f; - break; - case 2: - revertAction = 3; - revertType = Main.tile[x, y].wall; - break; - case 3: - revertAction = 2; - revertType = 0f; - break; - } - NetMessage.SendData(17, player, -1, "", revertAction, x, y, revertType); - for (int j = y - 2; j <= (y + 2); j++) - NetMessage.SendData(10, player, -1, "", 5, (float)(x - 2), (float)j, 0f); + NetMessage.SendData(20, player, -1, "", 10, (float)(x - 5), (float)(y - 5), 0f); } bool HandleTogglePvp(MemoryStream data, GetDataEventArgs e)