added "unqueued" counter, currently unused

This commit is contained in:
BuildTools 2016-11-28 17:48:48 -05:00
parent 845a0e56e5
commit 2e07dcbb1a
4 changed files with 29 additions and 29 deletions

View file

@ -5,11 +5,10 @@ import org.bukkit.configuration.file.FileConfiguration;
public class ConfigProcess implements Runnable {
static Main plugin; //initialized in Main onEnable()
static FileConfiguration config;//
final String name;
//================================STATIC================================
static Main plugin;
static FileConfiguration config;
//----------------------------------------------------------------------
static final boolean isNew(String name)
{
return !config.contains(name);
@ -53,6 +52,8 @@ public class ConfigProcess implements Runnable {
}
//===============================INSTANCE===============================
final String name;
//----------------------------------------------------------------------
ConfigProcess(String name)
{
this.name = name;

View file

@ -10,6 +10,7 @@ public class LoadProcess implements Runnable
private final World world;
final int totalRegions;
int[] currentRegion;
LoadProcess(String name, WorldObj newWorld)
{
ConfigProcess.addNew(name, newWorld);
@ -18,6 +19,7 @@ public class LoadProcess implements Runnable
totalRegions = newWorld.total;
currentRegion = newWorld.current;
}
LoadProcess(String name)
{
final WorldObj unfinished = ConfigProcess.getUnfinished(name);
@ -62,7 +64,6 @@ public class LoadProcess implements Runnable
private final boolean setNextRegion()
{
if (n == totalRegions) return false;
if (d == D)
{
@ -85,23 +86,30 @@ public class LoadProcess implements Runnable
//==============================GET CHUNKS==============================
private final int[][][] getChunksCurrentRegion()
{
final int[][][] chunks = new int[32][32][2];
int xR = currentRegion[0] * 32;
int zR = currentRegion[1] * 32;
int z;
for (int x = 0; x < 32; x++)
{
z = 0;
for (; z < 32; z++)
{
chunks[x][z][0] = (currentRegion[0] * 32) + x;
chunks[x][z][1] = (currentRegion[1] * 32) + z;
chunks[x][z][0] = xR + x;
chunks[x][z][1] = zR + z;
}
}
return chunks;
}
//==================================RUN=================================
private static volatile boolean ready = true;
private volatile int unqueued = 0;
public final void run()
{
if (!ready) return;
@ -113,7 +121,7 @@ public class LoadProcess implements Runnable
for (int[] chunk : xRow)
{
world.loadChunk(chunk[0], chunk[1], true);
world.unloadChunkRequest(chunk[0], chunk[1]);
if (!world.unloadChunkRequest(chunk[0], chunk[1])) unqueued++;
}
}
if (!setNextRegion())

View file

@ -9,10 +9,10 @@ import org.bukkit.scheduler.BukkitTask;
public class TaskManager {
static boolean inProgress = false;
private static boolean inProgress = false;
static LoadProcess loadProcess;
static ConfigProcess configProcess;
static LoadProcess loadProcess;
private static ConfigProcess configProcess;
private static BukkitTask loadTask;
private static BukkitTask configTask;
@ -22,7 +22,7 @@ public class TaskManager {
private static final void schedule(long delay)
{
loadTask = Bukkit.getScheduler().runTaskTimer(ConfigProcess.plugin, loadProcess, delay, 100);
configTask = Bukkit.getScheduler().runTaskTimer(ConfigProcess.plugin, loadProcess, delay, 100);
configTask = Bukkit.getScheduler().runTaskTimer(ConfigProcess.plugin, configProcess, delay, 200);
}
//-----------------------------------------------------------------------------
private static final boolean start(String[] args, String name)
@ -50,7 +50,7 @@ public class TaskManager {
}
return false;
}
static final void stop_or_finish()
private static final void stop_or_finish()
{
loadTask.cancel();
configTask.cancel();
@ -65,25 +65,17 @@ public class TaskManager {
static final void finish()
{
configProcess.finish();
stop_or_finish();
}
static final boolean stop()
private static final boolean stop()
{
if (inProgress)
{
if (loadProcess.n == loadProcess.totalRegions) finish();
else
{
loadTask.cancel();
configTask.cancel();
configProcess.stop();
loadProcess = null;
configProcess = null;
loadTask = null;
configTask = null;
inProgress = false;
stop_or_finish();
}
return true;
}

View file

@ -2,8 +2,8 @@ package iieLoadSaveEntireWorld;
public class WorldObj {
final int total;
int[] current;
final int total;
int[] current;
int n;
int c;
int D;
@ -12,7 +12,7 @@ public class WorldObj {
WorldObj()
{
total = 1936; //44 * 44
total = 1936;//(44*44)
current = new int[] { -1, -1 };
}
WorldObj(int total, int[] center)
@ -57,7 +57,7 @@ public class WorldObj {
* * * * *
*
* the spiral pattern used in LoadProcess rotates
* counter-clockwise, so it must begin at minimum
* east north west south, so it must begin at minimum
* center.
*/
}
@ -118,7 +118,6 @@ public class WorldObj {
Math.floorDiv( a.center[1] + a.radius, 512 )
};
//add margins---------------------------------------------------------------
final int[] edges = new int[4];
final int[] radii = new int[4];
final boolean[] margin = new boolean[4];