private static bool HandleSendTileSquare(GetDataHandlerArgs args) { var size = args.Data.ReadInt16(); var tileX = args.Data.ReadInt16(); var tileY = args.Data.ReadInt16(); bool isTrapdoor = false; if (Main.tile[tileX, tileY].type == TileID.TrapdoorClosed || Main.tile[tileX, tileY].type == TileID.TrapdoorOpen) { isTrapdoor = true; } if (args.Player.Group.HasPermission(Permissions.allowclientsideworldedit) && !isTrapdoor) return false; if (OnSendTileSquare(size, tileX, tileY)) return true; if (size > 5) return true; if ((DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000) { args.Player.SendTileSquare(tileX, tileY, size); return true; } if (TShock.CheckIgnores(args.Player)) { args.Player.SendTileSquare(tileX, tileY, size); return true; } try { var tiles = new NetTile[size, size]; for (int x = 0; x < size; x++) { for (int y = 0; y < size; y++) { tiles[x, y] = new NetTile(args.Data); } } bool changed = false; for (int x = 0; x < size; x++) { int realx = tileX + x; if (realx < 0 || realx >= Main.maxTilesX) continue; for (int y = 0; y < size; y++) { int realy = tileY + y; if (realy < 0 || realy >= Main.maxTilesY) continue; var tile = Main.tile[realx, realy]; var newtile = tiles[x, y]; if (TShock.CheckTilePermission(args.Player, realx, realy) || TShock.CheckRangePermission(args.Player, realx, realy)) { continue; } // Orientable tiles if (tile.type == newtile.Type && orientableTiles.Contains(tile.type)) { Main.tile[realx, realy].frameX = newtile.FrameX; Main.tile[realx, realy].frameY = newtile.FrameY; changed = true; } // Landmine if (tile.type == TileID.LandMine && !newtile.Active) { Main.tile[realx, realy].active(false); changed = true; } if (tile.active() && newtile.Active) { // Grass <-> Grass if (((tile.type == 2 || tile.type == 23 || tile.type == 60 || tile.type == 70 || tile.type == 109 || tile.type == 199) && (newtile.Type == 2 || newtile.Type == 23 || newtile.Type == 60 || newtile.Type == 70 || newtile.Type == 109 || newtile.Type == 199)) || // Dirt <-> Dirt ((tile.type == 0 || tile.type == 59) && (newtile.Type == 0 || newtile.Type == 59)) || // Ice <-> Ice ((tile.type == 161 || tile.type == 163 || tile.type == 164 || tile.type == 200) && (newtile.Type == 161 || newtile.Type == 163 || newtile.Type == 164 || newtile.Type == 200)) || // Stone <-> Stone ((tile.type == 1 || tile.type == 25 || tile.type == 117 || tile.type == 203 || Main.tileMoss[tile.type]) && (newtile.Type == 1 || newtile.Type == 25 || newtile.Type == 117 || newtile.Type == 203 || Main.tileMoss[newtile.Type])) || // Sand <-> Sand ((tile.type == 53 || tile.type == 112 || tile.type == 116 || tile.type == 234) && (newtile.Type == 53 || newtile.Type == 112 || newtile.Type == 116 || newtile.Type == 234))) { Main.tile[realx, realy].type = newtile.Type; changed = true; } } // Stone wall <-> Stone wall if (((tile.wall == 1 || tile.wall == 3 || tile.wall == 28 || tile.wall == 83) && (newtile.Wall == 1 || newtile.Wall == 3 || newtile.Wall == 28 || newtile.Wall == 83)) || // Leaf wall <-> Leaf wall (((tile.wall >= 63 && tile.wall <= 70) || tile.wall == 81) && ((newtile.Wall >= 63 && newtile.Wall <= 70) || newtile.Wall == 81))) { Main.tile[realx, realy].wall = newtile.Wall; changed = true; } } } if (changed) { TSPlayer.All.SendTileSquare(tileX, tileY, size + 1); WorldGen.RangeFrame(tileX, tileY, tileX + size, tileY + size); } else { args.Player.SendTileSquare(tileX, tileY, size); } } catch { args.Player.SendTileSquare(tileX, tileY, size); } return true; }
private static bool HandleSendTileSquare(GetDataHandlerArgs args) { short size = args.Data.ReadInt16(); int tilex = args.Data.ReadInt32(); int tiley = args.Data.ReadInt32(); if (size > 5) return true; var tiles = new NetTile[size, size]; for (int x = 0; x < size; x++) { for (int y = 0; y < size; y++) { tiles[x, y] = new NetTile(args.Data); } } bool changed = false; for (int x = 0; x < size; x++) { int realx = tilex + x; if (realx < 0 || realx >= Main.maxTilesX) continue; for (int y = 0; y < size; y++) { int realy = tiley + y; if (realy < 0 || realy >= Main.maxTilesY) continue; var tile = Main.tile[realx, realy]; var newtile = tiles[x, y]; if (tile.type == 0x17 && newtile.Type == 0x2) { tile.type = 0x2; changed = true; } else if (tile.type == 0x19 && newtile.Type == 0x1) { tile.type = 0x1; changed = true; } else if ((tile.type == 0xF && newtile.Type == 0xF) || (tile.type == 0x4F && newtile.Type == 0x4F)) { tile.frameX = newtile.FrameX; tile.frameY = newtile.FrameY; changed = true; } } } if (changed) TSPlayer.All.SendTileSquare(tilex, tiley, 3); return true; }
private static bool HandleSendTileSquare(GetDataHandlerArgs args) { var size = args.Data.ReadInt16(); var tileX = args.Data.ReadInt32(); var tileY = args.Data.ReadInt32(); if (size > 5) return true; if ((DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000) { args.Player.SendTileSquare(tileX, tileY, size); return true; } if (TShock.CheckIgnores(args.Player)) { args.Player.SendTileSquare(tileX, tileY); return true; } var tiles = new NetTile[size, size]; for (int x = 0; x < size; x++) { for (int y = 0; y < size; y++) { tiles[x, y] = new NetTile(args.Data); } } bool changed = false; for (int x = 0; x < size; x++) { int realx = tileX + x; if (realx < 0 || realx >= Main.maxTilesX) continue; for (int y = 0; y < size; y++) { int realy = tileY + y; if (realy < 0 || realy >= Main.maxTilesY) continue; var tile = Main.tile[realx, realy]; var newtile = tiles[x, y]; if(TShock.CheckTilePermission(args.Player, x, y)) { continue; } if(TShock.CheckRangePermission(args.Player, x, y)) { continue; } if ((tile.type == 128 && newtile.Type == 128) || (tile.type == 105 && newtile.Type == 105)) { if (TShock.Config.EnableInsecureTileFixes) { return false; } } if (tile.type == 0x17 && newtile.Type == 0x2) { tile.type = 0x2; changed = true; } else if (tile.type == 0x19 && newtile.Type == 0x1) { tile.type = 0x1; changed = true; } else if ((tile.type == 0xF && newtile.Type == 0xF) || (tile.type == 0x4F && newtile.Type == 0x4F)) { tile.frameX = newtile.FrameX; tile.frameY = newtile.FrameY; changed = true; } // Holy water/Unholy water else if (tile.type == 1 && newtile.Type == 117) { tile.type = 117; changed = true; } else if (tile.type == 1 && newtile.Type == 25) { tile.type = 25; changed = true; } else if (tile.type == 117 && newtile.Type == 25) { tile.type = 25; changed = true; } else if (tile.type == 25 && newtile.Type == 117) { tile.type = 117; changed = true; } else if (tile.type == 2 && newtile.Type == 23) { tile.type = 23; changed = true; } else if (tile.type == 2 && newtile.Type == 109) { tile.type = 109; changed = true; } else if (tile.type == 23 && newtile.Type == 109) { tile.type = 109; changed = true; } else if (tile.type == 109 && newtile.Type == 23) { tile.type = 23; changed = true; } else if (tile.type == 23 && newtile.Type == 109) { tile.type = 109; changed = true; } else if (tile.type == 53 && newtile.Type == 116) { tile.type = 116; changed = true; } else if (tile.type == 53 && newtile.Type == 112) { tile.type = 112; changed = true; } else if (tile.type == 112 && newtile.Type == 116) { tile.type = 116; changed = true; } else if (tile.type == 116 && newtile.Type == 112) { tile.type = 112; changed = true; } else if (tile.type == 112 && newtile.Type == 53) { tile.type = 53; changed = true; } else if (tile.type == 109 && newtile.Type == 2) { tile.type = 2; changed = true; } else if (tile.type == 116 && newtile.Type == 53) { tile.type = 53; changed = true; } else if (tile.type == 117 && newtile.Type == 1) { tile.type = 1; changed = true; } } } if (changed) { TSPlayer.All.SendTileSquare(tileX, tileY, size); WorldGen.RangeFrame(tileX, tileY, tileX + size, tileY + size); } else { args.Player.SendTileSquare(tileX, tileY, size); } return true; }