From 7ffef91aab2b3a51f04231c90aba83835740b3bc Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 28 Jan 2018 17:18:24 +1100 Subject: [PATCH] Optimise common case of zone permissions check returning true to be much faster --- MCGalaxy/Commands/Moderation/ZoneCmds.cs | 5 ++++- MCGalaxy/Levels/Level.Blocks.cs | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/MCGalaxy/Commands/Moderation/ZoneCmds.cs b/MCGalaxy/Commands/Moderation/ZoneCmds.cs index b0c22ca26..a2a7a7c1f 100644 --- a/MCGalaxy/Commands/Moderation/ZoneCmds.cs +++ b/MCGalaxy/Commands/Moderation/ZoneCmds.cs @@ -199,7 +199,10 @@ namespace MCGalaxy.Commands.Moderation { public override string shortcut { get { return "ZMark"; } } public override string type { get { return CommandTypes.Building; } } public override bool museumUsable { get { return false; } } - + public override CommandAlias[] Aliases { + get { return new[] { new CommandAlias("zm") }; } + } + public override void Use(Player p, string message) { if (message.Length == 0) { Help(p); return; } diff --git a/MCGalaxy/Levels/Level.Blocks.cs b/MCGalaxy/Levels/Level.Blocks.cs index 45eee6be9..231984197 100644 --- a/MCGalaxy/Levels/Level.Blocks.cs +++ b/MCGalaxy/Levels/Level.Blocks.cs @@ -16,6 +16,7 @@ permissions and limitations under the Licenses. */ using System; +using System.Collections.Generic; using MCGalaxy.Blocks; using MCGalaxy.Blocks.Physics; using MCGalaxy.DB; @@ -206,8 +207,10 @@ namespace MCGalaxy { for (int i = 0; i < zones.Length; i++) { Zone zn = zones[i]; if (x < zn.MinX || x > zn.MaxX || y < zn.MinY || y > zn.MaxY || z < zn.MinZ || z > zn.MaxZ) continue; - AccessResult access = zn.Access.Check(p); - if (access == AccessResult.Allowed || access == AccessResult.Whitelisted) return true; + + ZoneConfig cfg = zn.Config; + if (p.group.Permission >= cfg.BuildMin) return true; + if (cfg.BuildWhitelist.Count > 0 && cfg.BuildWhitelist.CaselessContains(p.name)) return true; } // Check zones denied from