mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-29 08:32:14 -04:00
Fix not being able to place blocks in other maps when zombie survival is active, also Blockqueue now uses BulkBlockUpdate if applicable.
This commit is contained in:
parent
6fd3f50914
commit
5687901de6
@ -55,7 +55,7 @@ namespace MCGalaxy.Commands
|
|||||||
else upTime += up.Seconds + " seconds";
|
else upTime += up.Seconds + " seconds";
|
||||||
Player.SendMessage(p, upTime);
|
Player.SendMessage(p, upTime);
|
||||||
if (Server.updateTimer.Interval > 1000) Player.SendMessage(p, "This server is currently in &5Low Lag" + Server.DefaultColor + " mode.");
|
if (Server.updateTimer.Interval > 1000) Player.SendMessage(p, "This server is currently in &5Low Lag" + Server.DefaultColor + " mode.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public override void Help(Player p)
|
public override void Help(Player p)
|
||||||
{
|
{
|
||||||
|
@ -24,7 +24,8 @@ namespace MCGalaxy.Games {
|
|||||||
|
|
||||||
public override bool HandlesManualChange(Player p, ushort x, ushort y, ushort z,
|
public override bool HandlesManualChange(Player p, ushort x, ushort y, ushort z,
|
||||||
byte action, byte tile, byte b) {
|
byte action, byte tile, byte b) {
|
||||||
|
if (Status == ZombieGameStatus.NotStarted
|
||||||
|
|| (p.level == null || !p.level.name.CaselessEq(CurrentLevelName))) return false;
|
||||||
if (CurrentLevel.BuildType == BuildType.NoModify) {
|
if (CurrentLevel.BuildType == BuildType.NoModify) {
|
||||||
p.RevertBlock(x, y, z); return true;
|
p.RevertBlock(x, y, z); return true;
|
||||||
} else if (CurrentLevel.BuildType == BuildType.ModifyOnly
|
} else if (CurrentLevel.BuildType == BuildType.ModifyOnly
|
||||||
@ -65,7 +66,8 @@ namespace MCGalaxy.Games {
|
|||||||
|
|
||||||
public override bool HandlesMovement(Player p, ushort x, ushort y, ushort z,
|
public override bool HandlesMovement(Player p, ushort x, ushort y, ushort z,
|
||||||
byte rotX, byte rotY) {
|
byte rotX, byte rotY) {
|
||||||
if (p.level == null || !p.level.name.CaselessEq(CurrentLevelName)) return false;
|
if (Status == ZombieGameStatus.NotStarted
|
||||||
|
|| (p.level == null || !p.level.name.CaselessEq(CurrentLevelName))) return false;
|
||||||
if (!p.referee && noRespawn) {
|
if (!p.referee && noRespawn) {
|
||||||
if (p.pos[0] >= x + 70 || p.pos[0] <= x - 70 ) {
|
if (p.pos[0] >= x + 70 || p.pos[0] <= x - 70 ) {
|
||||||
p.SendPos(0xFF, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1]);
|
p.SendPos(0xFF, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1]);
|
||||||
|
@ -24,6 +24,7 @@ namespace MCGalaxy {
|
|||||||
public static int blockupdates = 250;
|
public static int blockupdates = 250;
|
||||||
static System.Timers.Timer blocktimer = new System.Timers.Timer(100);
|
static System.Timers.Timer blocktimer = new System.Timers.Timer(100);
|
||||||
static bool started = false;
|
static bool started = false;
|
||||||
|
static BufferedBlockSender bulkSender = new BufferedBlockSender(null);
|
||||||
|
|
||||||
public static void Start() {
|
public static void Start() {
|
||||||
blocktimer.Elapsed += delegate {
|
blocktimer.Elapsed += delegate {
|
||||||
@ -33,6 +34,7 @@ namespace MCGalaxy {
|
|||||||
Level[] loaded = LevelInfo.Loaded.Items;
|
Level[] loaded = LevelInfo.Loaded.Items;
|
||||||
foreach (Level l in loaded)
|
foreach (Level l in loaded)
|
||||||
ProcessLevelBlocks(l);
|
ProcessLevelBlocks(l);
|
||||||
|
bulkSender.level = null;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Server.ErrorLog(ex);
|
Server.ErrorLog(ex);
|
||||||
throw;
|
throw;
|
||||||
@ -56,30 +58,35 @@ namespace MCGalaxy {
|
|||||||
p.level.blockqueue.Add(item);
|
p.level.blockqueue.Add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ProcessLevelBlocks(Level l) {
|
static void ProcessLevelBlocks(Level lvl) {
|
||||||
try {
|
try {
|
||||||
if (l.blockqueue.Count < 1) return;
|
if (lvl.blockqueue.Count < 1) return;
|
||||||
|
bulkSender.level = lvl;
|
||||||
int count = blockupdates;
|
int count = blockupdates;
|
||||||
if (l.blockqueue.Count < blockupdates || l.players.Count == 0)
|
if (lvl.blockqueue.Count < blockupdates || lvl.players.Count == 0)
|
||||||
count = l.blockqueue.Count;
|
count = lvl.blockqueue.Count;
|
||||||
Level.BlockPos bP = default(Level.BlockPos);
|
Level.BlockPos bP = default(Level.BlockPos);
|
||||||
|
|
||||||
for (int c = 0; c < count; c++) {
|
for (int c = 0; c < count; c++) {
|
||||||
block item = l.blockqueue[c];
|
block item = lvl.blockqueue[c];
|
||||||
bP.name = item.p.name;
|
bP.name = item.p.name;
|
||||||
ushort x, y, z;
|
ushort x, y, z;
|
||||||
l.IntToPos(item.index, out x, out y, out z);
|
lvl.IntToPos(item.index, out x, out y, out z);
|
||||||
|
|
||||||
bP.index = item.index;
|
bP.index = item.index;
|
||||||
bP.SetData(item.type, item.extType, item.type == 0);
|
bP.SetData(item.type, item.extType, item.type == 0);
|
||||||
l.Blockchange(item.p, x, y, z, item.type, item.extType);
|
if (lvl.DoBlockchange(item.p, x, y, z, item.type, item.extType)) {
|
||||||
l.blockCache.Add(bP);
|
bulkSender.Add(item.index, item.type, item.extType);
|
||||||
|
bulkSender.CheckIfSend(false);
|
||||||
|
lvl.blockCache.Add(bP);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
l.blockqueue.RemoveRange(0, count);
|
bulkSender.CheckIfSend(true);
|
||||||
|
lvl.blockqueue.RemoveRange(0, count);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Server.s.ErrorCase("error:" + e);
|
Server.s.ErrorCase("error:" + e);
|
||||||
Server.s.Log(String.Format("Block cache failed for map: {0}. {1} lost.", l.name, l.blockqueue.Count));
|
Server.s.Log(String.Format("Block cache failed for map: {0}. {1} lost.", lvl.name, lvl.blockqueue.Count));
|
||||||
l.blockqueue.Clear();
|
lvl.blockqueue.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ namespace MCGalaxy {
|
|||||||
int[] indices = new int[256];
|
int[] indices = new int[256];
|
||||||
byte[] types = new byte[256];
|
byte[] types = new byte[256];
|
||||||
int count = 0;
|
int count = 0;
|
||||||
Level level;
|
public Level level;
|
||||||
|
|
||||||
public BufferedBlockSender(Level level) {
|
public BufferedBlockSender(Level level) {
|
||||||
this.level = level;
|
this.level = level;
|
||||||
|
@ -951,7 +951,7 @@ Next: continue;
|
|||||||
internal void RemoveInvalidUndos() {
|
internal void RemoveInvalidUndos() {
|
||||||
UndoDrawOpEntry[] items = UndoDrawOps.Items;
|
UndoDrawOpEntry[] items = UndoDrawOps.Items;
|
||||||
for (int i = 0; i < items.Length; i++) {
|
for (int i = 0; i < items.Length; i++) {
|
||||||
if (!items[i].IsValid(p))
|
if (!items[i].IsValid(this))
|
||||||
UndoDrawOps.Remove(items[i]);
|
UndoDrawOps.Remove(items[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,12 +30,14 @@ namespace MCGalaxy.Util {
|
|||||||
|
|
||||||
public void SetStart(Player p) {
|
public void SetStart(Player p) {
|
||||||
StartNode = p.UndoBuffer.Tail;
|
StartNode = p.UndoBuffer.Tail;
|
||||||
StartIndex = StartNode.Items.Count;
|
if (StartNode != null)
|
||||||
|
StartIndex = StartNode.Items.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetEnd(Player p) {
|
public void SetEnd(Player p) {
|
||||||
EndNode = p.UndoBuffer.Tail;
|
EndNode = p.UndoBuffer.Tail;
|
||||||
EndIndex = EndNode.Items.Count;
|
if (EndNode != null)
|
||||||
|
EndIndex = EndNode.Items.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsValid(Player p) {
|
public bool IsValid(Player p) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user