Optimise common case of zone permissions check returning true to be much faster

This commit is contained in:
UnknownShadow200 2018-01-28 17:18:24 +11:00
parent 73d9fd14bb
commit 7ffef91aab
2 changed files with 9 additions and 3 deletions

View File

@ -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; }

View File

@ -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