mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 12:42:22 -04:00
Draw reload threshold is now based on size of map, fixes #472.
This commit is contained in:
parent
e5e565cbf1
commit
cf578efa4f
@ -25,16 +25,20 @@ namespace MCGalaxy.Commands.Maintenance {
|
|||||||
public override void Use(Player p, string message) {
|
public override void Use(Player p, string message) {
|
||||||
string[] args = message.SplitSpaces();
|
string[] args = message.SplitSpaces();
|
||||||
if (message == "") { Help(p); return; }
|
if (message == "") { Help(p); return; }
|
||||||
|
bool hasLimit = args.Length > 1;
|
||||||
|
|
||||||
|
if (args[0].CaselessEq("rt") || args[0].CaselessEq("reloadthreshold")) {
|
||||||
|
float threshold = 0;
|
||||||
|
if (hasLimit && !CommandParser.GetReal(p, args[1], "Limit", ref threshold, 0, 100)) return;
|
||||||
|
|
||||||
|
SetLimitPercent(p, ref ServerConfig.DrawReloadThreshold, threshold, hasLimit);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int limit = 0;
|
int limit = 0;
|
||||||
bool hasLimit = args.Length > 1;
|
|
||||||
if (hasLimit && !CommandParser.GetInt(p, args[1], "Limit", ref limit, 1)) return;
|
if (hasLimit && !CommandParser.GetInt(p, args[1], "Limit", ref limit, 1)) return;
|
||||||
|
|
||||||
switch (args[0].ToLower()) {
|
switch (args[0].ToLower()) {
|
||||||
case "rt":
|
|
||||||
case "reloadthreshold":
|
|
||||||
SetLimit(p, "Threshold before drawing reloads map", ref ServerConfig.DrawReloadLimit, limit, hasLimit);
|
|
||||||
return;
|
|
||||||
case "rp":
|
case "rp":
|
||||||
case "restartphysics":
|
case "restartphysics":
|
||||||
SetLimit(p, "Custom /rp limit", ref ServerConfig.PhysicsRestartLimit, limit, hasLimit);
|
SetLimit(p, "Custom /rp limit", ref ServerConfig.PhysicsRestartLimit, limit, hasLimit);
|
||||||
@ -72,12 +76,25 @@ namespace MCGalaxy.Commands.Maintenance {
|
|||||||
Group.SaveList(Group.GroupList);
|
Group.SaveList(Group.GroupList);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetLimit(Player p, string format, ref int target, int value, bool hasValue) {
|
static void SetLimitPercent(Player p, ref float target, float value, bool hasValue) {
|
||||||
|
const string type = "Threshold before drawing reloads map";
|
||||||
|
if (hasValue) target = value / 100.0f;
|
||||||
|
string percent = (target * 100).ToString("F2") + "%";
|
||||||
|
|
||||||
if (!hasValue) {
|
if (!hasValue) {
|
||||||
Player.Message(p, format + ": &b" + target);
|
Player.Message(p, type + ": &b" + percent);
|
||||||
|
} else {
|
||||||
|
Chat.MessageGlobal(type + " set to &b" + percent);
|
||||||
|
SrvProperties.Save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SetLimit(Player p, string type, ref int target, int value, bool hasValue) {
|
||||||
|
if (!hasValue) {
|
||||||
|
Player.Message(p, type + ": &b" + target);
|
||||||
} else {
|
} else {
|
||||||
target = value;
|
target = value;
|
||||||
Chat.MessageGlobal(format + " set to &b" + target);
|
Chat.MessageGlobal(type + " set to &b" + target);
|
||||||
SrvProperties.Save();
|
SrvProperties.Save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
int count = op.Positions.Count;
|
int count = op.Positions.Count;
|
||||||
|
|
||||||
bool confirmed = IsConfirmed(dArgs.Message), success = true;
|
bool confirmed = IsConfirmed(dArgs.Message), success = true;
|
||||||
if (count < p.group.MaxBlocks && count > ServerConfig.DrawReloadLimit && !confirmed) {
|
if (count < p.group.MaxBlocks && count > p.level.ReloadThreshold && !confirmed) {
|
||||||
Player.Message(p, "This fill would affect {0} blocks.", count);
|
Player.Message(p, "This fill would affect {0} blocks.", count);
|
||||||
Player.Message(p, "If you still want to fill, type %T/fill {0} confirm", dArgs.Message);
|
Player.Message(p, "If you still want to fill, type %T/fill {0} confirm", dArgs.Message);
|
||||||
} else {
|
} else {
|
||||||
|
@ -79,7 +79,7 @@ namespace MCGalaxy.Core {
|
|||||||
if (line == "&all") p.ignoreAll = true;
|
if (line == "&all") p.ignoreAll = true;
|
||||||
else if (line == "&irc") p.ignoreIRC = true;
|
else if (line == "&irc") p.ignoreIRC = true;
|
||||||
else if (line == "&8ball") p.ignore8ball = true;
|
else if (line == "&8ball") p.ignore8ball = true;
|
||||||
else if (line == "&drawouput") p.ignoreDrawOutput = true;
|
else if (line == "&drawoutput") p.ignoreDrawOutput = true;
|
||||||
else if (line == "&titles") p.ignoreTitles = true;
|
else if (line == "&titles") p.ignoreTitles = true;
|
||||||
else if (line == "&nicks") p.ignoreNicks = true;
|
else if (line == "&nicks") p.ignoreNicks = true;
|
||||||
else p.listignored.Add(line);
|
else p.listignored.Add(line);
|
||||||
|
@ -122,20 +122,19 @@ namespace MCGalaxy.Drawing.Ops {
|
|||||||
entry.Start = Server.StartTime.AddTicks(timeDelta * TimeSpan.TicksPerSecond);
|
entry.Start = Server.StartTime.AddTicks(timeDelta * TimeSpan.TicksPerSecond);
|
||||||
|
|
||||||
if (item.Brush != null) item.Brush.Configure(item.Op, p);
|
if (item.Brush != null) item.Brush.Configure(item.Op, p);
|
||||||
DoDrawOp(item, p);
|
bool needReload = DoDrawOp(item, p);
|
||||||
timeDelta = (int)DateTime.UtcNow.Subtract(Server.StartTime).TotalSeconds + 1;
|
timeDelta = (int)DateTime.UtcNow.Subtract(Server.StartTime).TotalSeconds + 1;
|
||||||
entry.End = Server.StartTime.AddTicks(timeDelta * TimeSpan.TicksPerSecond);
|
entry.End = Server.StartTime.AddTicks(timeDelta * TimeSpan.TicksPerSecond);
|
||||||
|
|
||||||
if (item.Op.Undoable) p.DrawOps.Add(entry);
|
if (item.Op.Undoable) p.DrawOps.Add(entry);
|
||||||
if (p.DrawOps.Count > 200) p.DrawOps.RemoveFirst();
|
if (p.DrawOps.Count > 200) p.DrawOps.RemoveFirst();
|
||||||
|
|
||||||
if (item.Op.TotalModified > ServerConfig.DrawReloadLimit)
|
if (needReload) DoReload(p, item.Op.Level);
|
||||||
DoReload(p, item.Op.Level);
|
|
||||||
item.Op.TotalModified = 0; // reset total modified (as drawop instances are reused in static mode)
|
item.Op.TotalModified = 0; // reset total modified (as drawop instances are reused in static mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DoDrawOp(PendingDrawOp item, Player p) {
|
static bool DoDrawOp(PendingDrawOp item, Player p) {
|
||||||
Level lvl = item.Op.Level;
|
Level lvl = item.Op.Level;
|
||||||
DrawOpOutputter outputter = new DrawOpOutputter(item.Op);
|
DrawOpOutputter outputter = new DrawOpOutputter(item.Op);
|
||||||
|
|
||||||
@ -144,6 +143,7 @@ namespace MCGalaxy.Drawing.Ops {
|
|||||||
} else {
|
} else {
|
||||||
item.Op.Perform(item.Marks, item.Brush, outputter.Output);
|
item.Op.Perform(item.Marks, item.Brush, outputter.Output);
|
||||||
}
|
}
|
||||||
|
return item.Op.TotalModified >= outputter.reloadThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DoReload(Player p, Level lvl) {
|
static void DoReload(Player p, Level lvl) {
|
||||||
@ -158,8 +158,12 @@ namespace MCGalaxy.Drawing.Ops {
|
|||||||
|
|
||||||
class DrawOpOutputter {
|
class DrawOpOutputter {
|
||||||
readonly DrawOp op;
|
readonly DrawOp op;
|
||||||
|
internal readonly int reloadThreshold;
|
||||||
|
|
||||||
public DrawOpOutputter(DrawOp op) { this.op = op; }
|
public DrawOpOutputter(DrawOp op) {
|
||||||
|
this.op = op;
|
||||||
|
reloadThreshold = op.Level.ReloadThreshold;
|
||||||
|
}
|
||||||
|
|
||||||
public void Output(DrawOpBlock b) {
|
public void Output(DrawOpBlock b) {
|
||||||
if (b.Block.BlockID == Block.Invalid) return;
|
if (b.Block.BlockID == Block.Invalid) return;
|
||||||
@ -191,14 +195,15 @@ namespace MCGalaxy.Drawing.Ops {
|
|||||||
p.SessionModified++; p.TotalModified++; p.TotalDrawn++; // increment block stats inline
|
p.SessionModified++; p.TotalModified++; p.TotalDrawn++; // increment block stats inline
|
||||||
}
|
}
|
||||||
|
|
||||||
// Potentially buffer the block change
|
// Potentially buffer the block change
|
||||||
if (op.TotalModified == ServerConfig.DrawReloadLimit) {
|
if (op.TotalModified == reloadThreshold) {
|
||||||
if (p == null || !p.ignoreDrawOutput) {
|
if (p == null || !p.ignoreDrawOutput) {
|
||||||
Player.Message(p, "Changed over {0} blocks, preparing to reload map..", ServerConfig.DrawReloadLimit);
|
Player.Message(p, "Changed over {0} blocks, preparing to reload map..", reloadThreshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
lock (lvl.queueLock)
|
lock (lvl.queueLock)
|
||||||
lvl.blockqueue.Clear();
|
lvl.blockqueue.Clear();
|
||||||
} else if (op.TotalModified < ServerConfig.DrawReloadLimit) {
|
} else if (op.TotalModified < reloadThreshold) {
|
||||||
if (!old.VisuallyEquals(b.Block)) BlockQueue.Addblock(p, index, b.Block);
|
if (!old.VisuallyEquals(b.Block)) BlockQueue.Addblock(p, index, b.Block);
|
||||||
|
|
||||||
if (lvl.physics > 0) {
|
if (lvl.physics > 0) {
|
||||||
|
@ -24,7 +24,7 @@ namespace MCGalaxy {
|
|||||||
public static class BlockQueue {
|
public static class BlockQueue {
|
||||||
|
|
||||||
public static int time = 100;
|
public static int time = 100;
|
||||||
public static int blockupdates = 250;
|
public static int blockupdates = 1000;
|
||||||
static BufferedBlockSender bulkSender = new BufferedBlockSender();
|
static BufferedBlockSender bulkSender = new BufferedBlockSender();
|
||||||
|
|
||||||
public static void Loop(SchedulerTask task) {
|
public static void Loop(SchedulerTask task) {
|
||||||
|
@ -60,7 +60,11 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
public bool IsMuseum {
|
public bool IsMuseum {
|
||||||
get { return name.StartsWith("&cMuseum " + ServerConfig.DefaultColor, StringComparison.Ordinal); }
|
get { return name.StartsWith("&cMuseum " + ServerConfig.DefaultColor, StringComparison.Ordinal); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int ReloadThreshold {
|
||||||
|
get { return Math.Max(10000, (int)(ServerConfig.DrawReloadThreshold * Width * Height * Length)); }
|
||||||
|
}
|
||||||
|
|
||||||
public static bool cancelload;
|
public static bool cancelload;
|
||||||
public bool cancelsave;
|
public bool cancelsave;
|
||||||
|
@ -133,8 +133,8 @@ namespace MCGalaxy {
|
|||||||
public static bool ListEmptyRanks = false;
|
public static bool ListEmptyRanks = false;
|
||||||
[ConfigInt("review-cooldown", "Review", 600, 0, 600)]
|
[ConfigInt("review-cooldown", "Review", 600, 0, 600)]
|
||||||
public static int ReviewCooldown = 600;
|
public static int ReviewCooldown = 600;
|
||||||
[ConfigInt("draw-reload-limit", "Other", 10000)]
|
[ConfigReal("draw-reload-threshold", "Other", 0.001f, 0, 1)]
|
||||||
public static int DrawReloadLimit = 10000;
|
public static float DrawReloadThreshold = 0.001f;
|
||||||
[ConfigBool("allow-tp-to-higher-ranks", "Other", true)]
|
[ConfigBool("allow-tp-to-higher-ranks", "Other", true)]
|
||||||
public static bool HigherRankTP = true;
|
public static bool HigherRankTP = true;
|
||||||
[ConfigPerm("os-perbuild-default", "Other", LevelPermission.Nobody)]
|
[ConfigPerm("os-perbuild-default", "Other", LevelPermission.Nobody)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user