From 67225c5e6e34270b799930efd1f4ffdcc5b4f950 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 4 Apr 2016 18:19:34 +1000 Subject: [PATCH] Use class variable physRandom instead of declaring a new Random() instance every physics tick. --- Levels/Level.Physics.cs | 79 +++++++++++++-------------- Levels/Level.cs | 1 + Levels/Physics/AirPhysics.cs | 6 +- Levels/Physics/BirdPhysics.cs | 3 +- Levels/Physics/C4Physics.cs | 4 +- Levels/Physics/ExtLiquidPhysics.cs | 15 +++-- Levels/Physics/ExtraInfoPhysics.cs | 9 +-- Levels/Physics/FinitePhysics.cs | 6 +- Levels/Physics/FirePhysics.cs | 3 +- Levels/Physics/FireworkPhysics.cs | 3 +- Levels/Physics/HunterPhysics.cs | 6 +- Levels/Physics/LeafPhysics.cs | 3 +- Levels/Physics/OtherPhysics.cs | 3 +- Levels/Physics/RocketPhysics.cs | 3 +- Levels/Physics/SimpleLiquidPhysics.cs | 35 +++++++----- Levels/Physics/SnakePhysics.cs | 3 +- Levels/Physics/TntPhysics.cs | 10 +++- Levels/Physics/TrainPhysics.cs | 3 +- Levels/Physics/ZombiePhysics.cs | 3 +- 19 files changed, 113 insertions(+), 85 deletions(-) diff --git a/Levels/Level.Physics.cs b/Levels/Level.Physics.cs index 6226c80e5..24fd02660 100644 --- a/Levels/Level.Physics.cs +++ b/Levels/Level.Physics.cs @@ -121,7 +121,7 @@ namespace MCGalaxy { return ""; } - public unsafe void CalcPhysics() { + public void CalcPhysics() { if (physics == 0) return; try { ushort x, y, z; @@ -144,7 +144,6 @@ namespace MCGalaxy { } } } else { - Random rand = new Random(); for (int i = 0; i < ListCheck.Count; i++) { Check C = ListCheck.Items[i]; IntToPos(C.b, out x, out y, out z); @@ -156,8 +155,8 @@ namespace MCGalaxy { PhysicsUpdate(x, y, z, C.time, info, this); if (OnPhysicsUpdateEvent.events.Count > 0) OnPhysicsUpdateEvent.Call(x, y, z, C.time, info, this); - if (info == "" || ExtraInfoPhysics.DoComplex(this, C, rand)) - DoNormalPhysics(x, y, z, rand, C); + if (info == "" || ExtraInfoPhysics.DoComplex(this, C)) + DoNormalPhysics(x, y, z, C); } catch { listCheckExists.Set(x, y, z, false); ListCheck.Remove(C); @@ -191,37 +190,37 @@ namespace MCGalaxy { } } - void DoNormalPhysics(ushort x, ushort y, ushort z, Random rand, Check C) { + void DoNormalPhysics(ushort x, ushort y, ushort z, Check C) { switch (blocks[C.b]) { case Block.air: - AirPhysics.DoAir(this, C, rand); break; + AirPhysics.DoAir(this, C); break; case Block.dirt: OtherPhysics.DoDirt(this, C); break; case Block.leaf: - LeafPhysics.DoLeaf(this, C, rand); break; + LeafPhysics.DoLeaf(this, C); break; case Block.shrub: - OtherPhysics.DoShrub(this, C, rand); break; + OtherPhysics.DoShrub(this, C); break; case Block.water: case Block.activedeathwater: - SimpleLiquidPhysics.DoWater(this, C, rand); break; + SimpleLiquidPhysics.DoWater(this, C); break; case Block.WaterDown: - ExtLiquidPhysics.DoWaterfall(this, C, rand); break; + ExtLiquidPhysics.DoWaterfall(this, C); break; case Block.LavaDown: - ExtLiquidPhysics.DoLavafall(this, C, rand); break; + ExtLiquidPhysics.DoLavafall(this, C); break; case Block.WaterFaucet: - ExtLiquidPhysics.DoFaucet(this, C, rand, Block.WaterDown); break; + ExtLiquidPhysics.DoFaucet(this, C, Block.WaterDown); break; case Block.LavaFaucet: - ExtLiquidPhysics.DoFaucet(this, C, rand, Block.LavaDown); break; + ExtLiquidPhysics.DoFaucet(this, C, Block.LavaDown); break; case Block.lava: case Block.activedeathlava: - SimpleLiquidPhysics.DoLava(this, C, rand); break; + SimpleLiquidPhysics.DoLava(this, C); break; case Block.fire: - FirePhysics.Do(this, C, rand); break; + FirePhysics.Do(this, C); break; case Block.finiteWater: case Block.finiteLava: - FinitePhysics.DoWaterOrLava(this, C, rand); break; + FinitePhysics.DoWaterOrLava(this, C); break; case Block.finiteFaucet: - FinitePhysics.DoFaucet(this, C, rand); break; + FinitePhysics.DoFaucet(this, C); break; case Block.sand: case Block.gravel: OtherPhysics.DoFalling(this, C, blocks[C.b]); break; @@ -261,64 +260,64 @@ namespace MCGalaxy { OtherPhysics.DoFloatwood(this, C); break; case Block.lava_fast: case Block.fastdeathlava: - SimpleLiquidPhysics.DoFastLava(this, C, rand); break; + SimpleLiquidPhysics.DoFastLava(this, C); break; //Special blocks that are not saved case Block.air_flood: - AirPhysics.DoFlood(this, C, rand, AirFlood.Full, Block.air_flood); break; + AirPhysics.DoFlood(this, C, AirFlood.Full, Block.air_flood); break; case Block.air_flood_layer: - AirPhysics.DoFlood(this, C, rand, AirFlood.Layer, Block.air_flood_layer); break; + AirPhysics.DoFlood(this, C, AirFlood.Layer, Block.air_flood_layer); break; case Block.air_flood_down: - AirPhysics.DoFlood(this, C, rand, AirFlood.Down, Block.air_flood_down); break; + AirPhysics.DoFlood(this, C, AirFlood.Down, Block.air_flood_down); break; case Block.air_flood_up: - AirPhysics.DoFlood(this, C, rand, AirFlood.Up, Block.air_flood_up); break; + AirPhysics.DoFlood(this, C, AirFlood.Up, Block.air_flood_up); break; case Block.smalltnt: - TntPhysics.DoSmallTnt(this, C, rand); break; + TntPhysics.DoSmallTnt(this, C); break; case Block.bigtnt: - TntPhysics.DoLargeTnt(this, C, rand, 1); break; + TntPhysics.DoLargeTnt(this, C, 1); break; case Block.nuketnt: - TntPhysics.DoLargeTnt(this, C, rand, 4); break; + TntPhysics.DoLargeTnt(this, C, 4); break; case Block.tntexplosion: - TntPhysics.DoTntExplosion(this, C, rand); break; + TntPhysics.DoTntExplosion(this, C); break; case Block.train: - TrainPhysics.Do(this, C, rand); break; + TrainPhysics.Do(this, C); break; case Block.magma: - ExtLiquidPhysics.DoMagma(this, C, rand); break; + ExtLiquidPhysics.DoMagma(this, C); break; case Block.geyser: - ExtLiquidPhysics.DoGeyser(this, C, rand); break; + ExtLiquidPhysics.DoGeyser(this, C); break; case Block.birdblack: case Block.birdwhite: case Block.birdlava: case Block.birdwater: - BirdPhysics.Do(this, C, rand); break; + BirdPhysics.Do(this, C); break; case Block.snaketail: SnakePhysics.DoTail(this, C); break; case Block.snake: - SnakePhysics.Do(this, C, rand); break; + SnakePhysics.Do(this, C); break; case Block.birdred: case Block.birdblue: case Block.birdkill: - HunterPhysics.DoKiller(this, C, rand, Block.air); break; + HunterPhysics.DoKiller(this, C, Block.air); break; case Block.fishbetta: case Block.fishshark: - HunterPhysics.DoKiller(this, C, rand, Block.water); break; + HunterPhysics.DoKiller(this, C, Block.water); break; case Block.fishgold: case Block.fishsalmon: case Block.fishsponge: - HunterPhysics.DoFlee(this, C, rand, Block.water); break; + HunterPhysics.DoFlee(this, C, Block.water); break; case Block.fishlavashark: - HunterPhysics.DoKiller(this, C, rand, Block.lava); break; + HunterPhysics.DoKiller(this, C, Block.lava); break; case Block.rockethead: - RocketPhysics.Do(this, C, rand); break; + RocketPhysics.Do(this, C); break; case Block.firework: - FireworkPhysics.Do(this, C, rand); break; + FireworkPhysics.Do(this, C); break; case Block.zombiehead: ZombiePhysics.DoHead(this, C); break; case Block.creeper: - ZombiePhysics.Do(this, C, rand); break; + ZombiePhysics.Do(this, C); break; case Block.c4: - C4Physics.DoC4(this, C, rand); break; + C4Physics.DoC4(this, C); break; case Block.c4det: - C4Physics.DoC4Det(this, C, rand); break; + C4Physics.DoC4Det(this, C); break; default: DoorPhysics.Do(this, C); break; } diff --git a/Levels/Level.cs b/Levels/Level.cs index d318c6361..cdfccff9e 100644 --- a/Levels/Level.cs +++ b/Levels/Level.cs @@ -167,6 +167,7 @@ namespace MCGalaxy public LevelPermission permissionvisit = LevelPermission.Guest; public LevelPermission pervisitmax = LevelPermission.Nobody; + public Random physRandom = new Random(); public bool physPause; public DateTime physResume; public Thread physThread; diff --git a/Levels/Physics/AirPhysics.cs b/Levels/Physics/AirPhysics.cs index f0482c865..54445344c 100644 --- a/Levels/Physics/AirPhysics.cs +++ b/Levels/Physics/AirPhysics.cs @@ -22,7 +22,8 @@ namespace MCGalaxy.BlockPhysics { public enum AirFlood { Full, Layer, Down, Up, } public static class AirPhysics { - public static void DoAir(Level lvl, Check C, Random rand) { + public static void DoAir(Level lvl, Check C) { + Random rand = lvl.physRandom; ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); @@ -43,7 +44,8 @@ namespace MCGalaxy.BlockPhysics { C.time = 255; } - public static void DoFlood(Level lvl, Check C, Random rand, AirFlood mode, byte block) { + public static void DoFlood(Level lvl, Check C, AirFlood mode, byte block) { + Random rand = lvl.physRandom; if (C.time >= 1) { lvl.AddUpdate(C.b, Block.air); C.time = 255; return; diff --git a/Levels/Physics/BirdPhysics.cs b/Levels/Physics/BirdPhysics.cs index c2c115c2b..98ee3fd80 100644 --- a/Levels/Physics/BirdPhysics.cs +++ b/Levels/Physics/BirdPhysics.cs @@ -21,7 +21,8 @@ namespace MCGalaxy.BlockPhysics { public static class BirdPhysics { - public static void Do(Level lvl, Check C, Random rand) { + public static void Do(Level lvl, Check C) { + Random rand = lvl.physRandom; ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); diff --git a/Levels/Physics/C4Physics.cs b/Levels/Physics/C4Physics.cs index c05c39a31..f6fb53a5f 100644 --- a/Levels/Physics/C4Physics.cs +++ b/Levels/Physics/C4Physics.cs @@ -22,13 +22,13 @@ namespace MCGalaxy.BlockPhysics { public static class C4Physics { - public static void DoC4(Level lvl, Check C, Random rand) { + public static void DoC4(Level lvl, Check C) { C4Data c4 = Find(lvl, ((Player)C.data).c4circuitNumber); if (c4 != null) c4.list.Add(C.b); C.time = 255; } - public static void DoC4Det(Level lvl, Check C, Random rand) { + public static void DoC4Det(Level lvl, Check C) { C4Data c4 = Find(lvl, ((Player)C.data).c4circuitNumber); if (c4 != null) c4.detIndex = C.b; ((Player)C.data).c4circuitNumber = -1; diff --git a/Levels/Physics/ExtLiquidPhysics.cs b/Levels/Physics/ExtLiquidPhysics.cs index 2d74d3af9..3c7b076ac 100644 --- a/Levels/Physics/ExtLiquidPhysics.cs +++ b/Levels/Physics/ExtLiquidPhysics.cs @@ -21,7 +21,7 @@ namespace MCGalaxy.BlockPhysics { public static class ExtLiquidPhysics { - public static void DoMagma(Level lvl, Check C, Random rand) { + public static void DoMagma(Level lvl, Check C) { C.time++; if (C.time < 3) return; ushort x, y, z; @@ -59,7 +59,7 @@ namespace MCGalaxy.BlockPhysics { } } - public static void DoGeyser(Level lvl, Check C, Random rand) { + public static void DoGeyser(Level lvl, Check C) { C.time++; ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); @@ -96,7 +96,8 @@ namespace MCGalaxy.BlockPhysics { } } - public static void DoWaterfall(Level lvl, Check C, Random rand) { + public static void DoWaterfall(Level lvl, Check C) { + Random rand = lvl.physRandom; ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); byte below = lvl.GetTile(x, (ushort)(y - 1), z); @@ -125,7 +126,8 @@ namespace MCGalaxy.BlockPhysics { } } - public static void DoLavafall(Level lvl, Check C, Random rand) { + public static void DoLavafall(Level lvl, Check C) { + Random rand = lvl.physRandom; ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); byte below = lvl.GetTile(x, (ushort)(y - 1), z); @@ -154,7 +156,7 @@ namespace MCGalaxy.BlockPhysics { } } - public static void DoFaucet(Level lvl, Check C, Random rand, byte target) { + public static void DoFaucet(Level lvl, Check C, byte target) { C.time++; if (C.time < 2) return; C.time = 0; @@ -163,7 +165,8 @@ namespace MCGalaxy.BlockPhysics { lvl.IntToPos(C.b, out x, out y, out z); int index = lvl.PosToInt(x, (ushort)(y - 1), z); if (index < 0) return; - + + Random rand = lvl.physRandom; byte block = lvl.blocks[index]; if (block == Block.air || block == target) { if (rand.Next(1, 10) > 7) diff --git a/Levels/Physics/ExtraInfoPhysics.cs b/Levels/Physics/ExtraInfoPhysics.cs index c9923de9e..4a05e306e 100644 --- a/Levels/Physics/ExtraInfoPhysics.cs +++ b/Levels/Physics/ExtraInfoPhysics.cs @@ -75,7 +75,7 @@ namespace MCGalaxy.BlockPhysics { } } - public static bool DoComplex(Level lvl, Check C, Random rand) { + public static bool DoComplex(Level lvl, Check C) { string info = C.data as string; if (info == null) return true; if (!info.Contains("wait") && lvl.blocks[C.b] == Block.air) @@ -126,17 +126,18 @@ namespace MCGalaxy.BlockPhysics { C.data = info.Substring(0, waitIndex) + info.Substring(info.IndexOf(' ', waitIndex + 5) + 1); - DoOther(lvl, C, rand, ref args); + DoOther(lvl, C, ref args); return false; } C.time++; return true; } - DoOther(lvl, C, rand, ref args); + DoOther(lvl, C, ref args); return false; } - static void DoOther(Level lvl, Check C, Random rand, ref ExtraInfoArgs args) { + static void DoOther(Level lvl, Check C, ref ExtraInfoArgs args) { + Random rand = lvl.physRandom; ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); diff --git a/Levels/Physics/FinitePhysics.cs b/Levels/Physics/FinitePhysics.cs index 109a8a901..3e8227352 100644 --- a/Levels/Physics/FinitePhysics.cs +++ b/Levels/Physics/FinitePhysics.cs @@ -22,7 +22,8 @@ namespace MCGalaxy.BlockPhysics { public static class FinitePhysics { - public unsafe static void DoWaterOrLava(Level lvl, Check C, Random rand) { + public unsafe static void DoWaterOrLava(Level lvl, Check C) { + Random rand = lvl.physRandom; ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); @@ -85,7 +86,8 @@ namespace MCGalaxy.BlockPhysics { return false; } - public unsafe static void DoFaucet(Level lvl, Check C, Random rand) { + public unsafe static void DoFaucet(Level lvl, Check C) { + Random rand = lvl.physRandom; ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); diff --git a/Levels/Physics/FirePhysics.cs b/Levels/Physics/FirePhysics.cs index e85666a5d..934b4609b 100644 --- a/Levels/Physics/FirePhysics.cs +++ b/Levels/Physics/FirePhysics.cs @@ -54,7 +54,7 @@ namespace MCGalaxy.BlockPhysics { lvl.MakeExplosion((ushort)x, (ushort)y, (ushort)z, -1); } - public static void Do(Level lvl, Check C, Random rand) { + public static void Do(Level lvl, Check C) { ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); if (C.time < 2) { @@ -62,6 +62,7 @@ namespace MCGalaxy.BlockPhysics { return; } + Random rand = lvl.physRandom; if (rand.Next(1, 20) == 1 && C.time % 2 == 0) { int max = rand.Next(1, 18); diff --git a/Levels/Physics/FireworkPhysics.cs b/Levels/Physics/FireworkPhysics.cs index deb5abda4..6e56d83b3 100644 --- a/Levels/Physics/FireworkPhysics.cs +++ b/Levels/Physics/FireworkPhysics.cs @@ -21,7 +21,8 @@ namespace MCGalaxy.BlockPhysics { public static class FireworkPhysics { - public static void Do(Level lvl, Check C, Random rand) { + public static void Do(Level lvl, Check C) { + Random rand = lvl.physRandom; ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); diff --git a/Levels/Physics/HunterPhysics.cs b/Levels/Physics/HunterPhysics.cs index 7560f6ba2..52ac2b45e 100644 --- a/Levels/Physics/HunterPhysics.cs +++ b/Levels/Physics/HunterPhysics.cs @@ -21,7 +21,8 @@ namespace MCGalaxy.BlockPhysics { public static class HunterPhysics { - public static void DoKiller(Level lvl, Check C, Random rand, byte target) { + public static void DoKiller(Level lvl, Check C, byte target) { + Random rand = lvl.physRandom; Player closest = AIPhysics.ClosestPlayer(lvl, C); ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); @@ -65,7 +66,8 @@ namespace MCGalaxy.BlockPhysics { RandomlyMove(lvl, C, rand, x, y, z, target); } - public static void DoFlee(Level lvl, Check C, Random rand, byte target) { + public static void DoFlee(Level lvl, Check C, byte target) { + Random rand = lvl.physRandom; Player closest = AIPhysics.ClosestPlayer(lvl, C); ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); diff --git a/Levels/Physics/LeafPhysics.cs b/Levels/Physics/LeafPhysics.cs index 69314898b..77ad3600d 100644 --- a/Levels/Physics/LeafPhysics.cs +++ b/Levels/Physics/LeafPhysics.cs @@ -21,7 +21,8 @@ namespace MCGalaxy.BlockPhysics { public static class LeafPhysics { - public static void DoLeaf(Level lvl, Check C, Random rand) { + public static void DoLeaf(Level lvl, Check C) { + Random rand = lvl.physRandom; ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); if (lvl.physics > 1) { //Adv physics kills flowers and mushroos in water/lava diff --git a/Levels/Physics/OtherPhysics.cs b/Levels/Physics/OtherPhysics.cs index ad5aec311..c41462a80 100644 --- a/Levels/Physics/OtherPhysics.cs +++ b/Levels/Physics/OtherPhysics.cs @@ -101,7 +101,8 @@ namespace MCGalaxy.BlockPhysics { C.time = 255; } - public static void DoShrub(Level lvl, Check C, Random rand) { + public static void DoShrub(Level lvl, Check C) { + Random rand = lvl.physRandom; ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); if (lvl.physics > 1) { //Adv physics kills flowers and mushroos in water/lava diff --git a/Levels/Physics/RocketPhysics.cs b/Levels/Physics/RocketPhysics.cs index aaa05f654..f16217fb6 100644 --- a/Levels/Physics/RocketPhysics.cs +++ b/Levels/Physics/RocketPhysics.cs @@ -21,7 +21,8 @@ namespace MCGalaxy.BlockPhysics { public static class RocketPhysics { - public static void Do(Level lvl, Check C, Random rand) { + public static void Do(Level lvl, Check C) { + Random rand = lvl.physRandom; int dirX = rand.Next(1, 10) <= 5 ? 1 : -1; int dirY = rand.Next(1, 10) <= 5 ? 1 : -1; int dirZ = rand.Next(1, 10) <= 5 ? 1 : -1; diff --git a/Levels/Physics/SimpleLiquidPhysics.cs b/Levels/Physics/SimpleLiquidPhysics.cs index c3dc42ca9..d0dc2508d 100644 --- a/Levels/Physics/SimpleLiquidPhysics.cs +++ b/Levels/Physics/SimpleLiquidPhysics.cs @@ -22,45 +22,47 @@ namespace MCGalaxy.BlockPhysics { public static class SimpleLiquidPhysics { const StringComparison comp = StringComparison.Ordinal; - public static void DoWater(Level lvl, Check C, Random rand) { + public static void DoWater(Level lvl, Check C) { + Random rand = lvl.physRandom; if (lvl.finite) { lvl.liquids.Remove(C.b); - FinitePhysics.DoWaterOrLava(lvl, C, rand); + FinitePhysics.DoWaterOrLava(lvl, C); return; } if (lvl.randomFlow) - DoWaterRandowFlow(lvl, C, rand); + DoWaterRandowFlow(lvl, C); else - DoWaterUniformFlow(lvl, C, rand); + DoWaterUniformFlow(lvl, C); } - public static void DoLava(Level lvl, Check C, Random rand) { + public static void DoLava(Level lvl, Check C) { if (C.time < 4) { C.time++; return; } if (lvl.finite) { lvl.liquids.Remove(C.b); - FinitePhysics.DoWaterOrLava(lvl, C, rand); + FinitePhysics.DoWaterOrLava(lvl, C); return; } if (lvl.randomFlow) - DoLavaRandowFlow(lvl, C, rand, true); + DoLavaRandowFlow(lvl, C, true); else - DoLavaUniformFlow(lvl, C, rand, true); + DoLavaUniformFlow(lvl, C, true); } - public static void DoFastLava(Level lvl, Check C, Random rand) { + public static void DoFastLava(Level lvl, Check C) { if (lvl.randomFlow) { byte oldTime = C.time; - DoLavaRandowFlow(lvl, C, rand, false); + DoLavaRandowFlow(lvl, C, false); if (C.time != 255) C.time = oldTime; } else { - DoLavaUniformFlow(lvl, C, rand, false); + DoLavaUniformFlow(lvl, C, false); } } - static void DoWaterRandowFlow(Level lvl, Check C, Random rand) { + static void DoWaterRandowFlow(Level lvl, Check C) { + Random rand = lvl.physRandom; bool[] blocked = null; ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); @@ -122,7 +124,8 @@ namespace MCGalaxy.BlockPhysics { } } - static void DoWaterUniformFlow(Level lvl, Check C, Random rand) { + static void DoWaterUniformFlow(Level lvl, Check C) { + Random rand = lvl.physRandom; lvl.liquids.Remove(C.b); ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); @@ -175,7 +178,8 @@ namespace MCGalaxy.BlockPhysics { return true; } - static void DoLavaRandowFlow(Level lvl, Check C, Random rand, bool checkWait) { + static void DoLavaRandowFlow(Level lvl, Check C, bool checkWait) { + Random rand = lvl.physRandom; bool[] blocked = null; ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); @@ -234,7 +238,8 @@ namespace MCGalaxy.BlockPhysics { } } - static void DoLavaUniformFlow(Level lvl, Check C, Random rand, bool checkWait) { + static void DoLavaUniformFlow(Level lvl, Check C, bool checkWait) { + Random rand = lvl.physRandom; lvl.liquids.Remove(C.b); ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); diff --git a/Levels/Physics/SnakePhysics.cs b/Levels/Physics/SnakePhysics.cs index 0a9aff4db..12dc62c6b 100644 --- a/Levels/Physics/SnakePhysics.cs +++ b/Levels/Physics/SnakePhysics.cs @@ -21,7 +21,8 @@ namespace MCGalaxy.BlockPhysics { public static class SnakePhysics { - public static void Do(Level lvl, Check C, Random rand) { + public static void Do(Level lvl, Check C) { + Random rand = lvl.physRandom; ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); int dirsVisited = 0, index = 0; diff --git a/Levels/Physics/TntPhysics.cs b/Levels/Physics/TntPhysics.cs index 8aa3722bf..ab7f2f533 100644 --- a/Levels/Physics/TntPhysics.cs +++ b/Levels/Physics/TntPhysics.cs @@ -32,12 +32,14 @@ namespace MCGalaxy.BlockPhysics { lvl.Blockchange(x, y, (ushort)(z - 1), lvl.GetTile(x, y, (ushort)(z - 1)) == Block.lavastill ? Block.air : Block.lavastill); } - public static void DoTntExplosion(Level lvl, Check C, Random rand) { + public static void DoTntExplosion(Level lvl, Check C) { + Random rand = lvl.physRandom; if (rand.Next(1, 11) <= 7) lvl.AddUpdate(C.b, Block.air); } - public static void DoLargeTnt(Level lvl, Check C, Random rand, int power) { + public static void DoLargeTnt(Level lvl, Check C, int power) { + Random rand = lvl.physRandom; ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); @@ -53,10 +55,12 @@ namespace MCGalaxy.BlockPhysics { } } - public static void DoSmallTnt(Level lvl, Check C, Random rand) { + public static void DoSmallTnt(Level lvl, Check C) { + Random rand = lvl.physRandom; ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z); Player p = C.data as Player; + if (p != null && p.PlayingTntWars) { int power = 2, threshold = 3; TntWarsGame game = TntWarsGame.GetTntWarsGame(p); diff --git a/Levels/Physics/TrainPhysics.cs b/Levels/Physics/TrainPhysics.cs index e33de61ea..73f2370e5 100644 --- a/Levels/Physics/TrainPhysics.cs +++ b/Levels/Physics/TrainPhysics.cs @@ -21,7 +21,8 @@ namespace MCGalaxy.BlockPhysics { public static class TrainPhysics { - public static void Do(Level lvl, Check C, Random rand) { + public static void Do(Level lvl, Check C) { + Random rand = lvl.physRandom; int dirX = rand.Next(1, 10) <= 5 ? 1 : -1; int dirY = rand.Next(1, 10) <= 5 ? 1 : -1; int dirZ = rand.Next(1, 10) <= 5 ? 1 : -1; diff --git a/Levels/Physics/ZombiePhysics.cs b/Levels/Physics/ZombiePhysics.cs index 4d38889dc..78d2339ab 100644 --- a/Levels/Physics/ZombiePhysics.cs +++ b/Levels/Physics/ZombiePhysics.cs @@ -21,7 +21,8 @@ namespace MCGalaxy.BlockPhysics { public static class ZombiePhysics { - public static void Do(Level lvl, Check C, Random rand) { + public static void Do(Level lvl, Check C) { + Random rand = lvl.physRandom; ushort x, y, z; lvl.IntToPos(C.b, out x, out y, out z);