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() {
|
public static void LoadGlobal() {
|
||||||
BlockDefinition[] oldDefs = GlobalDefs;
|
BlockDefinition[] oldDefs = GlobalDefs;
|
||||||
GlobalDefs = Load(true, null);
|
GlobalDefs = Load(true, null);
|
||||||
GlobalDefs[0] = new BlockDefinition();
|
GlobalDefs[Block.air] = DefaultSet.MakeCustomBlock(Block.air);
|
||||||
GlobalDefs[0].Name = "Air fallback";
|
GlobalDefs[Block.air].Name = "Air fallback";
|
||||||
|
|
||||||
GlobalProps = new BlockProps[Block.Count];
|
GlobalProps = new BlockProps[Block.Count];
|
||||||
for (int i = 0; i < Block.Count; i++)
|
for (int i = 0; i < Block.Count; i++)
|
||||||
|
@ -27,7 +27,7 @@ namespace MCGalaxy.Blocks.Physics {
|
|||||||
lvl.IntToPos(C.b, out x, out y, out z);
|
lvl.IntToPos(C.b, out x, out y, out z);
|
||||||
|
|
||||||
ActivateablePhysics.CheckNeighbours(lvl, x, y, z);
|
ActivateablePhysics.CheckNeighbours(lvl, x, y, z);
|
||||||
ActivateablePhysics.CheckAt(lvl, lvl.PosToInt(x, (ushort)(y - 1), z));
|
ActivateablePhysics.CheckAt(lvl, lvl.PosToInt(x, (ushort)(y - 1), z));
|
||||||
|
|
||||||
//Edge of map water
|
//Edge of map water
|
||||||
if (lvl.edgeWater && (y < lvl.EdgeLevel && y >= (lvl.EdgeLevel + lvl.SidesOffset))) {
|
if (lvl.edgeWater && (y < lvl.EdgeLevel && y >= (lvl.EdgeLevel + lvl.SidesOffset))) {
|
||||||
|
@ -108,7 +108,7 @@ namespace MCGalaxy.Commands.CPE {
|
|||||||
case "edge":
|
case "edge":
|
||||||
case "water":
|
case "water":
|
||||||
LevelEnv.SetBlock(p, value, EnvProp.EdgeBlock,
|
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 "side":
|
||||||
case "border":
|
case "border":
|
||||||
case "bedrock":
|
case "bedrock":
|
||||||
@ -130,7 +130,7 @@ namespace MCGalaxy.Commands.CPE {
|
|||||||
LevelEnv.SetWeather(p, lvl, "normal");
|
LevelEnv.SetWeather(p, lvl, "normal");
|
||||||
|
|
||||||
LevelEnv.SetBlock(p, "normal", EnvProp.EdgeBlock,
|
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,
|
LevelEnv.SetBlock(p, "normal", EnvProp.SidesBlock,
|
||||||
"sides block", Block.blackrock, ref lvl.EdgeBlock);
|
"sides block", Block.blackrock, ref lvl.EdgeBlock);
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
or implied. See the Licenses for the specific language governing
|
or implied. See the Licenses for the specific language governing
|
||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using MCGalaxy.Network;
|
using MCGalaxy.Network;
|
||||||
|
|
||||||
@ -22,35 +22,20 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
public static class BlockQueue {
|
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;
|
public static int blockupdates = 250;
|
||||||
static System.Timers.Timer blocktimer = new System.Timers.Timer(100);
|
|
||||||
static bool started = false;
|
|
||||||
static BufferedBlockSender bulkSender = new BufferedBlockSender();
|
static BufferedBlockSender bulkSender = new BufferedBlockSender();
|
||||||
|
|
||||||
public static void Start() {
|
public static void Loop(SchedulerTask task) {
|
||||||
blocktimer.Elapsed += delegate {
|
Level[] loaded = LevelInfo.Loaded.Items;
|
||||||
if (started) return;
|
foreach (Level lvl in loaded) {
|
||||||
started = true;
|
lock (lvl.queueLock)
|
||||||
try {
|
ProcessLevelBlocks(lvl);
|
||||||
Level[] loaded = LevelInfo.Loaded.Items;
|
}
|
||||||
foreach (Level lvl in loaded) {
|
|
||||||
lock (lvl.queueLock)
|
bulkSender.level = null;
|
||||||
ProcessLevelBlocks(lvl);
|
task.Delay = TimeSpan.FromMilliseconds(time);
|
||||||
}
|
|
||||||
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; }
|
|
||||||
|
|
||||||
public static void Addblock(Player p, int index, byte type, byte extType = 0) {
|
public static void Addblock(Player p, int index, byte type, byte extType = 0) {
|
||||||
if (index == -1) return;
|
if (index == -1) return;
|
||||||
@ -71,16 +56,18 @@ namespace MCGalaxy {
|
|||||||
static void ProcessLevelBlocks(Level lvl) {
|
static void ProcessLevelBlocks(Level lvl) {
|
||||||
try {
|
try {
|
||||||
if (lvl.blockqueue.Count == 0) return;
|
if (lvl.blockqueue.Count == 0) return;
|
||||||
|
if (!lvl.HasPlayers()) { lvl.blockqueue.Clear(); return; }
|
||||||
|
|
||||||
bulkSender.level = lvl;
|
bulkSender.level = lvl;
|
||||||
int count = blockupdates;
|
int count = blockupdates;
|
||||||
if (lvl.blockqueue.Count < blockupdates || !lvl.HasPlayers())
|
if (lvl.blockqueue.Count < blockupdates)
|
||||||
count = lvl.blockqueue.Count;
|
count = lvl.blockqueue.Count;
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
ulong flags = lvl.blockqueue[i];
|
ulong flags = lvl.blockqueue[i];
|
||||||
int index = (int)(flags >> 32);
|
int index = (int)(flags >> 32);
|
||||||
byte block = (flags & 0x100) != 0 ? Block.custom_block : (byte)flags;
|
byte block = (flags & 0x100) != 0 ? Block.custom_block : (byte)flags;
|
||||||
byte extBlock = (flags & 0x100) != 0 ? (byte)flags : Block.air;
|
byte extBlock = (flags & 0x100) != 0 ? (byte)flags : Block.air;
|
||||||
bulkSender.Add(index, block, extBlock);
|
bulkSender.Add(index, block, extBlock);
|
||||||
}
|
}
|
||||||
bulkSender.Send(true);
|
bulkSender.Send(true);
|
||||||
|
@ -128,7 +128,8 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
InitZombieSurvival();
|
InitZombieSurvival();
|
||||||
InitLavaSurvival();
|
InitLavaSurvival();
|
||||||
BlockQueue.Start();
|
MainScheduler.QueueRepeat(BlockQueue.Loop, null,
|
||||||
|
TimeSpan.FromMilliseconds(BlockQueue.time));
|
||||||
|
|
||||||
Log("Finished setting up server, finding classicube.net url..");
|
Log("Finished setting up server, finding classicube.net url..");
|
||||||
ServerSetupFinished = true;
|
ServerSetupFinished = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user