static bool LoadOfflineLevel(Player p, string map) { string propsPath = LevelInfo.PropsPath(map); LevelConfig cfg = new LevelConfig(); cfg.Load(propsPath); if (!cfg.LoadOnGoto) { p.Message("Level \"{0}\" cannot be loaded using %T/Goto.", map); return(false); } AccessController visitAccess = new LevelAccessController(cfg, map, true); bool skip = p.summonedMap != null && p.summonedMap.CaselessEq(map); LevelPermission plRank = skip ? LevelPermission.Nobody : p.Rank; if (!visitAccess.CheckDetailed(p, plRank)) { return(false); } LevelActions.Load(p, map, false); Level lvl = LevelInfo.FindExact(map); if (lvl != null) { return(GotoLevel(p, lvl)); } p.Message("Level \"{0}\" failed to be auto-loaded.", map); return(false); }
internal static bool ValidateAction(Player p, string map, string action) { if (p == null) { return(true); } LevelAccessController visit, build; Level lvl = null; LevelConfig cfg = GetConfig(map, out lvl); if (lvl != null) { visit = lvl.VisitAccess; build = lvl.BuildAccess; } else { visit = new LevelAccessController(cfg, map, true); build = new LevelAccessController(cfg, map, false); } if (!visit.CheckDetailed(p) || !build.CheckDetailed(p)) { Player.Message(p, "Hence, you cannot {0}.", action); return(false); } return(true); }
static bool LoadOfflineLevel(Player p, string name) { string propsPath = LevelInfo.PropertiesPath(name); LevelConfig cfg = new LevelConfig(); LevelConfig.Load(propsPath, cfg); if (!cfg.LoadOnGoto) { Player.Message(p, "Level \"{0}\" cannot be loaded using %T/Goto.", name); return(false); } LevelAccessController visitAccess = new LevelAccessController(cfg, name, true); bool ignorePerms = p.summonedMap != null && p.summonedMap.CaselessEq(name); if (!visitAccess.CheckDetailed(p, ignorePerms)) { return(false); } CmdLoad.LoadLevel(p, name, true); Level lvl = LevelInfo.FindExact(name); if (lvl != null) { return(GotoLevel(p, lvl)); } Player.Message(p, "Level \"{0}\" failed to be auto-loaded.", name); return(false); }
void Init(string n, ushort x, ushort y, ushort z) { Width = x; Height = y; Length = z; if (Width < 16) { Width = 16; } if (Height < 16) { Height = 16; } if (Length < 16) { Length = 16; } #pragma warning disable 0612 width = Width; length = Height; height = Length; depth = Length; #pragma warning restore 0612 CustomBlockDefs = new BlockDefinition[256]; for (int i = 0; i < CustomBlockDefs.Length; i++) { CustomBlockDefs[i] = BlockDefinition.GlobalDefs[i]; } CustomBlockProps = new BlockProps[256]; for (int i = 0; i < CustomBlockProps.Length; i++) { CustomBlockProps[i] = BlockDefinition.GlobalProps[i]; } name = n; BlockDB = new BlockDB(this); EdgeLevel = (short)(y / 2); CloudsHeight = (short)(y + 2); blocks = new byte[Width * Height * Length]; ChunksX = (Width + 15) >> 4; ChunksY = (Height + 15) >> 4; ChunksZ = (Length + 15) >> 4; CustomBlocks = new byte[ChunksX * ChunksY * ChunksZ][]; spawnx = (ushort)(Width / 2); spawny = (ushort)(Height * 0.75f); spawnz = (ushort)(Length / 2); rotx = 0; roty = 0; ZoneList = new List <Zone>(); VisitAccess = new LevelAccessController(this, true); BuildAccess = new LevelAccessController(this, false); listCheckExists = new SparseBitSet(Width, Height, Length); listUpdateExists = new SparseBitSet(Width, Height, Length); }
internal void Init(string name, ushort width, ushort height, ushort length) { if (width < 1) { width = 1; } if (height < 1) { height = 1; } if (length < 1) { length = 1; } Width = width; Height = height; Length = length; for (int i = 0; i < CustomBlockDefs.Length; i++) { CustomBlockDefs[i] = BlockDefinition.GlobalDefs[i]; } if (blocks == null) { blocks = new byte[width * height * length]; } LoadDefaultProps(); for (int i = 0; i < blockAABBs.Length; i++) { blockAABBs[i] = Block.BlockAABB((ushort)i, this); } UpdateAllBlockHandlers(); this.name = name; MapName = name.ToLower(); BlockDB = new BlockDB(this); ChunksX = Utils.CeilDiv16(width); ChunksY = Utils.CeilDiv16(height); ChunksZ = Utils.CeilDiv16(length); if (CustomBlocks == null) { CustomBlocks = new byte[ChunksX * ChunksY * ChunksZ][]; } spawnx = (ushort)(width / 2); spawny = (ushort)(height * 0.75f); spawnz = (ushort)(length / 2); rotx = 0; roty = 0; VisitAccess = new LevelAccessController(Config, name, true); BuildAccess = new LevelAccessController(Config, name, false); listCheckExists = new SparseBitSet(width, height, length); listUpdateExists = new SparseBitSet(width, height, length); }
public Level(string name, ushort width, ushort height, ushort length) { if (width < 1) { width = 1; } if (height < 1) { height = 1; } if (length < 1) { length = 1; } Width = width; Height = height; Length = length; for (int i = 0; i < CustomBlockDefs.Length; i++) { CustomBlockDefs[i] = BlockDefinition.GlobalDefs[i]; } LoadCoreProps(); for (int i = 0; i < blockAABBs.Length; i++) { ExtBlock block = ExtBlock.FromIndex(i); blockAABBs[i] = Block.BlockAABB(block, this); } UpdateBlockHandlers(); this.name = name; MapName = name.ToLower(); BlockDB = new BlockDB(this); Config.EdgeLevel = (short)(height / 2); Config.CloudsHeight = (short)(height + 2); blocks = new byte[Width * Height * Length]; ChunksX = Utils.CeilDiv16(Width); ChunksY = Utils.CeilDiv16(Height); ChunksZ = Utils.CeilDiv16(Length); CustomBlocks = new byte[ChunksX * ChunksY * ChunksZ][]; spawnx = (ushort)(Width / 2); spawny = (ushort)(Height * 0.75f); spawnz = (ushort)(Length / 2); rotx = 0; roty = 0; VisitAccess = new LevelAccessController(this, true); BuildAccess = new LevelAccessController(this, false); listCheckExists = new SparseBitSet(Width, Height, Length); listUpdateExists = new SparseBitSet(Width, Height, Length); }
public static bool Check(Player p, LevelPermission plRank, string map, string action, out LevelConfig cfg) { Level lvl; cfg = GetConfig(map, out lvl); if (p.IsConsole) { return(true); } if (lvl != null) { return(Check(p, plRank, lvl, action)); } AccessController visit = new LevelAccessController(cfg, map, true); AccessController build = new LevelAccessController(cfg, map, false); if (!visit.CheckDetailed(p, plRank) || !build.CheckDetailed(p, plRank)) { p.Message("Hence, you cannot {0}.", action); return(false); } return(true); }