attempting to fix the resume process

This commit is contained in:
BuildTools 2016-12-06 19:25:03 -05:00
parent b93b7730c9
commit 9e83ab43f5

View file

@ -5,19 +5,47 @@ import org.bukkit.World;
public class LoadProcess implements Runnable
{
//=================================INIT=================================
//================================VALUES================================
private final World world;
final int totalRegions;
int[] currentRegion;
LoadProcess(String name, WorldObj newWorld)
//see setNextRegion()
int n;
int c;
int D;
int d;
boolean B;
//=============================CONSTRUCTORS=============================
LoadProcess(String name) //resume from stored
{
ConfigProcess.addNew(name, newWorld);
Bukkit.getLogger().info("resuming stored world-load process");
WorldObj unfinishedworld = ConfigProcess.getUnfinished(name);
world = Bukkit.getWorld(name);
totalRegions = newWorld.total;
currentRegion = newWorld.current;
totalRegions = unfinishedworld.total;
currentRegion = unfinishedworld.current;
n = unfinishedworld.n;
c = unfinishedworld.c;
D = unfinishedworld.D;
d = unfinishedworld.d;
B = unfinishedworld.B;
}
LoadProcess(String name, WorldObj newworld) //new process
{
Bukkit.getLogger().info("new world-load process");
ConfigProcess.addNew(name, newworld);
world = Bukkit.getWorld(name);
totalRegions = newworld.total;
currentRegion = newworld.current;
n = 1;
c = 1;
@ -25,69 +53,6 @@ public class LoadProcess implements Runnable
d = 0;
B = false;
}
LoadProcess(String name)
{
WorldObj unfinished = ConfigProcess.getUnfinished(name);
world = Bukkit.getWorld(name);
totalRegions = unfinished.total;
currentRegion = unfinished.current;
n = unfinished.n;
c = unfinished.c;
D = unfinished.D;
d = unfinished.d;
B = unfinished.B;
}
//===============================PATTERN================================
/* The pattern:
*
* 3 | 36 35 34 33 32 31
* |
* 2 | 17 16 15 14 13 30
* |
* 1 | 18 05 04 03 12 29
* |
* Z | 19 06 01 02 11 28
* |
* -1 | 20 07 08 09 10 27
* |
* -2 | 21 22 23 24 25 26
* +-----------------------
* -2 -1 X 1 2 3
* etc.
*/
int n; //how many regions have been saved already
int c; //direction of travel: E,N,W,S - 1,2,3,4
int D; //distance to travel
int d; //distance already traveled
boolean B; //OK to increase distance?
private final boolean setNextRegion()
{
if (n == totalRegions) return false;
if (d == D)
{
d = 1;
if (B) D++;
B = !B;
c = c == 4 ? 1 : c + 1;
}
else d++;
switch (c)
{
case 1 : currentRegion[0]++; break;
case 2 : currentRegion[1]++; break;
case 3 : currentRegion[0]--; break;
case 4 : currentRegion[1]--; break;
}
n++;
return true;
}
//==============================GET CHUNKS==============================
@ -111,6 +76,55 @@ public class LoadProcess implements Runnable
}
//===========================SET NEXT REGION============================
/* The pattern:
*
* 3 | 36 35 34 33 32 31
* |
* 2 | 17 16 15 14 13 30
* |
* 1 | 18 05 04 03 12 29
* |
* Z | 19 06 01 02 11 28
* |
* -1 | 20 07 08 09 10 27
* |
* -2 | 21 22 23 24 25 26
* +-----------------------
* -2 -1 X 1 2 3
* etc.
*
* n how many regions have been saved already
* c direction of travel: E,N,W,S - 1,2,3,4
* D distance to travel (side-length)
* d distance already traveled
* B OK to increase distance?
*/
private final boolean setNextRegion()
{
if (n == totalRegions) return false;
if (d == D)
{
d = 1;
if (B) D++;
B = !B;
c = c == 4 ? 1 : c + 1;
}
else d++;
switch (c)
{
case 1 : currentRegion[0]++; break;
case 2 : currentRegion[1]++; break;
case 3 : currentRegion[0]--; break;
case 4 : currentRegion[1]--; break;
}
n++;
return true;
}
//==================================RUN=================================
private volatile boolean ready = true;
@ -132,55 +146,6 @@ public class LoadProcess implements Runnable
{
TaskManager.finish();
}
//while (skip(currentRegion))
//{
// if (!setNextRegion())
// {
// TaskManager.finish();
// }
//}
ready = true;
}
//=============================SKIP REGION?=============================
//this is specific to our new TerrainControl world
//skip all regions that contain jungle biome
/*
private static final boolean skip(int[] r)
{
switch(r[0])
{
case -17 : return check(r[1], -15,-14 );
case -16 : return check(r[1], -20,-19,-18,-17,-16,-15,-14 );
case -15 : return check(r[1], -20,-19,-18,-17,-16,-15 );
case -14 : return check(r[1], -19,-18,-17,-16,-15 );
case -13 : return check(r[1], -19,-18,-17,-16,-15 );
case -12 : return check(r[1], -18,-17,-16,-15 );
case -11 : return check(r[1], -19,-18,-17,-16,-15,-14 );
case -10 : return check(r[1], -19,-18,-17,-16,-15,-14 );
case -9 : return check(r[1], -19,-18,-17,-16,-15,-14 );
case -8 : return check(r[1], -18,-17,-16,-15 );
case -7 : return check(r[1], -18,-17,-16,-15 );
case -6 : return check(r[1], -17,-16,-15 );
case -3 : return check(r[1], -7, -6, -5 );
case -2 : return check(r[1], -6, -5, -4 );
case -1 : return check(r[1], -7, -6, -5, -4 );
case 0 : return check(r[1], -8, -7, -6, -5, -4 );
case 1 : return check(r[1], -9, -8, -7, -6, -5, -4 );
case 2 : return check(r[1], -9, -8, -7, -6, -5 );
case 3 : return check(r[1], -7, -6 );
}
return false;
}
private static final boolean check(int z, int... skips)
{
for (int skip : skips)
{
if (z == skip) return true;
}
return false;
}
*/
}