mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 04:32:50 -04:00
Fix /lb remove 0 stuffing up (Thanks fam0r), blockqueue is now a scheduled task.
This commit is contained in:
parent
4de5512aad
commit
7a46a30c47
@ -117,8 +117,8 @@ namespace MCGalaxy {
|
||||
public static void LoadGlobal() {
|
||||
BlockDefinition[] oldDefs = GlobalDefs;
|
||||
GlobalDefs = Load(true, null);
|
||||
GlobalDefs[0] = new BlockDefinition();
|
||||
GlobalDefs[0].Name = "Air fallback";
|
||||
GlobalDefs[Block.air] = DefaultSet.MakeCustomBlock(Block.air);
|
||||
GlobalDefs[Block.air].Name = "Air fallback";
|
||||
|
||||
GlobalProps = new BlockProps[Block.Count];
|
||||
for (int i = 0; i < Block.Count; i++)
|
||||
|
@ -108,7 +108,7 @@ namespace MCGalaxy.Commands.CPE {
|
||||
case "edge":
|
||||
case "water":
|
||||
LevelEnv.SetBlock(p, value, EnvProp.EdgeBlock,
|
||||
"edge block", Block.waterstill, ref lvl.HorizonBlock); break;
|
||||
"edge block", Block.water, ref lvl.HorizonBlock); break;
|
||||
case "side":
|
||||
case "border":
|
||||
case "bedrock":
|
||||
@ -130,7 +130,7 @@ namespace MCGalaxy.Commands.CPE {
|
||||
LevelEnv.SetWeather(p, lvl, "normal");
|
||||
|
||||
LevelEnv.SetBlock(p, "normal", EnvProp.EdgeBlock,
|
||||
"edge block", Block.waterstill, ref lvl.HorizonBlock);
|
||||
"edge block", Block.water, ref lvl.HorizonBlock);
|
||||
LevelEnv.SetBlock(p, "normal", EnvProp.SidesBlock,
|
||||
"sides block", Block.blackrock, ref lvl.EdgeBlock);
|
||||
|
||||
|
@ -22,35 +22,20 @@ namespace MCGalaxy {
|
||||
|
||||
public static class BlockQueue {
|
||||
|
||||
public static int time { get { return (int)blocktimer.Interval; } set { blocktimer.Interval = value; } }
|
||||
public static int time = 100;
|
||||
public static int blockupdates = 250;
|
||||
static System.Timers.Timer blocktimer = new System.Timers.Timer(100);
|
||||
static bool started = false;
|
||||
static BufferedBlockSender bulkSender = new BufferedBlockSender();
|
||||
|
||||
public static void Start() {
|
||||
blocktimer.Elapsed += delegate {
|
||||
if (started) return;
|
||||
started = true;
|
||||
try {
|
||||
public static void Loop(SchedulerTask task) {
|
||||
Level[] loaded = LevelInfo.Loaded.Items;
|
||||
foreach (Level lvl in loaded) {
|
||||
lock (lvl.queueLock)
|
||||
ProcessLevelBlocks(lvl);
|
||||
}
|
||||
bulkSender.level = null;
|
||||
} catch (Exception ex) {
|
||||
Server.ErrorLog(ex);
|
||||
throw;
|
||||
} finally {
|
||||
started = false;
|
||||
}
|
||||
};
|
||||
blocktimer.Start();
|
||||
}
|
||||
|
||||
public static void Pause() { blocktimer.Enabled = false; }
|
||||
public static void Resume() { blocktimer.Enabled = true; }
|
||||
bulkSender.level = null;
|
||||
task.Delay = TimeSpan.FromMilliseconds(time);
|
||||
}
|
||||
|
||||
public static void Addblock(Player p, int index, byte type, byte extType = 0) {
|
||||
if (index == -1) return;
|
||||
@ -71,9 +56,11 @@ namespace MCGalaxy {
|
||||
static void ProcessLevelBlocks(Level lvl) {
|
||||
try {
|
||||
if (lvl.blockqueue.Count == 0) return;
|
||||
if (!lvl.HasPlayers()) { lvl.blockqueue.Clear(); return; }
|
||||
|
||||
bulkSender.level = lvl;
|
||||
int count = blockupdates;
|
||||
if (lvl.blockqueue.Count < blockupdates || !lvl.HasPlayers())
|
||||
if (lvl.blockqueue.Count < blockupdates)
|
||||
count = lvl.blockqueue.Count;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
|
@ -128,7 +128,8 @@ namespace MCGalaxy {
|
||||
|
||||
InitZombieSurvival();
|
||||
InitLavaSurvival();
|
||||
BlockQueue.Start();
|
||||
MainScheduler.QueueRepeat(BlockQueue.Loop, null,
|
||||
TimeSpan.FromMilliseconds(BlockQueue.time));
|
||||
|
||||
Log("Finished setting up server, finding classicube.net url..");
|
||||
ServerSetupFinished = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user