Change autogenerate-to-visibilitylimits to have options for map-only (temporary generated chunks) versus permanent (world growing)

Fix exception catching code in thread pool
This commit is contained in:
Mike Primm 2011-06-25 16:01:06 -05:00
parent 6dac7f0689
commit 39281188bc
7 changed files with 90 additions and 20 deletions

View file

@ -12,7 +12,10 @@ import org.bukkit.block.Biome;
import org.bukkit.entity.Entity;
import org.bukkit.ChunkSnapshot;
import org.dynmap.DynmapChunk;
import org.dynmap.DynmapPlugin;
import org.dynmap.DynmapWorld;
import org.dynmap.Log;
import org.dynmap.MapManager;
/**
* Container for managing chunks - dependent upon using chunk snapshots, since rendering is off server thread
@ -31,7 +34,9 @@ public class NewMapChunkCache implements MapChunkCache {
private boolean biome, biomeraw, highesty, blockdata;
private HiddenChunkStyle hidestyle = HiddenChunkStyle.FILL_AIR;
private List<VisibilityLimit> visible_limits = null;
private DynmapWorld.AutoGenerateOption generateopt;
private boolean do_generate = false;
private boolean do_save = false;
private boolean isempty = true;
private ChunkSnapshot[] snaparray; /* Index = (x-x_min) + ((z-z_min)*x_dim) */
@ -284,6 +289,7 @@ public class NewMapChunkCache implements MapChunkCache {
if(iterator == null)
iterator = chunks.listIterator();
DynmapPlugin.setIgnoreChunkLoads(true);
// Load the required chunks.
while((cnt < max_to_load) && iterator.hasNext()) {
DynmapChunk chunk = iterator.next();
@ -298,7 +304,7 @@ public class NewMapChunkCache implements MapChunkCache {
}
}
boolean wasLoaded = w.isChunkLoaded(chunk.x, chunk.z);
boolean didload = w.loadChunk(chunk.x, chunk.z, do_generate && vis);
boolean didload = w.loadChunk(chunk.x, chunk.z, false);
boolean didgenerate = false;
/* If we didn't load, and we're supposed to generate, do it */
if((!didload) && do_generate && vis)
@ -348,7 +354,7 @@ public class NewMapChunkCache implements MapChunkCache {
* while the actual in-use chunk area for a player where the chunks are managed
* by the MC base server is 21x21 (or about a 160 block radius).
* Also, if we did generate it, need to save it */
w.unloadChunk(chunk.x, chunk.z, didgenerate, false);
w.unloadChunk(chunk.x, chunk.z, didgenerate && do_save, false);
/* And pop preserved chunk - this is a bad leak in Bukkit for map traversals like us */
try {
if(poppreservedchunk != null)
@ -359,6 +365,8 @@ public class NewMapChunkCache implements MapChunkCache {
}
cnt++;
}
DynmapPlugin.setIgnoreChunkLoads(false);
if(iterator.hasNext() == false) { /* If we're done */
isempty = true;
/* Fill missing chunks with empty dummy chunk */
@ -457,12 +465,14 @@ public class NewMapChunkCache implements MapChunkCache {
/**
* Set autogenerate - must be done after at least one visible range has been set
*/
public void setAutoGenerateVisbileRanges(boolean do_generate) {
if(do_generate && ((visible_limits == null) || (visible_limits.size() == 0))) {
public void setAutoGenerateVisbileRanges(DynmapWorld.AutoGenerateOption generateopt) {
if((generateopt != DynmapWorld.AutoGenerateOption.NONE) && ((visible_limits == null) || (visible_limits.size() == 0))) {
Log.severe("Cannot setAutoGenerateVisibleRanges() without visible ranges defined");
return;
}
this.do_generate = do_generate;
this.generateopt = generateopt;
this.do_generate = (generateopt != DynmapWorld.AutoGenerateOption.NONE);
this.do_save = (generateopt == DynmapWorld.AutoGenerateOption.PERMANENT);
}
/**
* Add visible area limit - can be called more than once