mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 05:03:34 -04:00
Fix multiple zones not showing.
This commit is contained in:
parent
c557b4128c
commit
02a1d6aa58
@ -100,8 +100,7 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
unsafe static byte NextFreeId(PlayerBot bot) {
|
unsafe static byte NextFreeId(PlayerBot bot) {
|
||||||
byte* used = stackalloc byte[256];
|
byte* used = stackalloc byte[256];
|
||||||
for (int i = 0; i < 256; i++)
|
for (int i = 0; i < 256; i++) used[i] = 0;
|
||||||
used[i] = 0;
|
|
||||||
|
|
||||||
PlayerBot[] bots = bot.level.Bots.Items;
|
PlayerBot[] bots = bot.level.Bots.Items;
|
||||||
for (int i = 0; i < bots.Length; i++) {
|
for (int i = 0; i < bots.Length; i++) {
|
||||||
|
@ -72,7 +72,7 @@ namespace MCGalaxy.Commands.Moderation {
|
|||||||
zone.MaxY = (ushort)Math.Max(marks[0].Y, marks[1].Y);
|
zone.MaxY = (ushort)Math.Max(marks[0].Y, marks[1].Y);
|
||||||
zone.MaxZ = (ushort)Math.Max(marks[0].Z, marks[1].Z);
|
zone.MaxZ = (ushort)Math.Max(marks[0].Z, marks[1].Z);
|
||||||
|
|
||||||
p.level.Zones.Add(zone);
|
zone.AddTo(p.level);
|
||||||
p.level.Save(true);
|
p.level.Save(true);
|
||||||
Player.Message(p, "Created zone " + zone.ColoredName);
|
Player.Message(p, "Created zone " + zone.ColoredName);
|
||||||
return false;
|
return false;
|
||||||
@ -137,8 +137,9 @@ namespace MCGalaxy.Commands.Moderation {
|
|||||||
Level lvl = p.level;
|
Level lvl = p.level;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
for (int i = 0; i < lvl.Zones.Count; i++) {
|
Zone[] zones = lvl.Zones.Items;
|
||||||
Zone z = lvl.Zones[i];
|
for (int i = 0; i < zones.Length; i++) {
|
||||||
|
Zone z = zones[i];
|
||||||
if (!z.Contains(P.X, P.Y, P.Z)) continue;
|
if (!z.Contains(P.X, P.Y, P.Z)) continue;
|
||||||
found = true;
|
found = true;
|
||||||
|
|
||||||
@ -163,7 +164,8 @@ namespace MCGalaxy.Commands.Moderation {
|
|||||||
public override bool museumUsable { get { return false; } }
|
public override bool museumUsable { get { return false; } }
|
||||||
|
|
||||||
public override void Use(Player p, string message) {
|
public override void Use(Player p, string message) {
|
||||||
MultiPageOutput.Output(p, p.level.Zones, FormatZone, "ZoneList", "zones", message, true);
|
Zone[] zones = p.level.Zones.Items;
|
||||||
|
MultiPageOutput.Output(p, zones, FormatZone, "ZoneList", "zones", message, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static string FormatZone(Zone zone) {
|
static string FormatZone(Zone zone) {
|
||||||
|
@ -59,7 +59,8 @@ namespace MCGalaxy.Core {
|
|||||||
|
|
||||||
// TODO: unshow old zones here??
|
// TODO: unshow old zones here??
|
||||||
if (p.Supports(CpeExt.SelectionCuboid)) {
|
if (p.Supports(CpeExt.SelectionCuboid)) {
|
||||||
foreach (Zone zn in level.Zones) { zn.Show(p); }
|
Zone[] zones = level.Zones.Items;
|
||||||
|
foreach (Zone zn in zones) { zn.Show(p); }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!level.Config.Guns && p.aiming) {
|
if (!level.Config.Guns && p.aiming) {
|
||||||
|
@ -137,11 +137,11 @@ namespace MCGalaxy.Levels.IO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void WriteZonesSection(Level lvl, Stream gs, byte[] buffer) {
|
static void WriteZonesSection(Level lvl, Stream gs, byte[] buffer) {
|
||||||
List<Zone> zones = lvl.Zones;
|
Zone[] zones = lvl.Zones.Items;
|
||||||
if (zones.Count == 0) return;
|
if (zones.Length == 0) return;
|
||||||
|
|
||||||
gs.WriteByte(0x51);
|
gs.WriteByte(0x51);
|
||||||
NetUtils.WriteI32(zones.Count, buffer, 0);
|
NetUtils.WriteI32(zones.Length, buffer, 0);
|
||||||
gs.Write(buffer, 0, sizeof(int));
|
gs.Write(buffer, 0, sizeof(int));
|
||||||
|
|
||||||
foreach (Zone z in zones) {
|
foreach (Zone z in zones) {
|
||||||
|
@ -164,7 +164,7 @@ namespace MCGalaxy.Levels.IO {
|
|||||||
ConfigElement.Parse(elems, key, value, z.Config);
|
ConfigElement.Parse(elems, key, value, z.Config);
|
||||||
}
|
}
|
||||||
|
|
||||||
lvl.Zones.Add(z);
|
z.AddTo(lvl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,19 +199,20 @@ namespace MCGalaxy {
|
|||||||
public bool CheckAffectPermissions(Player p, ushort x, ushort y, ushort z, ExtBlock old, ExtBlock block) {
|
public bool CheckAffectPermissions(Player p, ushort x, ushort y, ushort z, ExtBlock old, ExtBlock block) {
|
||||||
if (!p.group.Blocks[old.BlockID] && !Block.AllowBreak(old.BlockID) && !Block.BuildIn(old.BlockID)) return false;
|
if (!p.group.Blocks[old.BlockID] && !Block.AllowBreak(old.BlockID) && !Block.BuildIn(old.BlockID)) return false;
|
||||||
if (p.PlayingTntWars && !CheckTNTWarsChange(p, x, y, z, ref block.BlockID)) return false;
|
if (p.PlayingTntWars && !CheckTNTWarsChange(p, x, y, z, ref block.BlockID)) return false;
|
||||||
if (Zones.Count == 0) return CheckRank(p);
|
Zone[] zones = Zones.Items;
|
||||||
|
if (zones.Length == 0) return CheckRank(p);
|
||||||
|
|
||||||
// Check zones specifically allowed in
|
// Check zones specifically allowed in
|
||||||
for (int i = 0; i < Zones.Count; i++) {
|
for (int i = 0; i < zones.Length; i++) {
|
||||||
Zone zn = Zones[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;
|
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);
|
AccessResult access = zn.Access.Check(p);
|
||||||
if (access == AccessResult.Allowed || access == AccessResult.Whitelisted) return true;
|
if (access == AccessResult.Allowed || access == AccessResult.Whitelisted) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check zones denied from
|
// Check zones denied from
|
||||||
for (int i = 0; i < Zones.Count; i++) {
|
for (int i = 0; i < zones.Length; i++) {
|
||||||
Zone zn = Zones[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;
|
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);
|
AccessResult access = zn.Access.Check(p);
|
||||||
if (access == AccessResult.Allowed || access == AccessResult.Whitelisted) continue;
|
if (access == AccessResult.Allowed || access == AccessResult.Whitelisted) continue;
|
||||||
|
@ -75,7 +75,7 @@ namespace MCGalaxy {
|
|||||||
BufferedBlockSender bulkSender;
|
BufferedBlockSender bulkSender;
|
||||||
|
|
||||||
public List<UndoPos> UndoBuffer = new List<UndoPos>();
|
public List<UndoPos> UndoBuffer = new List<UndoPos>();
|
||||||
public List<Zone> Zones;
|
public VolatileArray<Zone> Zones = new VolatileArray<Zone>();
|
||||||
public bool backedup;
|
public bool backedup;
|
||||||
public BlockDB BlockDB;
|
public BlockDB BlockDB;
|
||||||
public LevelAccessController VisitAccess, BuildAccess;
|
public LevelAccessController VisitAccess, BuildAccess;
|
||||||
|
@ -73,7 +73,6 @@ namespace MCGalaxy {
|
|||||||
spawnz = (ushort)(Length / 2);
|
spawnz = (ushort)(Length / 2);
|
||||||
rotx = 0; roty = 0;
|
rotx = 0; roty = 0;
|
||||||
|
|
||||||
Zones = new List<Zone>();
|
|
||||||
VisitAccess = new LevelAccessController(this, true);
|
VisitAccess = new LevelAccessController(this, true);
|
||||||
BuildAccess = new LevelAccessController(this, false);
|
BuildAccess = new LevelAccessController(this, false);
|
||||||
listCheckExists = new SparseBitSet(Width, Height, Length);
|
listCheckExists = new SparseBitSet(Width, Height, Length);
|
||||||
@ -105,7 +104,8 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Zone FindZoneExact(string name) {
|
public Zone FindZoneExact(string name) {
|
||||||
foreach (Zone zone in Zones) {
|
Zone[] zones = Zones.Items;
|
||||||
|
foreach (Zone zone in zones) {
|
||||||
if (zone.Config.Name.CaselessEq(name)) return zone;
|
if (zone.Config.Name.CaselessEq(name)) return zone;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -68,7 +68,7 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
z.Config.Name = "Zone" + id;
|
z.Config.Name = "Zone" + id;
|
||||||
id++;
|
id++;
|
||||||
level.Zones.Add(z);
|
z.AddTo(level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using MCGalaxy.Config;
|
using MCGalaxy.Config;
|
||||||
using MCGalaxy.Network;
|
|
||||||
using MCGalaxy.Maths;
|
using MCGalaxy.Maths;
|
||||||
|
using MCGalaxy.Network;
|
||||||
|
|
||||||
namespace MCGalaxy {
|
namespace MCGalaxy {
|
||||||
|
|
||||||
@ -99,6 +99,12 @@ namespace MCGalaxy {
|
|||||||
public ZoneAccessController Access;
|
public ZoneAccessController Access;
|
||||||
public string ColoredName { get { return Config.Color + Config.Name; } }
|
public string ColoredName { get { return Config.Color + Config.Name; } }
|
||||||
|
|
||||||
|
public Zone(Level lvl) {
|
||||||
|
Config = new ZoneConfig();
|
||||||
|
Access = new ZoneAccessController(lvl, Config);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public bool Contains(int x, int y, int z) {
|
public bool Contains(int x, int y, int z) {
|
||||||
return x >= MinX && x <= MaxX && y >= MinY && y <= MaxY && z >= MinZ && z <= MaxZ;
|
return x >= MinX && x <= MaxX && y >= MinY && y <= MaxY && z >= MinZ && z <= MaxZ;
|
||||||
}
|
}
|
||||||
@ -126,9 +132,27 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Zone(Level lvl) {
|
public void AddTo(Level level) {
|
||||||
Config = new ZoneConfig();
|
lock (level.Zones.locker) {
|
||||||
Access = new ZoneAccessController(lvl, Config);
|
ID = NextFreeZoneId(level);
|
||||||
|
level.Zones.Add(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe byte NextFreeZoneId(Level level) {
|
||||||
|
byte* used = stackalloc byte[256];
|
||||||
|
for (int i = 0; i < 256; i++) used[i] = 0;
|
||||||
|
|
||||||
|
Zone[] zones = level.Zones.Items;
|
||||||
|
for (int i = 0; i < zones.Length; i++) {
|
||||||
|
byte id = zones[i].ID;
|
||||||
|
used[id] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (byte i = 0; i <= 255; i++ ) {
|
||||||
|
if (used[i] == 0) return i;
|
||||||
|
}
|
||||||
|
return 255;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -176,8 +176,7 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
unsafe static byte NextFreeId() {
|
unsafe static byte NextFreeId() {
|
||||||
byte* used = stackalloc byte[256];
|
byte* used = stackalloc byte[256];
|
||||||
for (int i = 0; i < 256; i++)
|
for (int i = 0; i < 256; i++) used[i] = 0;
|
||||||
used[i] = 0;
|
|
||||||
|
|
||||||
Player[] players = PlayerInfo.Online.Items;
|
Player[] players = PlayerInfo.Online.Items;
|
||||||
for (int i = 0; i < players.Length; i++) {
|
for (int i = 0; i < players.Length; i++) {
|
||||||
|
@ -90,7 +90,7 @@ namespace MCGalaxy {
|
|||||||
/// <summary> Find partial matches of 'name' against the list of zones in a map. </summary>
|
/// <summary> Find partial matches of 'name' against the list of zones in a map. </summary>
|
||||||
public static Zone FindZones(Player p, Level lvl, string name) {
|
public static Zone FindZones(Player p, Level lvl, string name) {
|
||||||
int matches = 0;
|
int matches = 0;
|
||||||
return Find<Zone>(p, name, out matches, lvl.Zones,
|
return Find<Zone>(p, name, out matches, lvl.Zones.Items,
|
||||||
null, z => z.Config.Name, "zones");
|
null, z => z.Config.Name, "zones");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user