fixed the resume bug

This commit is contained in:
BuildTools 2016-12-06 20:20:47 -05:00
parent 42a38642c0
commit 0af18cbe58
3 changed files with 20 additions and 23 deletions

View file

@ -15,13 +15,12 @@ public class ConfigProcess implements Runnable {
} }
static final void addNew(String name, WorldObj newWorld) static final void addNew(String name, WorldObj newWorld)
{ {
Bukkit.getLogger().info("config: addNew(" + name + ")");
config.set(name + ".total", newWorld.total); config.set(name + ".total", newWorld.total);
config.set(name + ".currentRegion.x", newWorld.current[0]); config.set(name + ".currentRegion.x", newWorld.current[0]);
config.set(name + ".currentRegion.z", newWorld.current[1]); config.set(name + ".currentRegion.z", newWorld.current[1]);
config.set(name + ".n", 1); config.set(name + ".n", 1);
config.set(name + ".c", 1); config.set(name + ".c", 1);
config.set(name + ".D", 1); config.set(name + ".s", 1);
config.set(name + ".d", 0); config.set(name + ".d", 0);
config.set(name + ".B", false); config.set(name + ".B", false);
plugin.saveConfig(); plugin.saveConfig();
@ -38,7 +37,7 @@ public class ConfigProcess implements Runnable {
}, },
config.getInt(name + ".n"), config.getInt(name + ".n"),
config.getInt(name + ".c"), config.getInt(name + ".c"),
config.getInt(name + ".D"), config.getInt(name + ".s"),
config.getInt(name + ".d"), config.getInt(name + ".d"),
config.getBoolean(name + ".B") config.getBoolean(name + ".B")
); );
@ -66,7 +65,7 @@ public class ConfigProcess implements Runnable {
config.set(name + ".currentRegion.z", TaskManager.loadProcess.currentRegion[1]); config.set(name + ".currentRegion.z", TaskManager.loadProcess.currentRegion[1]);
config.set(name + ".n", TaskManager.loadProcess.n); config.set(name + ".n", TaskManager.loadProcess.n);
config.set(name + ".c", TaskManager.loadProcess.c); config.set(name + ".c", TaskManager.loadProcess.c);
config.set(name + ".D", TaskManager.loadProcess.D); config.set(name + ".s", TaskManager.loadProcess.s);
config.set(name + ".d", TaskManager.loadProcess.d); config.set(name + ".d", TaskManager.loadProcess.d);
config.set(name + ".B", TaskManager.loadProcess.B); config.set(name + ".B", TaskManager.loadProcess.B);
plugin.saveConfig(); plugin.saveConfig();

View file

@ -14,7 +14,7 @@ public class LoadProcess implements Runnable
//see setNextRegion() //see setNextRegion()
int n; int n;
int c; int c;
int D; int s;
int d; int d;
boolean B; boolean B;
@ -23,14 +23,9 @@ public class LoadProcess implements Runnable
LoadProcess(String name) //resume from stored LoadProcess(String name) //resume from stored
{ {
Bukkit.getLogger().info("resuming stored world-load process");
WorldObj unfinishedworld = ConfigProcess.getUnfinished(name); WorldObj unfinishedworld = ConfigProcess.getUnfinished(name);
Bukkit.getLogger().info("resuming stored world-load process "
+ unfinishedworld.n + " "
+ unfinishedworld.c + " "
+ unfinishedworld.D + " "
+ unfinishedworld.d + " "
+ unfinishedworld.B
);
world = Bukkit.getWorld(name); world = Bukkit.getWorld(name);
totalRegions = unfinishedworld.total; totalRegions = unfinishedworld.total;
@ -38,7 +33,7 @@ public class LoadProcess implements Runnable
n = unfinishedworld.n; n = unfinishedworld.n;
c = unfinishedworld.c; c = unfinishedworld.c;
D = unfinishedworld.D; s = unfinishedworld.s;
d = unfinishedworld.d; d = unfinishedworld.d;
B = unfinishedworld.B; B = unfinishedworld.B;
} }
@ -54,7 +49,7 @@ public class LoadProcess implements Runnable
n = 1; n = 1;
c = 1; c = 1;
D = 1; s = 1;
d = 0; d = 0;
B = false; B = false;
} }
@ -102,18 +97,18 @@ public class LoadProcess implements Runnable
* *
* n how many regions have been saved already * n how many regions have been saved already
* c direction of travel: E,N,W,S - 1,2,3,4 * c direction of travel: E,N,W,S - 1,2,3,4
* D distance to travel (side-length) * s side: distance to travel (side-length)
* d distance already traveled * d side: distance already traveled
* B OK to increase distance? * B OK to increase distance?
*/ */
private final boolean setNextRegion() private final boolean setNextRegion()
{ {
if (n == totalRegions) return false; if (n == totalRegions) return false;
if (d == D) if (d == s)
{ {
d = 1; d = 1;
if (B) D++; if (B) s++;
B = !B; B = !B;
c = c == 4 ? 1 : c + 1; c = c == 4 ? 1 : c + 1;
} }

View file

@ -9,7 +9,7 @@ public class WorldObj {
int[] current; int[] current;
int n; int n;
int c; int c;
int D; int s;
int d; int d;
boolean B; boolean B;
@ -24,20 +24,23 @@ public class WorldObj {
this.current = center; this.current = center;
} }
WorldObj(int total, int[] current, WorldObj(int total, int[] current,
int n, int c, int D, int d, boolean B) int n, int c, int s, int d, boolean B)
{ {
this.total = total; this.total = total;
this.current = current; this.current = current;
this.n = n; this.n = n;
this.c = c; this.c = c;
this.D = D; this.s = s;
this.D = d; this.d = d;
this.B = B; this.B = B;
} }
static final WorldObj generate(String[] args) static final WorldObj generate(String[] args)
{ {
if (args.length == 0) return new WorldObj(); if (args.length == 0)
{
return new WorldObj();
}
int[] bounds = regionBounds(new ParsedArgs(args)); int[] bounds = regionBounds(new ParsedArgs(args));