diff --git a/Blocks/Behaviour/WalkthroughBehaviour.cs b/Blocks/Behaviour/WalkthroughBehaviour.cs index bc83d9eaf..744c94b7e 100644 --- a/Blocks/Behaviour/WalkthroughBehaviour.cs +++ b/Blocks/Behaviour/WalkthroughBehaviour.cs @@ -85,7 +85,8 @@ namespace MCGalaxy.BlockBehaviour { p.checkpointX = x; p.checkpointY = y; p.checkpointZ = z; int index = p.level.PosToInt(x, y, z); if (index != p.lastCheckpointIndex) { - p.SpawnEntity(p, 0xFF, p.pos[0], (ushort)((y - 1) * 32 + 51), p.pos[2], p.rot[0], p.rot[1]); + int sendY = (p.pos[1] / 32) * 32 + 10; + p.SpawnEntity(p, 0xFF, p.pos[0], (ushort)sendY, p.pos[2], p.rot[0], p.rot[1]); p.lastCheckpointIndex = index; } return true; diff --git a/Blocks/Block.CoreProps.cs b/Blocks/Block.CoreProps.cs index 7c06daa71..48626c4c0 100644 --- a/Blocks/Block.CoreProps.cs +++ b/Blocks/Block.CoreProps.cs @@ -114,7 +114,9 @@ namespace MCGalaxy { for (int i = 0; i < names.Length; i++) { Properties[i].Name = names[i]; if (names[i] != "unknown") - Aliases[names[i]] = (byte)i; + Aliases[names[i]] = (byte)i; + if (names[i].IndexOf('_') >= 0) + Aliases[names[i].Replace("_", "")] = (byte)i; } // Add old MCGalaxy aliases diff --git a/Games/ZombieSurvival/ZombieGame.Core.cs b/Games/ZombieSurvival/ZombieGame.Core.cs index 0bddad2cf..46f44b3a9 100644 --- a/Games/ZombieSurvival/ZombieGame.Core.cs +++ b/Games/ZombieSurvival/ZombieGame.Core.cs @@ -76,6 +76,7 @@ namespace MCGalaxy.Games { void DoRound() { if (!Running) return; List players = DoRoundCountdown(); + if (players == null) return; RoundInProgress = true; Random random = new Random(); Player first = PickFirstZombie(random, players); @@ -125,6 +126,7 @@ namespace MCGalaxy.Games { List DoRoundCountdown() { while (true) { RoundStart = DateTime.UtcNow.AddSeconds(30); + if (!Running) return null; CurLevel.ChatLevel("&4Round Start:&f 30..."); Thread.Sleep(20000); if (!Running) return null; CurLevel.ChatLevel("&4Round Start:&f 10..."); @@ -150,6 +152,7 @@ namespace MCGalaxy.Games { } } + if (!Running) return null; if (nonRefPlayers >= 2) return players; CurLevel.ChatLevel("&cNeed 2 or more players to start a round."); } diff --git a/Levels/Physics/ExtraInfoPhysics.cs b/Levels/Physics/ExtraInfoPhysics.cs index 4a05e306e..cf76ba1d0 100644 --- a/Levels/Physics/ExtraInfoPhysics.cs +++ b/Levels/Physics/ExtraInfoPhysics.cs @@ -41,8 +41,7 @@ namespace MCGalaxy.BlockPhysics { door = true; break; } } - if (!wait) - return false; + if (!wait) return false; if (door && C.time < 2) { // TODO: perhaps do proper bounds checking @@ -179,7 +178,7 @@ namespace MCGalaxy.BlockPhysics { if (rainbownum > 2) { byte block = lvl.blocks[C.b]; if (block < Block.red || block > Block.darkpink) { - lvl.AddUpdate(C.b, Block.red, true, C.data); + lvl.AddUpdate(C.b, Block.red, false, C.data); } else { byte next = block == Block.darkpink ? Block.red : (byte)(block + 1); lvl.AddUpdate(C.b, next); diff --git a/Levels/PhysicsArgs.cs b/Levels/PhysicsArgs.cs new file mode 100644 index 000000000..a35bd7aa2 --- /dev/null +++ b/Levels/PhysicsArgs.cs @@ -0,0 +1,101 @@ +/* + Copyright 2015 MCGalaxy + + Dual-licensed under the Educational Community License, Version 2.0 and + the GNU General Public License, Version 3 (the "Licenses"); you may + not use this file except in compliance with the Licenses. You may + obtain a copy of the Licenses at + + http://www.opensource.org/licenses/ecl2.php + http://www.gnu.org/licenses/gpl-3.0.html + + Unless required by applicable law or agreed to in writing, + software distributed under the Licenses are distributed on an "AS IS" + BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + or implied. See the Licenses for the specific language governing + permissions and limitations under the Licenses. + */ +using System; +using System.Runtime.InteropServices; + +namespace MCGalaxy.BlockPhysics { + + [StructLayout(LayoutKind.Sequential, Pack = 4)] + public struct PhysicsArgs { + public uint Raw; + + // Flags + /// Whether this physics item should wait before performing its other arguments. + public bool Wait { + get { return (Raw & (1u << 0)) != 0; } + set { Raw &= ~(1u << 0); + Raw |= (value ? 1u : 0u) << 0; } + } + + /// Whether this physics item should randomly drop downards. + public bool Drop { + get { return (Raw & (1u << 1)) != 0; } + set { Raw &= ~(1u << 1); + Raw |= (value ? 1u : 0u) << 1; } + } + + /// Whether this physics item should randomly convert back into air. + public bool Dissipate { + get { return (Raw & (1u << 2)) != 0; } + set { Raw &= ~(1u << 2); + Raw |= (value ? 1u : 0u) << 2; } + } + + /// Whether this physics item should revert back into the given block id. + public bool Revert { + get { return (Raw & (1u << 3)) != 0; } + set { Raw &= ~(1u << 3); + Raw |= (value ? 1u : 0u) << 3; } + } + + /// Whether this physics item should check itself and its neighbours for tdoor activation. + public bool Door { + get { return (Raw & (1u << 4)) != 0; } + set { Raw &= ~(1u << 4); + Raw |= (value ? 1u : 0u) << 4; } + } + + /// Whether this physics item should randomly explode. + public bool Explode { + get { return (Raw & (1u << 5)) != 0; } + set { Raw &= ~(1u << 5); + Raw |= (value ? 1u : 0u) << 5; } + } + + /// Whether this physics update should have a rainbow affect applied. + public bool Rainbow { + get { return (Raw & (1u << 6)) != 0; } + set { Raw &= ~(1u << 6); + Raw |= (value ? 1u : 0u) << 6; } + } + + // Data + public bool RandomRainbow { + get { return (Raw & (1u << 7)) != 0; } + set { Raw |= (value ? 1u : 0u) << 7; } + } + + public byte Value1 { + get { return (byte)(Raw >> 8); } + set { Raw &= ~(0xFFu << 8); + Raw |= (uint)value << 8; } + } + + public byte Value2 { + get { return (byte)(Raw >> 16); } + set { Raw &= ~(0xFFu << 16); + Raw |= (uint)value << 16; } + } + + public byte Value3 { + get { return (byte)(Raw >> 24); } + set { Raw &= ~(0xFFu << 24); + Raw |= (uint)value << 24; } + } + } +} diff --git a/MCGalaxy_.csproj b/MCGalaxy_.csproj index 1f8578e12..3dd855792 100644 --- a/MCGalaxy_.csproj +++ b/MCGalaxy_.csproj @@ -470,6 +470,7 @@ +