From 16997d8ed5ef8b0a514b7661ef26b6f1bd8742f6 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 27 Mar 2016 10:51:38 +1100 Subject: [PATCH] Allow configuring round min/max time. --- Commands/Fun/CmdMapSet.cs | 36 ++++++++++--- Commands/Fun/ZombieSurvival/CmdHuman.cs | 2 +- Commands/Fun/ZombieSurvival/CmdQueue.cs | 4 +- Games/ZombieSurvival/ZombieGame.Core.cs | 67 +++++++++++++------------ Games/ZombieSurvival/ZombieGame.Game.cs | 36 ++++++------- Games/ZombieSurvival/ZombieGame.cs | 26 +++++----- Levels/IO/LvlProperties.cs | 10 +++- Levels/Level.cs | 3 +- Player/Player.cs | 2 +- 9 files changed, 109 insertions(+), 77 deletions(-) diff --git a/Commands/Fun/CmdMapSet.cs b/Commands/Fun/CmdMapSet.cs index 548bbc309..648185ce6 100644 --- a/Commands/Fun/CmdMapSet.cs +++ b/Commands/Fun/CmdMapSet.cs @@ -43,8 +43,8 @@ namespace MCGalaxy.Commands { if (args.Length == 1) { Player.SendMessage(p, "You need to provide a value."); return; } if (args[0].CaselessEq("author") || args[0].CaselessEq("authors")) { - p.level.Authors = args[1].Replace(" ", "%S, "); - Player.SendMessage(p, "Sets the authors of the map to: " + args[1]); + p.level.Authors = args[1].Replace(" ", "%S, "); + Player.SendMessage(p, "Sets the authors of the map to: " + args[1]); } else if (args[0].CaselessEq("pillar") || args[0].CaselessEq("pillaring")) { bool value; if (!bool.TryParse(args[1], out value)) { @@ -59,6 +59,28 @@ namespace MCGalaxy.Commands { } p.level.BuildType = value; Player.SendMessage(p, "Set build type to: " + value); + } else if (args[0].CaselessEq("minroundtime") || args[0].CaselessEq("minround")) { + byte time; + if (!byte.TryParse(args[1], out time) || time == 0 || time > 10) { + Player.SendMessage(p, "Minutes must be an integer between 1 and 10."); return; + } + + if (time > p.level.MaxRoundTime) { + Player.SendMessage(p, "Min round time must be less than or equal to max round time"); return; + } + p.level.MinRoundTime = time; + Player.SendMessage(p, "Set min round time to: " + time + " minutes"); + } else if (args[0].CaselessEq("maxroundtime") || args[0].CaselessEq("maxround")) { + byte time; + if (!byte.TryParse(args[1], out time) || time == 0 || time > 10) { + Player.SendMessage(p, "Minutes must be an integer between 1 and 10."); return; + } + + if (time < p.level.MinRoundTime) { + Player.SendMessage(p, "Max round time must be greater than or equal to min round time"); return; + } + p.level.MaxRoundTime = time; + Player.SendMessage(p, "Set max round time to: " + time + " minutes"); } else { Player.SendMessage(p, "Unrecognised property \"" + args[0] + "\"."); return; } @@ -66,13 +88,13 @@ namespace MCGalaxy.Commands { } public override void Help(Player p) { - Player.SendMessage(p, "%T/mapset author [name1] ..."); - Player.SendMessage(p, "%HSets the authors of the current map. " + - "This is shown to players at the start of rounds in various games."); + Player.SendMessage(p, "%HThis sets the various options for games on this map."); + Player.SendMessage(p, "%T/mapset authors [name1] ..."); + Player.SendMessage(p, "%HThis is shown to players at the start of rounds."); Player.SendMessage(p, "%T/mapset pillaring [true/false]"); - Player.SendMessage(p, "%HSets whether players can pillar on this map in various games."); Player.SendMessage(p, "%T/mapset build [normal/modifyonly/nomodify]"); - Player.SendMessage(p, "%HSets how players are allowed to change blocks."); + Player.SendMessage(p, "%T/mapset minroundtime [minutes]"); + Player.SendMessage(p, "%T/mapset maxroundtime [minutes]"); } } } diff --git a/Commands/Fun/ZombieSurvival/CmdHuman.cs b/Commands/Fun/ZombieSurvival/CmdHuman.cs index a829fad7e..167ef3681 100644 --- a/Commands/Fun/ZombieSurvival/CmdHuman.cs +++ b/Commands/Fun/ZombieSurvival/CmdHuman.cs @@ -35,7 +35,7 @@ namespace MCGalaxy.Commands { } p.pledgeSurvive = true; - Server.zombie.CurrentLevel + Server.zombie.CurLevel .ChatLevel(p.color + p.DisplayName + " %Spledges that they will not succumb to the infection!"); } diff --git a/Commands/Fun/ZombieSurvival/CmdQueue.cs b/Commands/Fun/ZombieSurvival/CmdQueue.cs index 17c8fcdfd..f9d621674 100644 --- a/Commands/Fun/ZombieSurvival/CmdQueue.cs +++ b/Commands/Fun/ZombieSurvival/CmdQueue.cs @@ -43,8 +43,8 @@ namespace MCGalaxy.Commands if (LevelInfo.ExistsOffline(value)) { p.SendMessage(value + " was queued."); Server.zombie.QueuedLevel = value.ToLower(); - if (Server.zombie.CurrentLevel != null) - Server.zombie.CurrentLevel.ChatLevel(value + " was queued as the next map."); + if (Server.zombie.CurLevel != null) + Server.zombie.CurLevel.ChatLevel(value + " was queued as the next map."); } else { p.SendMessage("Level does not exist."); } diff --git a/Games/ZombieSurvival/ZombieGame.Core.cs b/Games/ZombieSurvival/ZombieGame.Core.cs index 80aa0e16a..2035c2e63 100644 --- a/Games/ZombieSurvival/ZombieGame.Core.cs +++ b/Games/ZombieSurvival/ZombieGame.Core.cs @@ -67,13 +67,14 @@ namespace MCGalaxy.Games { Random random = new Random(); Player first = PickFirstZombie(random, players); - CurrentLevel.ChatLevel(first.color + first.name + " %Sstarted the infection!"); + CurLevel.ChatLevel(first.color + first.name + " %Sstarted the infection!"); first.infected = true; UpdatePlayerColor(first, InfectCol); RoundInProgress = true; - int roundMins = random.Next(4, 7); - CurrentLevel.ChatLevel("The round will last for " + roundMins + " minutes!"); + int roundMins = random.Next(CurLevel.MinRoundTime, CurLevel.MaxRoundTime); + string suffix = roundMins == 1 ? " %Sminute!" : " %Sminutes!"; + CurLevel.ChatLevel("The round will last for &a" + roundMins + suffix); RoundEnd = DateTime.UtcNow.AddMinutes(roundMins); timer = new System.Timers.Timer(roundMins * 60 * 1000); timer.Elapsed += new ElapsedEventHandler(EndRound); @@ -102,40 +103,40 @@ namespace MCGalaxy.Games { first = QueuedZombie != null ? PlayerInfo.Find(QueuedZombie) : players[random.Next(players.Count)]; QueuedZombie = null; - } while (first == null || !first.level.name.CaselessEq(CurrentLevelName)); + } while (first == null || !first.level.name.CaselessEq(CurLevelName)); return first; } List DoRoundCountdown() { while (true) { RoundStart = DateTime.UtcNow.AddSeconds(30); - CurrentLevel.ChatLevel("%4Round Start:%f 30..."); + CurLevel.ChatLevel("%4Round Start:%f 30..."); Thread.Sleep(20000); if (!Server.ZombieModeOn) return null; - CurrentLevel.ChatLevel("%4Round Start:%f 10..."); + CurLevel.ChatLevel("%4Round Start:%f 10..."); Thread.Sleep(10000); if (!Server.ZombieModeOn) return null; - CurrentLevel.ChatLevel("%4Round Start:%f 5..."); + CurLevel.ChatLevel("%4Round Start:%f 5..."); Thread.Sleep(1000); if (!Server.ZombieModeOn) return null; - CurrentLevel.ChatLevel("%4Round Start:%f 4..."); + CurLevel.ChatLevel("%4Round Start:%f 4..."); Thread.Sleep(1000); if (!Server.ZombieModeOn) return null; - CurrentLevel.ChatLevel("%4Round Start:%f 3..."); + CurLevel.ChatLevel("%4Round Start:%f 3..."); Thread.Sleep(1000); if (!Server.ZombieModeOn) return null; - CurrentLevel.ChatLevel("%4Round Start:%f 2..."); + CurLevel.ChatLevel("%4Round Start:%f 2..."); Thread.Sleep(1000); if (!Server.ZombieModeOn) return null; - CurrentLevel.ChatLevel("%4Round Start:%f 1..."); + CurLevel.ChatLevel("%4Round Start:%f 1..."); Thread.Sleep(1000); if (!Server.ZombieModeOn) return null; int nonRefPlayers = 0; List players = new List(); Player[] online = PlayerInfo.Online.Items; foreach (Player p in online) { - if (!p.referee && p.level.name.CaselessEq(CurrentLevelName)) { + if (!p.referee && p.level.name.CaselessEq(CurLevelName)) { players.Add(p); nonRefPlayers++; } } if (nonRefPlayers >= 2) return players; - CurrentLevel.ChatLevel(Colors.red + "ERROR: Need 2 or more players to play"); + CurLevel.ChatLevel(Colors.red + "ERROR: Need 2 or more players to play"); } } @@ -164,7 +165,7 @@ namespace MCGalaxy.Games { continue; if (!pAlive.infected && pKiller.infected && !pAlive.referee && !pKiller.referee && pKiller != pAlive - && pKiller.level.name.CaselessEq(CurrentLevelName) && pAlive.level.name.CaselessEq(CurrentLevelName)) + && pKiller.level.name.CaselessEq(CurLevelName) && pAlive.level.name.CaselessEq(CurLevelName)) { InfectPlayer(pAlive); aliveChanged = true; @@ -176,7 +177,7 @@ namespace MCGalaxy.Games { pKiller.SendMessage("You gained " + (2 + infectCombo) + " " + Server.moneys); pKiller.money += 2 + infectCombo; pKiller.OnMoneyChanged(); - CurrentLevel.ChatLevel(pKiller.FullName + " is on a rampage! " + (infectCombo + 1) + " infections in a row!"); + CurLevel.ChatLevel(pKiller.FullName + " is on a rampage! " + (infectCombo + 1) + " infections in a row!"); } } else { infectCombo = 0; @@ -184,7 +185,7 @@ namespace MCGalaxy.Games { lastPlayerToInfect = pKiller.name; pKiller.playersInfected++; - CurrentLevel.ChatLevel(String.Format( + CurLevel.ChatLevel(String.Format( messages[random.Next(messages.Length)], Colors.red + pKiller.DisplayName + Colors.yellow, Colors.red + pAlive.DisplayName + Colors.yellow)); @@ -203,7 +204,7 @@ namespace MCGalaxy.Games { void CheckHumanPledge(Player pAlive) { if (!pAlive.pledgeSurvive) return; pAlive.pledgeSurvive = false; - CurrentLevel.ChatLevel(pAlive.FullName + "%Sbroke their pledge of not being infected."); + CurLevel.ChatLevel(pAlive.FullName + "%Sbroke their pledge of not being infected."); pAlive.money = Math.Max(pAlive.money - 2, 0); pAlive.OnMoneyChanged(); } @@ -213,7 +214,7 @@ namespace MCGalaxy.Games { if (Bounties.TryGetValue(pAlive.name, out bounty)) Bounties.Remove(pAlive.name); if (bounty != null) { - CurrentLevel.ChatLevel(pKiller.FullName + " %Scollected the bounty of &a" + + CurLevel.ChatLevel(pKiller.FullName + " %Scollected the bounty of &a" + bounty.Amount + " %S" + Server.moneys + " on " + pAlive.FullName + "%S."); bounty.Origin.money = Math.Max(0, bounty.Origin.money - bounty.Amount); bounty.Origin.OnMoneyChanged(); @@ -231,11 +232,11 @@ namespace MCGalaxy.Games { void EndRound(object sender, ElapsedEventArgs e) { if (Status == ZombieGameStatus.NotStarted) return; - CurrentLevel.ChatLevel("%4Round End:%f 5"); Thread.Sleep(1000); - CurrentLevel.ChatLevel("%4Round End:%f 4"); Thread.Sleep(1000); - CurrentLevel.ChatLevel("%4Round End:%f 3"); Thread.Sleep(1000); - CurrentLevel.ChatLevel("%4Round End:%f 2"); Thread.Sleep(1000); - CurrentLevel.ChatLevel("%4Round End:%f 1"); Thread.Sleep(1000); + CurLevel.ChatLevel("%4Round End:%f 5"); Thread.Sleep(1000); + CurLevel.ChatLevel("%4Round End:%f 4"); Thread.Sleep(1000); + CurLevel.ChatLevel("%4Round End:%f 3"); Thread.Sleep(1000); + CurLevel.ChatLevel("%4Round End:%f 2"); Thread.Sleep(1000); + CurLevel.ChatLevel("%4Round End:%f 1"); Thread.Sleep(1000); HandOutRewards(); } @@ -248,10 +249,10 @@ namespace MCGalaxy.Games { if (Status == ZombieGameStatus.NotStarted) return; Player[] alive = Alive.Items; - CurrentLevel.ChatLevel(Colors.lime + "The game has ended!"); - if (alive.Length == 0) CurrentLevel.ChatLevel(Colors.maroon + "Zombies have won this round."); - else if (alive.Length == 1) CurrentLevel.ChatLevel(Colors.green + "Congratulations to the sole survivor:"); - else CurrentLevel.ChatLevel(Colors.green + "Congratulations to the survivors:"); + CurLevel.ChatLevel(Colors.lime + "The game has ended!"); + if (alive.Length == 0) CurLevel.ChatLevel(Colors.maroon + "Zombies have won this round."); + else if (alive.Length == 1) CurLevel.ChatLevel(Colors.green + "Congratulations to the sole survivor:"); + else CurLevel.ChatLevel(Colors.green + "Congratulations to the survivors:"); timer.Enabled = false; string playersString = ""; @@ -273,12 +274,12 @@ namespace MCGalaxy.Games { } } - CurrentLevel.ChatLevel(playersString); + CurLevel.ChatLevel(playersString); online = PlayerInfo.Online.Items; Random rand = new Random(); foreach (Player pl in online) { int money = 0; - if (!pl.level.name.CaselessEq(CurrentLevelName)) continue; + if (!pl.level.name.CaselessEq(CurLevelName)) continue; bool inBlock = pl.CheckIfInsideBlock(); if (!inBlock && alive.Length == 0) { @@ -317,7 +318,7 @@ namespace MCGalaxy.Games { p.infected = false; p.playersInfected = 0; - if (p.level.name.CaselessEq(CurrentLevelName)) + if (p.level.name.CaselessEq(CurLevelName)) playersString += p.color + p.DisplayName + Colors.white + ", "; } @@ -339,8 +340,8 @@ namespace MCGalaxy.Games { string level = levels[r.Next(0, levels.Count)]; string level2 = levels[r.Next(0, levels.Count)]; - if (level == lastLevel1 || level == lastLevel2 || level == CurrentLevelName || - level2 == lastLevel1 || level2 == lastLevel2 || level2 == CurrentLevelName || + if (level == lastLevel1 || level == lastLevel2 || level == CurLevelName || + level2 == lastLevel1 || level2 == lastLevel2 || level2 == CurLevelName || level == selectedLevel1) { goto LevelChoice; } else if (selectedLevel1 == "") { @@ -357,7 +358,7 @@ namespace MCGalaxy.Games { if (initialChangeLevel) { Server.votingforlevel = true; - CurrentLevel.ChatLevel(" " + Colors.black + "Level Vote: %S" + selectedLevel1 + ", " + selectedLevel2 + + CurLevel.ChatLevel(" " + Colors.black + "Level Vote: %S" + selectedLevel1 + ", " + selectedLevel2 + " or random " + "(" + Colors.lime + "1%S/" + Colors.red + "2%S/" + Colors.blue + "3%S)"); System.Threading.Thread.Sleep(15000); Server.votingforlevel = false; diff --git a/Games/ZombieSurvival/ZombieGame.Game.cs b/Games/ZombieSurvival/ZombieGame.Game.cs index e898551f3..0eb9372bc 100644 --- a/Games/ZombieSurvival/ZombieGame.Game.cs +++ b/Games/ZombieSurvival/ZombieGame.Game.cs @@ -25,15 +25,15 @@ namespace MCGalaxy.Games { public override bool HandlesManualChange(Player p, ushort x, ushort y, ushort z, byte action, byte tile, byte b) { if (Status == ZombieGameStatus.NotStarted - || (p.level == null || !p.level.name.CaselessEq(CurrentLevelName))) return false; - if (CurrentLevel.BuildType == BuildType.NoModify) { + || (p.level == null || !p.level.name.CaselessEq(CurLevelName))) return false; + if (CurLevel.BuildType == BuildType.NoModify) { p.RevertBlock(x, y, z); return true; - } else if (CurrentLevel.BuildType == BuildType.ModifyOnly + } else if (CurLevel.BuildType == BuildType.ModifyOnly && p.level.GetTile(x, y, z) == Block.op_air) { p.RevertBlock(x, y, z); return true; } - if (action == 1 && !CurrentLevel.Pillaring && !p.referee) { + if (action == 1 && !CurLevel.Pillaring && !p.referee) { if (p.lastYblock == y - 1 && p.lastXblock == x && p.lastZblock == z ) { p.blocksStacked++; } else { @@ -50,7 +50,7 @@ namespace MCGalaxy.Games { p.lastXblock = x; p.lastYblock = y; p.lastZblock = z; if (action == 1 || (action == 0 && p.painting)) { - if (!p.level.name.CaselessEq(CurrentLevelName) || p.referee) return false; + if (!p.level.name.CaselessEq(CurLevelName) || p.referee) return false; if (p.blockCount == 0 ) { p.SendMessage("You have no blocks left."); @@ -67,7 +67,7 @@ namespace MCGalaxy.Games { public override bool HandlesMovement(Player p, ushort x, ushort y, ushort z, byte rotX, byte rotY) { if (Status == ZombieGameStatus.NotStarted - || (p.level == null || !p.level.name.CaselessEq(CurrentLevelName))) return false; + || (p.level == null || !p.level.name.CaselessEq(CurLevelName))) return false; if (!p.referee && noRespawn) { if (p.pos[0] >= x + 70 || p.pos[0] <= x - 70 ) { p.SendPos(0xFF, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1]); @@ -83,7 +83,7 @@ namespace MCGalaxy.Games { public override bool HandlesChatMessage(Player p, string message) { if (Status == ZombieGameStatus.NotStarted - || (p.level == null || !p.level.name.CaselessEq(CurrentLevelName))) return false; + || (p.level == null || !p.level.name.CaselessEq(CurLevelName))) return false; if (Server.votingforlevel && HandleVote(p, message)) return true; if (message[0] == '~' && message.Length > 1) { @@ -125,11 +125,11 @@ namespace MCGalaxy.Games { public override void PlayerJoinedServer(Player p) { if (Status == ZombieGameStatus.NotStarted || Server.ZombieOnlyServer) return; Player.SendMessage(p, "A Zombie Survival game is running! " + - "Type %T/g " + CurrentLevelName + " %Sto join."); + "Type %T/g " + CurLevelName + " %Sto join."); } public override void PlayerJoinedLevel(Player p, Level oldLvl) { - if (RoundInProgress && p.level.name.CaselessEq(CurrentLevelName)) { + if (RoundInProgress && p.level.name.CaselessEq(CurLevelName)) { if (Status != ZombieGameStatus.NotStarted && p != null) { p.SendMessage("You joined in the middle of a round. &cYou are now infected!"); p.blockCount = 50; @@ -137,18 +137,18 @@ namespace MCGalaxy.Games { } } - if (p.level.name.CaselessEq(CurrentLevelName)) { + if (p.level.name.CaselessEq(CurLevelName)) { double startLeft = (RoundStart - DateTime.UtcNow).TotalSeconds; if (startLeft >= 0) p.SendMessage("%a" + (int)startLeft + " %Sseconds left until the round starts. %aRun!"); - p.SendMessage("This map has &a" + CurrentLevel.Likes + - " likes %Sand &c" + CurrentLevel.Dislikes + " dislikes"); + p.SendMessage("This map has &a" + CurLevel.Likes + + " likes %Sand &c" + CurLevel.Dislikes + " dislikes"); p.SendCpeMessage(CpeMessageType.Status2, - "%SPillaring " + (CurrentLevel.Pillaring ? "&aYes" : "&cNo") + - "%S, Type is &a" + CurrentLevel.BuildType); + "%SPillaring " + (CurLevel.Pillaring ? "&aYes" : "&cNo") + + "%S, Type is &a" + CurLevel.BuildType); - if (CurrentLevel.Authors != "") - p.SendMessage("It was created by " + CurrentLevel.Authors); + if (CurLevel.Authors != "") + p.SendMessage("It was created by " + CurLevel.Authors); p.SendCpeMessage(CpeMessageType.Status3, "%SYou have &a" + p.money + " %S" + Server.moneys); UpdatePlayerStatus(p); return; @@ -159,13 +159,13 @@ namespace MCGalaxy.Games { p.SendCpeMessage(CpeMessageType.Status3, ""); Alive.Remove(p); Infected.Remove(p); - if (oldLvl != null && oldLvl.name.CaselessEq(CurrentLevelName)) + if (oldLvl != null && oldLvl.name.CaselessEq(CurLevelName)) UpdateAllPlayerStatus(); } public override void PlayerMoneyChanged(Player p) { if (Status == ZombieGameStatus.NotStarted - || !p.level.name.CaselessEq(CurrentLevelName)) return; + || !p.level.name.CaselessEq(CurLevelName)) return; p.SendCpeMessage(CpeMessageType.Status3, "%SYou have &a" + p.money + " %S" + Server.moneys); } } diff --git a/Games/ZombieSurvival/ZombieGame.cs b/Games/ZombieSurvival/ZombieGame.cs index fea5e5737..9c440864f 100644 --- a/Games/ZombieSurvival/ZombieGame.cs +++ b/Games/ZombieSurvival/ZombieGame.cs @@ -69,10 +69,10 @@ namespace MCGalaxy.Games { public string LastLevelName = ""; /// The name of the level that the current round of zombie survival is being played on. - public string CurrentLevelName = ""; + public string CurLevelName = ""; /// The level that the current round of zombie survival is being played on. - public Level CurrentLevel = null; + public Level CurLevel = null; /// List of alive/human players. public VolatileArray Alive = new VolatileArray(false); @@ -128,7 +128,7 @@ namespace MCGalaxy.Games { if (alive.Length == 0) return; int index = random.Next(alive.Length); - while (alive[index].referee || !alive[index].level.name.CaselessEq(CurrentLevelName)) { + while (alive[index].referee || !alive[index].level.name.CaselessEq(CurLevelName)) { if (index >= alive.Length - 1) { index = 0; alive = Alive.Items; @@ -139,7 +139,7 @@ namespace MCGalaxy.Games { } Player zombie = alive[index]; - CurrentLevel.ChatLevel(zombie.FullName + " %Scontinued the infection!"); + CurLevel.ChatLevel(zombie.FullName + " %Scontinued the infection!"); InfectPlayer(zombie); } @@ -163,22 +163,22 @@ namespace MCGalaxy.Games { void ChangeLevel(string next) { Player[] online = PlayerInfo.Online.Items; - if (CurrentLevel != null) { + if (CurLevel != null) { bool saveSettings = false; foreach (Player pl in online) saveSettings |= pl.ratedMap; - if (saveSettings) Level.SaveSettings(CurrentLevel); + if (saveSettings) Level.SaveSettings(CurLevel); - CurrentLevel.ChatLevel("The next map has been chosen - " + Colors.red + next.ToLower()); - CurrentLevel.ChatLevel("Please wait while you are transfered."); + CurLevel.ChatLevel("The next map has been chosen - " + Colors.red + next.ToLower()); + CurLevel.ChatLevel("Please wait while you are transfered."); } - CurrentLevelName = next; + CurLevelName = next; QueuedLevel = null; Command.all.Find("load").Use(null, next.ToLower() + " 0"); - CurrentLevel = LevelInfo.Find(next); + CurLevel = LevelInfo.Find(next); if (Server.ZombieOnlyServer) - Server.mainLevel = CurrentLevel; + Server.mainLevel = CurLevel; online = PlayerInfo.Online.Items; foreach (Player pl in online) { @@ -203,8 +203,8 @@ namespace MCGalaxy.Games { RoundStart = DateTime.MinValue; RoundEnd = DateTime.MinValue; LastLevelName = ""; - CurrentLevelName = ""; - CurrentLevel = null; + CurLevelName = ""; + CurLevel = null; Player[] online = PlayerInfo.Online.Items; foreach (Player pl in online) { diff --git a/Levels/IO/LvlProperties.cs b/Levels/IO/LvlProperties.cs index ab9437f5d..a43d5e34c 100644 --- a/Levels/IO/LvlProperties.cs +++ b/Levels/IO/LvlProperties.cs @@ -61,6 +61,7 @@ namespace MCGalaxy.Levels.IO { writer.WriteLine("Unload = " + level.unload); writer.WriteLine("WorldChat = " + level.worldChat); + writer.WriteLine("#Permission settings"); writer.WriteLine("PerBuild = " + GetName(level.permissionbuild)); writer.WriteLine("PerVisit = " + GetName(level.permissionvisit)); writer.WriteLine("PerBuildMax = " + GetName(level.perbuildmax)); @@ -77,11 +78,14 @@ namespace MCGalaxy.Levels.IO { writer.WriteLine("Texture = " + level.terrainUrl); writer.WriteLine("TexturePack = " + level.texturePackUrl); + writer.WriteLine("#Game settings"); writer.WriteLine("Likes = " + level.Likes); writer.WriteLine("Dislikes = " + level.Dislikes); writer.WriteLine("Authors = " + level.Authors); writer.WriteLine("Pillaring = " + level.Pillaring); writer.WriteLine("BuildType = " + level.BuildType); + writer.WriteLine("MinRoundTime = " + level.MinRoundTime); + writer.WriteLine("MaxRoundTime = " + level.MaxRoundTime); } static string GetName(LevelPermission perm) { @@ -113,7 +117,7 @@ namespace MCGalaxy.Levels.IO { public static void Load(Level level, string path) { foreach (string line in File.ReadAllLines(path)) { try { - if (line[0] == '#') continue; + if (line.Length == 0 || line[0] == '#') continue; int sepIndex = line.IndexOf(" = "); if (sepIndex < 0) continue; @@ -228,6 +232,10 @@ namespace MCGalaxy.Levels.IO { level.Pillaring = bool.Parse(value); break; case "buildtype": level.BuildType = (BuildType)Enum.Parse(typeof(BuildType), value); break; + case "minroundtime": + level.MinRoundTime = int.Parse(value); break; + case "maxroundtime": + level.MaxRoundTime = int.Parse(value); break; } } diff --git a/Levels/Level.cs b/Levels/Level.cs index c2618bf97..74c40641b 100644 --- a/Levels/Level.cs +++ b/Levels/Level.cs @@ -208,6 +208,7 @@ namespace MCGalaxy public BuildType BuildType = BuildType.Normal; public bool CanPlace { get { return Buildable && BuildType != BuildType.NoModify; } } public bool CanDelete { get { return Deletable && BuildType != BuildType.NoModify; } } + public int MinRoundTime = 4, MaxRoundTime = 7; public Level(string n, ushort x, ushort y, ushort z, string type, int seed = 0, bool useSeed = false) { @@ -284,7 +285,7 @@ namespace MCGalaxy public bool ShouldSaveLevelFile() { if (Server.ZombieModeOn && - (name.CaselessEq(Server.zombie.CurrentLevelName) + (name.CaselessEq(Server.zombie.CurLevelName) || name.CaselessEq(Server.zombie.LastLevelName))) return false; if (Server.lava.active && Server.lava.HasMap(name)) return false; return true; diff --git a/Player/Player.cs b/Player/Player.cs index 4ece552e6..08e47c18e 100644 --- a/Player/Player.cs +++ b/Player/Player.cs @@ -517,7 +517,7 @@ namespace MCGalaxy { dst.SendSpawn(id, Colors.red + Server.zombie.ZombieName + possession, x, y, z, rotx, roty); else dst.SendSpawn(id, Colors.red + p.name + possession, x, y, z, rotx, roty); - if (dst.HasCpeExt(CpeExt.ChangeModel)) + if (dst.HasCpeExt(CpeExt.ChangeModel) && id != 0xFF) dst.SendChangeModel(id, "zombie"); }