From dfd65bbd77a2e57cf4353cbeafbe2c6806eeee4f Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Thu, 7 Apr 2016 12:13:50 +1000 Subject: [PATCH] Fix CPE messages not being reset for zombie survival, fixes #124. --- Blocks/Block.CoreProps.cs | 2 +- Blocks/Block.cs | 4 +-- Games/ZombieSurvival/ZombieGame.Game.cs | 38 ++++++++++++++----------- Games/ZombieSurvival/ZombieGame.cs | 11 +++++-- 4 files changed, 34 insertions(+), 21 deletions(-) diff --git a/Blocks/Block.CoreProps.cs b/Blocks/Block.CoreProps.cs index 93f43d81a..7c06daa71 100644 --- a/Blocks/Block.CoreProps.cs +++ b/Blocks/Block.CoreProps.cs @@ -56,7 +56,7 @@ namespace MCGalaxy { if (i >= red && i <= white) Properties[i].KilledByLava = true; - if (i == air || i == shrub || (i >= yellowflower && i <= redmushroom) { + if (i == air || i == shrub || (i >= yellowflower && i <= redmushroom)) { Properties[i].KilledByLava = true; Properties[i].KilledByWater = true; } diff --git a/Blocks/Block.cs b/Blocks/Block.cs index 6b454563f..bd57c6c61 100644 --- a/Blocks/Block.cs +++ b/Blocks/Block.cs @@ -23,7 +23,7 @@ namespace MCGalaxy { public static bool Walkthrough(byte type) { return type == air || type == shrub || (type >= water && type <= lavastill) - && (type >= yelllowflower && type <= redmushroom); + && (type >= yellowflower && type <= redmushroom); } public static bool AllowBreak(byte type) @@ -85,7 +85,7 @@ namespace MCGalaxy } public static bool Placable(byte type) { - return !(type == blackrock || (type >= water && type <= lavstill) + return !(type == blackrock || (type >= water && type <= lavastill)) && type < Block.CpeCount; } diff --git a/Games/ZombieSurvival/ZombieGame.Game.cs b/Games/ZombieSurvival/ZombieGame.Game.cs index ec489e79b..5042dd8ce 100644 --- a/Games/ZombieSurvival/ZombieGame.Game.cs +++ b/Games/ZombieSurvival/ZombieGame.Game.cs @@ -87,7 +87,7 @@ namespace MCGalaxy.Games { Player[] players = p.Game.Infected ? Infected.Items : Alive.Items; string type = p.Game.Infected ? " &cto zombies%S: " : " &ato humans%S: "; foreach (Player pl in players) - pl.SendMessage(p.color + p.DisplayName + type + message.Substring(1)); + pl.SendMessage(p.color + p.DisplayName + type + message.Substring(1)); return true; } else if (message[0] == '`' && message.Length > 1) { if (p.Game.Team == null) { @@ -122,7 +122,7 @@ namespace MCGalaxy.Games { } public override void PlayerJoinedLevel(Player p, Level lvl, Level oldLvl) { - p.SendCpeMessage(CpeMessageType.BottomRight2, ""); + p.SendCpeMessage(CpeMessageType.BottomRight2, ""); p.SendCpeMessage(CpeMessageType.BottomRight1, ""); if (RoundInProgress && lvl.name.CaselessEq(CurLevelName)) { if (Running && p != null) { @@ -152,30 +152,36 @@ namespace MCGalaxy.Games { return; } - p.SendCpeMessage(CpeMessageType.Status1, ""); - p.SendCpeMessage(CpeMessageType.Status2, ""); - p.SendCpeMessage(CpeMessageType.Status3, ""); + ResetCpeMessages(p); Alive.Remove(p); Infected.Remove(p); if (oldLvl != null && oldLvl.name.CaselessEq(CurLevelName)) UpdateAllPlayerStatus(); } - + + void ResetCpeMessages(Player p) { + p.SendCpeMessage(CpeMessageType.Status1, ""); + p.SendCpeMessage(CpeMessageType.Status2, ""); + p.SendCpeMessage(CpeMessageType.Status3, ""); + p.SendCpeMessage(CpeMessageType.BottomRight1, ""); + p.SendCpeMessage(CpeMessageType.BottomRight2, ""); + } + public override bool PlayerCanJoinLevel(Player p, Level lvl, Level oldLvl) { - if (!oldLvl.name.CaselessEq(CurLevelName)) return true; - if (lvl.name.CaselessEq(CurLevelName)) return true; - - if (RoundInProgress && !p.Game.Referee) { - p.SendMessage("Sorry, you cannot leave a zombie survival map until the current round has ended."); - return false; - } - return true; + if (!oldLvl.name.CaselessEq(CurLevelName)) return true; + if (lvl.name.CaselessEq(CurLevelName)) return true; + + if (RoundInProgress && !p.Game.Referee) { + p.SendMessage("Sorry, you cannot leave a zombie survival map until the current round has ended."); + return false; + } + return true; } public override void PlayerMoneyChanged(Player p) { if (!Running || !p.level.name.CaselessEq(CurLevelName)) return; - string moneyMsg = "&a" + p.money + " %S" + Server.moneys; - string stateMsg = " and you are " + (p.Game.Infected ? "&cdead" : "&aalive"); + string moneyMsg = "&a" + p.money + " %S" + Server.moneys; + string stateMsg = " and you are " + (p.Game.Infected ? "&cdead" : "&aalive"); p.SendCpeMessage(CpeMessageType.Status3, moneyMsg + stateMsg); } } diff --git a/Games/ZombieSurvival/ZombieGame.cs b/Games/ZombieSurvival/ZombieGame.cs index d7d570dab..fb9d43e91 100644 --- a/Games/ZombieSurvival/ZombieGame.cs +++ b/Games/ZombieSurvival/ZombieGame.cs @@ -203,11 +203,18 @@ namespace MCGalaxy.Games { RoundInProgress = false; RoundStart = DateTime.MinValue; RoundEnd = DateTime.MinValue; + Player[] online = PlayerInfo.Online.Items; + foreach (Player pl in online) { + pl.Game.RatedMap = false; + pl.Game.PledgeSurvive = false; + if (pl.level == null || !pl.level.name.CaselessEq(CurLevelName)) + continue; + ResetCpeMessages(pl); + } + LastLevelName = ""; CurLevelName = ""; CurLevel = null; - - Player[] online = PlayerInfo.Online.Items; foreach (Player pl in online) { pl.Game.RatedMap = false; pl.Game.PledgeSurvive = false;