private static void SetNewborn(Player p, Life2DZone life, string val) { Block b = Map.GetBlockByName(val); if (b == Block.Undefined) { p.Message("&WUnrecognized block name " + val); return; } life.Newborn = b; p.Message("&yNewborn block set to " + val); }
public Block NextBlockWithParam([NotNull] Player player, ref int param) { if (player == null) { throw new ArgumentNullException("player"); } string jointString = Next(); if (jointString == null) { return(Block.Undefined); } Block targetBlock; int slashIndex = jointString.IndexOf('/'); if (slashIndex != -1) { string blockName = jointString.Substring(0, slashIndex); string paramString = jointString.Substring(slashIndex + 1); targetBlock = Map.GetBlockByName(blockName); if (targetBlock == Block.Undefined) { player.Message("Unrecognized blocktype \"{0}\"", blockName); } int tempParam; if (Int32.TryParse(paramString, out tempParam)) { param = tempParam; } else { player.Message("Could not parse \"{0}\" as an integer.", paramString); } } else { targetBlock = Map.GetBlockByName(jointString); if (targetBlock == Block.Undefined) { player.Message("Unrecognized blocktype \"{0}\"", jointString); } } return(targetBlock); }
public Block NextBlock([NotNull] Player player) { if (player == null) { throw new ArgumentNullException("player"); } string blockName = Next(); Block targetBlock = Block.Undefined; if (blockName != null) { targetBlock = Map.GetBlockByName(blockName); if (targetBlock == Block.Undefined) { player.Message("Unrecognized blocktype \"{0}\"", blockName); } } return(targetBlock); }
static void LoadWorldListEntry([NotNull] XElement el) { if (el == null) { throw new ArgumentNullException("el"); } XAttribute tempAttr; if ((tempAttr = el.Attribute("name")) == null) { Logger.Log(LogType.Error, "WorldManager: World tag with no name skipped."); return; } string worldName = tempAttr.Value; bool neverUnload = (el.Attribute("noUnload") != null); World world; try { world = AddWorld(null, worldName, null, neverUnload); } catch (WorldOpException ex) { Logger.Log(LogType.Error, "WorldManager: Error adding world \"{0}\": {1}", worldName, ex.Message); return; } if ((tempAttr = el.Attribute("realm")) != null) { if (tempAttr.Value == "yes") { world.IsRealm = true; } else { Logger.Log(LogType.Warning, "WorldManager: Could not parse \"realm\" attribute of world \"{0}\", assuming NOT a realm.", worldName); } } if ((tempAttr = el.Attribute("hidden")) != null) { bool isHidden; if (Boolean.TryParse(tempAttr.Value, out isHidden)) { world.IsHidden = isHidden; } else { Logger.Log(LogType.Warning, "WorldManager: Could not parse \"hidden\" attribute of world \"{0}\", assuming NOT hidden.", worldName); } } if ((tempAttr = el.Attribute("visitCount")) != null) { int vCount; if (Int32.TryParse(tempAttr.Value, out vCount)) { world.VisitCount = vCount; } else { Logger.Log(LogType.Warning, "WorldManager: Could not parse \"VisitCount\" attribute of world \"{0}\", assuming NO Visits.", worldName); } } if (firstWorld == null) { firstWorld = world; } XElement tempEl; if ((tempEl = el.Element(AccessSecurityXmlTagName)) != null) { world.AccessSecurity = new SecurityController(tempEl, true); } else if ((tempEl = el.Element("accessSecurity")) != null) { world.AccessSecurity = new SecurityController(tempEl, true); } if ((tempEl = el.Element(BuildSecurityXmlTagName)) != null) { world.BuildSecurity = new SecurityController(tempEl, true); } else if ((tempEl = el.Element("buildSecurity")) != null) { world.BuildSecurity = new SecurityController(tempEl, true); } if ((tempAttr = el.Attribute("backup")) != null) { TimeSpan backupInterval; if (tempAttr.Value.ToTimeSpan(out backupInterval)) { world.BackupInterval = backupInterval; } else { world.BackupInterval = World.DefaultBackupInterval; Logger.Log(LogType.Warning, "WorldManager: Could not parse \"backup\" attribute of world \"{0}\", assuming default ({1}).", worldName, world.BackupInterval.ToMiniString()); } } else { world.BackupInterval = World.DefaultBackupInterval; } XElement blockEl = el.Element(BlockDB.XmlRootName); if (blockEl != null) { world.BlockDB.LoadSettings(blockEl); } XElement envEl = el.Element(EnvironmentXmlTagName); if (envEl != null) { if ((tempAttr = envEl.Attribute("cloud")) != null) { if (!Int32.TryParse(tempAttr.Value, out world.CloudColor)) { world.CloudColor = -1; Logger.Log(LogType.Warning, "WorldManager: Could not parse \"cloud\" attribute of Environment settings for world \"{0}\", assuming default (normal).", worldName); } } if ((tempAttr = envEl.Attribute("terrain")) != null) { world.Terrain = envEl.Attribute("terrain").Value; } if ((tempAttr = envEl.Attribute("fog")) != null) { if (!Int32.TryParse(tempAttr.Value, out world.FogColor)) { world.FogColor = -1; Logger.Log(LogType.Warning, "WorldManager: Could not parse \"fog\" attribute of Environment settings for world \"{0}\", assuming default (normal).", worldName); } } if ((tempAttr = envEl.Attribute("sky")) != null) { if (!Int32.TryParse(tempAttr.Value, out world.SkyColor)) { world.SkyColor = -1; Logger.Log(LogType.Warning, "WorldManager: Could not parse \"sky\" attribute of Environment settings for world \"{0}\", assuming default (normal).", worldName); } } if ((tempAttr = envEl.Attribute("level")) != null) { if (!Int32.TryParse(tempAttr.Value, out world.EdgeLevel)) { world.EdgeLevel = -1; Logger.Log(LogType.Warning, "WorldManager: Could not parse \"level\" attribute of Environment settings for world \"{0}\", assuming default (normal).", worldName); } } if ((tempAttr = envEl.Attribute("edge")) != null) { Block block = Map.GetBlockByName(tempAttr.Value); if (block == Block.Undefined) { world.EdgeBlock = Block.Water; Logger.Log(LogType.Warning, "WorldManager: Could not parse \"edge\" attribute of Environment settings for world \"{0}\", assuming default (Water).", worldName); } else { world.EdgeBlock = block; } } if ((tempAttr = envEl.Attribute("side")) != null) { Block block = Map.GetBlockByName(tempAttr.Value); if (block == Block.Undefined) { world.EdgeBlock = Block.Admincrete; Logger.Log(LogType.Warning, "WorldManager: Could not parse \"side\" attribute of Environment settings for world \"{0}\", assuming default (Admincrete).", worldName); } else { world.SideBlock = block; } } if ((tempAttr = envEl.Attribute("cloudCC")) != null) { world.CloudColor = System.Drawing.ColorTranslator.FromHtml(tempAttr.Value).ToArgb(); } if ((tempAttr = envEl.Attribute("fogCC")) != null) { world.FogColor = System.Drawing.ColorTranslator.FromHtml(tempAttr.Value).ToArgb(); } if ((tempAttr = envEl.Attribute("skyCC")) != null) { world.SkyColor = System.Drawing.ColorTranslator.FromHtml(tempAttr.Value).ToArgb(); } if ((tempAttr = envEl.Attribute("levelCC")) != null) { world.EdgeLevel = Convert.ToInt16(tempAttr.Value); } if ((tempAttr = envEl.Attribute("edgeCC")) != null) { world.EdgeBlock = (Block)Byte.Parse(tempAttr.Value); } if ((tempAttr = envEl.Attribute("sideCC")) != null) { world.SideBlock = (Block)Byte.Parse(tempAttr.Value); } if ((tempAttr = envEl.Attribute("textureCC")) != null) { world.textureURL = tempAttr.Value; } if ((tempAttr = envEl.Attribute("hacks")) != null) { world.Hax = Convert.ToBoolean(tempAttr.Value); } } foreach (XElement mainedRankEl in el.Elements(RankMainXmlTagName)) { Rank rank = Rank.Parse(mainedRankEl.Value); if (rank != null) { if (rank < world.AccessSecurity.MinRank) { world.AccessSecurity.MinRank = rank; Logger.Log(LogType.Warning, "WorldManager: Lowered access MinRank of world {0} to allow it to be the main world for that rank.", rank.Name); } rank.MainWorld = world; } } CheckMapFile(world); }