public static void LavaCheck(Func <Int32, Int32, ITile> TileRefs, ISandbox sandbox, int x, int y) { if (TileRefs == null) { TileRefs = TileCollection.ITileAt; } if ((TileRefs(x - 1, y).Liquid > 0 && !TileRefs(x - 1, y).Lava) || (TileRefs(x + 1, y).Liquid > 0 && !TileRefs(x + 1, y).Lava) || (TileRefs(x, y - 1).Liquid > 0 && !TileRefs(x, y - 1).Lava)) { int liq = 0; if (!TileRefs(x - 1, y).Lava) { liq += (int)TileRefs(x - 1, y).Liquid; TileRefs(x - 1, y).SetLiquid(0); } if (!TileRefs(x + 1, y).Lava) { liq += (int)TileRefs(x + 1, y).Liquid; TileRefs(x + 1, y).SetLiquid(0); } if (!TileRefs(x, y - 1).Lava) { liq += (int)TileRefs(x, y - 1).Liquid; TileRefs(x, y - 1).SetLiquid(0); } if (liq >= 32 && !TileRefs(x, y).Active) { TileRefs(x, y).SetLiquid(0); TileRefs(x, y).SetLava(false); WorldModify.PlaceTile(TileRefs, sandbox, x, y, 56, true, true, -1, 0); WorldModify.SquareTileFrame(TileRefs, sandbox, x, y, true); NetMessage.SendTileSquare(-1, x - 1, y - 1, 3); return; } } else if (TileRefs(x, y + 1).Liquid > 0 && !TileRefs(x, y + 1).Lava&& !TileRefs(x, y + 1).Active) { TileRefs(x, y).SetLiquid(0); TileRefs(x, y).SetLava(false); TileRefs(x, y + 1).SetLiquid(0); WorldModify.PlaceTile(TileRefs, sandbox, x, y + 1, 56, true, true, -1, 0); WorldModify.SquareTileFrame(TileRefs, sandbox, x, y + 1, true); NetMessage.SendTileSquare(-1, x - 1, y, 3); } }
public static void LavaCheck(int x, int y) { if ((Main.tile.At(x - 1, y).Liquid > 0 && !Main.tile.At(x - 1, y).Lava) || (Main.tile.At(x + 1, y).Liquid > 0 && !Main.tile.At(x + 1, y).Lava) || (Main.tile.At(x, y - 1).Liquid > 0 && !Main.tile.At(x, y - 1).Lava)) { int num = 0; if (!Main.tile.At(x - 1, y).Lava) { num += (int)Main.tile.At(x - 1, y).Liquid; Main.tile.At(x - 1, y).SetLiquid(0); } if (!Main.tile.At(x + 1, y).Lava) { num += (int)Main.tile.At(x + 1, y).Liquid; Main.tile.At(x + 1, y).SetLiquid(0); } if (!Main.tile.At(x, y - 1).Lava) { num += (int)Main.tile.At(x, y - 1).Liquid; Main.tile.At(x, y - 1).SetLiquid(0); } if (num >= 128 && !Main.tile.At(x, y).Active) { ClearLava(x, y); WorldModify.PlaceTile(x, y, 56, true, true, -1, 0); WorldModify.SquareTileFrame(x, y, true); NetMessage.SendTileSquare(-1, x - 1, y - 1, 3); return; } } else if (Main.tile.At(x, y + 1).Liquid > 0 && !Main.tile.At(x, y + 1).Lava&& !Main.tile.At(x, y + 1).Active) { ClearLava(x, y); WorldModify.PlaceTile(x, y + 1, 56, true, true, -1, 0); WorldModify.SquareTileFrame(x, y + 1, true); NetMessage.SendTileSquare(-1, x - 1, y, 3); } }
public override void Process(int whoAmI, byte[] readBuffer, int length, int num) { int x = BitConverter.ToInt32(readBuffer, num); num += 4; int y = BitConverter.ToInt32(readBuffer, num); num += 4; byte liquid = readBuffer[num++]; byte lavaFlag = readBuffer[num]++; var player = Main.players[whoAmI]; if (NetPlay.spamCheck) // dead code... { int centerX = (int)(player.Position.X + (float)(player.Width / 2)); int centerY = (int)(player.Position.Y + (float)(player.Height / 2)); int disperseDistance = 10; int left = centerX - disperseDistance; int right = centerX + disperseDistance; int top = centerY - disperseDistance; int bottom = centerY + disperseDistance; if (centerX < left || centerX > right || centerY < top || centerY > bottom) { NetMessage.BootPlayer(whoAmI, "Cheating attempt detected: Liquid spam"); return; } } var ctx = new HookContext { Connection = player.Connection, Player = player, Sender = player, }; var args = new HookArgs.LiquidFlowReceived { X = x, Y = y, Amount = liquid, Lava = lavaFlag == 1, }; HookPoints.LiquidFlowReceived.Invoke(ref ctx, ref args); if (ctx.CheckForKick()) { return; } if (ctx.Result == HookResult.IGNORE) { return; } if (ctx.Result == HookResult.RECTIFY) { var msg = NetMessage.PrepareThreadInstance(); msg.FlowLiquid(x, y); msg.Send(whoAmI); return; } TileRef tile = Main.tile.At(x, y); { tile.SetLiquid(liquid); tile.SetLava(lavaFlag == 1); WorldModify.SquareTileFrame(null, null, x, y, true); } }
public static void DelWater(int liquidIndex) { int x = Main.liquid[liquidIndex].x; int y = Main.liquid[liquidIndex].y; if (Main.tile.At(x, y).Liquid < 2) { Main.tile.At(x, y).SetLiquid(0); } else if (Main.tile.At(x, y).Liquid < 20) { if ((Main.tile.At(x - 1, y).Liquid < Main.tile.At(x, y).Liquid&& (!Main.tile.At(x - 1, y).Active || !Main.tileSolid[(int)Main.tile.At(x - 1, y).Type] || Main.tileSolidTop[(int)Main.tile.At(x - 1, y).Type])) || (Main.tile.At(x + 1, y).Liquid < Main.tile.At(x, y).Liquid&& (!Main.tile.At(x + 1, y).Active || !Main.tileSolid[(int)Main.tile.At(x + 1, y).Type] || Main.tileSolidTop[(int)Main.tile.At(x + 1, y).Type])) || (Main.tile.At(x, y + 1).Liquid < 255 && (!Main.tile.At(x, y + 1).Active || !Main.tileSolid[(int)Main.tile.At(x, y + 1).Type] || Main.tileSolidTop[(int)Main.tile.At(x, y + 1).Type]))) { Main.tile.At(x, y).SetLiquid(0); } } else if (Main.tile.At(x, y + 1).Liquid < 255 && (!Main.tile.At(x, y + 1).Active || !Main.tileSolid[(int)Main.tile.At(x, y + 1).Type] || Main.tileSolidTop[(int)Main.tile.At(x, y + 1).Type]) && !Liquid.stuck) { Main.liquid[liquidIndex].kill = 0; return; } if (Main.tile.At(x, y).Liquid < 250 && Main.tile.At(x, y - 1).Liquid > 0) { Liquid.AddWater(x, y - 1); } if (Main.tile.At(x, y).Liquid == 0) { Main.tile.At(x, y).SetLava(false); } else { if (Main.tile.At(x + 1, y).Liquid > 0 && Main.tile.At(x + 1, y + 1).Liquid < 250 && !Main.tile.At(x + 1, y + 1).Active) { Liquid.AddWater(x + 1, y); } if (Main.tile.At(x - 1, y).Liquid > 0 && Main.tile.At(x - 1, y + 1).Liquid < 250 && !Main.tile.At(x - 1, y + 1).Active) { Liquid.AddWater(x - 1, y); } if (Main.tile.At(x, y).Lava) { Liquid.LavaCheck(x, y); for (int i = x - 1; i <= x + 1; i++) { for (int j = y - 1; j <= y + 1; j++) { if (Main.tile.At(i, j).Active) { if (Main.tile.At(i, j).Type == 2 || Main.tile.At(i, j).Type == 23) { Main.tile.At(i, j).SetType(0); WorldModify.SquareTileFrame(i, j, true); NetMessage.SendTileSquare(-1, x, y, 3); } else if (Main.tile.At(i, j).Type == 60 || Main.tile.At(i, j).Type == 70) { Main.tile.At(i, j).SetType(59); WorldModify.SquareTileFrame(i, j, true); NetMessage.SendTileSquare(-1, x, y, 3); } } } } } } NetMessage.SendWater(x, y); Liquid.numLiquid--; Main.tile.At(Main.liquid[liquidIndex].x, Main.liquid[liquidIndex].y).SetCheckingLiquid(false); Main.liquid[liquidIndex].x = Main.liquid[Liquid.numLiquid].x; Main.liquid[liquidIndex].y = Main.liquid[Liquid.numLiquid].y; Main.liquid[liquidIndex].kill = Main.liquid[Liquid.numLiquid].kill; if (Main.tileAlch[(int)Main.tile.At(x, y).Type]) { WorldModify.CheckAlch(x, y); } }
public static void DelWater(Func <Int32, Int32, ITile> TileRefs, ISandbox sandbox, int id) { if (TileRefs == null) { TileRefs = TileCollection.ITileAt; } int x = Main.liquid[id].x; int y = Main.liquid[id].y; if (TileRefs(x, y).Liquid < 2) { TileRefs(x, y).SetLiquid(0); if (TileRefs(x - 1, y).Liquid < 2) { TileRefs(x - 1, y).SetLiquid(0); } if (TileRefs(x + 1, y).Liquid < 2) { TileRefs(x + 1, y).SetLiquid(0); } } else if (TileRefs(x, y).Liquid < 20) { if ((TileRefs(x - 1, y).Liquid < TileRefs(x, y).Liquid&& (!TileRefs(x - 1, y).Active || !Main.tileSolid[(int)TileRefs(x - 1, y).Type] || Main.tileSolidTop[(int)TileRefs(x - 1, y).Type])) || (TileRefs(x + 1, y).Liquid < TileRefs(x, y).Liquid&& (!TileRefs(x + 1, y).Active || !Main.tileSolid[(int)TileRefs(x + 1, y).Type] || Main.tileSolidTop[(int)TileRefs(x + 1, y).Type])) || (TileRefs(x, y + 1).Liquid < 255 && (!TileRefs(x, y + 1).Active || !Main.tileSolid[(int)TileRefs(x, y + 1).Type] || Main.tileSolidTop[(int)TileRefs(x, y + 1).Type]))) { TileRefs(x, y).SetLiquid(0); } } else if (TileRefs(x, y + 1).Liquid < 255 && (!TileRefs(x, y + 1).Active || !Main.tileSolid[(int)TileRefs(x, y + 1).Type] || Main.tileSolidTop[(int)TileRefs(x, y + 1).Type]) && !Liquid.stuck) { Main.liquid[id].kill = 0; return; } if (TileRefs(x, y).Liquid < 250 && TileRefs(x, y - 1).Liquid > 0) { Liquid.AddWater(TileRefs, sandbox, x, y - 1); } if (TileRefs(x, y).Liquid == 0) { TileRefs(x, y).SetLava(false); } else { if ((TileRefs(x + 1, y).Liquid > 0 && TileRefs(x + 1, y + 1).Liquid < 250 && !TileRefs(x + 1, y + 1).Active) || (TileRefs(x - 1, y).Liquid > 0 && TileRefs(x - 1, y + 1).Liquid < 250 && !TileRefs(x - 1, y + 1).Active)) { Liquid.AddWater(TileRefs, sandbox, x - 1, y); Liquid.AddWater(TileRefs, sandbox, x + 1, y); } if (TileRefs(x, y).Lava) { Liquid.LavaCheck(TileRefs, sandbox, x, y); for (int i = x - 1; i <= x + 1; i++) { for (int j = y - 1; j <= y + 1; j++) { if (TileRefs(i, j).Active) { if (TileRefs(i, j).Type == 2 || TileRefs(i, j).Type == 23 || TileRefs(i, j).Type == 109) { TileRefs(i, j).SetType(0); WorldModify.SquareTileFrame(TileRefs, sandbox, i, j, true); NetMessage.SendTileSquare(-1, x, y, 3); } else if (TileRefs(i, j).Type == 60 || TileRefs(i, j).Type == 70) { TileRefs(i, j).SetType(59); WorldModify.SquareTileFrame(TileRefs, sandbox, i, j, true); NetMessage.SendTileSquare(-1, x, y, 3); } } } } } } NetMessage.SendWater(x, y); Liquid.numLiquid--; TileRefs(Main.liquid[id].x, Main.liquid[id].y).SetCheckingLiquid(false); Main.liquid[id].x = Main.liquid[Liquid.numLiquid].x; Main.liquid[id].y = Main.liquid[Liquid.numLiquid].y; Main.liquid[id].kill = Main.liquid[Liquid.numLiquid].kill; if (Main.tileAlch[(int)TileRefs(x, y).Type]) { WorldModify.CheckAlch(TileRefs, sandbox, x, y); } }