Add support for single map render via /dynmap fullrender world:map, /dynmap radiusrender radius mapname

This commit is contained in:
Mike Primm 2011-08-13 11:47:11 +08:00 committed by mikeprimm
parent 78c2f613b1
commit 7bc3eb8fb5
11 changed files with 60 additions and 29 deletions

View file

@ -579,14 +579,17 @@ public class DynmapPlugin extends JavaPlugin {
else if(c.equals("radiusrender") && checkPlayerPermission(sender,"radiusrender")) { else if(c.equals("radiusrender") && checkPlayerPermission(sender,"radiusrender")) {
if (player != null) { if (player != null) {
int radius = 0; int radius = 0;
String mapname = null;
if(args.length > 1) { if(args.length > 1) {
radius = Integer.parseInt(args[1]); /* Parse radius */ radius = Integer.parseInt(args[1]); /* Parse radius */
if(radius < 0) if(radius < 0)
radius = 0; radius = 0;
if(args.length > 2)
mapname = args[2];
} }
Location loc = player.getLocation(); Location loc = player.getLocation();
if(loc != null) if(loc != null)
mapManager.renderWorldRadius(loc, sender, radius); mapManager.renderWorldRadius(loc, sender, mapname, radius);
} }
else { else {
sender.sendMessage("Command can only be issued by player."); sender.sendMessage("Command can only be issued by player.");
@ -616,18 +619,28 @@ public class DynmapPlugin extends JavaPlugin {
} }
} }
} else if (c.equals("fullrender") && checkPlayerPermission(sender,"fullrender")) { } else if (c.equals("fullrender") && checkPlayerPermission(sender,"fullrender")) {
String map = null;
if (args.length > 1) { if (args.length > 1) {
for (int i = 1; i < args.length; i++) { for (int i = 1; i < args.length; i++) {
World w = getServer().getWorld(args[i]); int dot = args[i].indexOf(":");
World w;
String wname = args[i];
if(dot >= 0) {
wname = args[i].substring(0, dot);
map = args[i].substring(dot+1);
}
w = getServer().getWorld(wname);
if(w != null) if(w != null)
mapManager.renderFullWorld(new Location(w, 0, 0, 0),sender); mapManager.renderFullWorld(new Location(w, 0, 0, 0),sender, map);
else else
sender.sendMessage("World '" + args[i] + "' not defined/loaded"); sender.sendMessage("World '" + wname + "' not defined/loaded");
} }
} else if (player != null) { } else if (player != null) {
Location loc = player.getLocation(); Location loc = player.getLocation();
if(args.length > 1)
map = args[1];
if(loc != null) if(loc != null)
mapManager.renderFullWorld(loc, sender); mapManager.renderFullWorld(loc, sender, map);
} else { } else {
sender.sendMessage("World name is required"); sender.sendMessage("World name is required");
} }

View file

@ -166,15 +166,16 @@ public class MapManager {
int cxmin, cxmax, czmin, czmax; int cxmin, cxmax, czmin, czmax;
String rendertype; String rendertype;
boolean cancelled; boolean cancelled;
String mapname;
/* Full world, all maps render */ /* Full world, all maps render */
FullWorldRenderState(DynmapWorld dworld, Location l, CommandSender sender) { FullWorldRenderState(DynmapWorld dworld, Location l, CommandSender sender, String mapname) {
this(dworld, l, sender, -1); this(dworld, l, sender, mapname, -1);
rendertype = "Full render"; rendertype = "Full render";
} }
/* Full world, all maps render, with optional render radius */ /* Full world, all maps render, with optional render radius */
FullWorldRenderState(DynmapWorld dworld, Location l, CommandSender sender, int radius) { FullWorldRenderState(DynmapWorld dworld, Location l, CommandSender sender, String mapname, int radius) {
world = dworld; world = dworld;
loc = l; loc = l;
found = new HashSet<MapTile>(); found = new HashSet<MapTile>();
@ -193,6 +194,7 @@ public class MapManager {
czmax = (l.getBlockZ() + radius+15)>>4; czmax = (l.getBlockZ() + radius+15)>>4;
rendertype = "Radius render"; rendertype = "Radius render";
} }
this.mapname = mapname;
} }
/* Single tile render - used for incremental renders */ /* Single tile render - used for incremental renders */
@ -240,8 +242,17 @@ public class MapManager {
/* Advance to next unrendered map */ /* Advance to next unrendered map */
while(map_index < world.maps.size()) { while(map_index < world.maps.size()) {
map_index++; /* Move to next one */ map_index++; /* Move to next one */
if((map_index < world.maps.size()) && (renderedmaps.contains(world.maps.get(map_index)) == false)) if(map_index >= world.maps.size()) break;
break; /* If single map render, see if this is our target */
if(mapname != null) {
if(world.maps.get(map_index).getName().equals(mapname)) {
break;
}
}
else {
if(renderedmaps.contains(world.maps.get(map_index)) == false)
break;
}
} }
if(map_index >= world.maps.size()) { /* Last one done? */ if(map_index >= world.maps.size()) { /* Last one done? */
sender.sendMessage(rendertype + " of '" + world.world.getName() + "' finished."); sender.sendMessage(rendertype + " of '" + world.world.getName() + "' finished.");
@ -253,6 +264,8 @@ public class MapManager {
/* Build active map list */ /* Build active map list */
activemaps = ""; activemaps = "";
for(String n : activemaplist) { for(String n : activemaplist) {
if((mapname != null) && (!mapname.equals(n)))
continue;
if(activemaps.length() > 0) if(activemaps.length() > 0)
activemaps += ","; activemaps += ",";
activemaps += n; activemaps += n;
@ -307,12 +320,12 @@ public class MapManager {
} }
if(tile0 != null) { /* Single tile? */ if(tile0 != null) { /* Single tile? */
if(cache.isEmpty() == false) if(cache.isEmpty() == false)
tile.render(cache); tile.render(cache, null);
} }
else { else {
/* Switch to not checking if rendered tile is blank - breaks us on skylands, where tiles can be nominally blank - just work off chunk cache empty */ /* Switch to not checking if rendered tile is blank - breaks us on skylands, where tiles can be nominally blank - just work off chunk cache empty */
if (cache.isEmpty() == false) { if (cache.isEmpty() == false) {
tile.render(cache); tile.render(cache, mapname);
found.remove(tile); found.remove(tile);
rendered.add(tile); rendered.add(tile);
for (MapTile adjTile : map.getAdjecentTiles(tile)) { for (MapTile adjTile : map.getAdjecentTiles(tile)) {
@ -434,7 +447,7 @@ public class MapManager {
} }
} }
void renderFullWorld(Location l, CommandSender sender) { void renderFullWorld(Location l, CommandSender sender, String mapname) {
DynmapWorld world = getWorld(l.getWorld().getName()); DynmapWorld world = getWorld(l.getWorld().getName());
if (world == null) { if (world == null) {
sender.sendMessage("Could not render: world '" + l.getWorld().getName() + "' not defined in configuration."); sender.sendMessage("Could not render: world '" + l.getWorld().getName() + "' not defined in configuration.");
@ -448,7 +461,7 @@ public class MapManager {
sender.sendMessage(rndr.rendertype + " of world '" + wname + "' already active."); sender.sendMessage(rndr.rendertype + " of world '" + wname + "' already active.");
return; return;
} }
rndr = new FullWorldRenderState(world,l,sender); /* Make new activation record */ rndr = new FullWorldRenderState(world,l,sender, mapname); /* Make new activation record */
active_renders.put(wname, rndr); /* Add to active table */ active_renders.put(wname, rndr); /* Add to active table */
} }
/* Schedule first tile to be worked */ /* Schedule first tile to be worked */
@ -457,7 +470,7 @@ public class MapManager {
sender.sendMessage("Full render starting on world '" + wname + "'..."); sender.sendMessage("Full render starting on world '" + wname + "'...");
} }
void renderWorldRadius(Location l, CommandSender sender, int radius) { void renderWorldRadius(Location l, CommandSender sender, String mapname, int radius) {
DynmapWorld world = getWorld(l.getWorld().getName()); DynmapWorld world = getWorld(l.getWorld().getName());
if (world == null) { if (world == null) {
sender.sendMessage("Could not render: world '" + l.getWorld().getName() + "' not defined in configuration."); sender.sendMessage("Could not render: world '" + l.getWorld().getName() + "' not defined in configuration.");
@ -471,7 +484,7 @@ public class MapManager {
sender.sendMessage(rndr.rendertype + " of world '" + wname + "' already active."); sender.sendMessage(rndr.rendertype + " of world '" + wname + "' already active.");
return; return;
} }
rndr = new FullWorldRenderState(world,l,sender, radius); /* Make new activation record */ rndr = new FullWorldRenderState(world,l,sender, mapname, radius); /* Make new activation record */
active_renders.put(wname, rndr); /* Add to active table */ active_renders.put(wname, rndr); /* Add to active table */
} }
/* Schedule first tile to be worked */ /* Schedule first tile to be worked */

View file

@ -10,7 +10,7 @@ import org.dynmap.utils.MapChunkCache;
public abstract class MapTile { public abstract class MapTile {
protected DynmapWorld world; protected DynmapWorld world;
public abstract boolean render(MapChunkCache cache); public abstract boolean render(MapChunkCache cache, String mapname);
public abstract List<DynmapChunk> getRequiredChunks(); public abstract List<DynmapChunk> getRequiredChunks();
public abstract MapTile[] getAdjecentTiles(); public abstract MapTile[] getAdjecentTiles();

View file

@ -495,7 +495,7 @@ public class FlatMap extends MapType {
} }
@Override @Override
public boolean render(MapChunkCache cache) { public boolean render(MapChunkCache cache, String mapname) {
return map.render(cache, this, MapManager.mapman.getTileFile(this)); return map.render(cache, this, MapManager.mapman.getTileFile(this));
} }

View file

@ -119,7 +119,7 @@ public class HDMapManager {
/** /**
* Initialize shader states for all shaders for given tile * Initialize shader states for all shaders for given tile
*/ */
public HDShaderState[] getShaderStateForTile(HDMapTile tile, MapChunkCache cache, MapIterator mapiter) { public HDShaderState[] getShaderStateForTile(HDMapTile tile, MapChunkCache cache, MapIterator mapiter, String mapname) {
DynmapWorld w = MapManager.mapman.worldsLookup.get(tile.getWorld().getName()); DynmapWorld w = MapManager.mapman.worldsLookup.get(tile.getWorld().getName());
if(w == null) return new HDShaderState[0]; if(w == null) return new HDShaderState[0];
ArrayList<HDShaderState> shaders = new ArrayList<HDShaderState>(); ArrayList<HDShaderState> shaders = new ArrayList<HDShaderState>();
@ -127,6 +127,9 @@ public class HDMapManager {
if(map instanceof HDMap) { if(map instanceof HDMap) {
HDMap hdmap = (HDMap)map; HDMap hdmap = (HDMap)map;
if(hdmap.getPerspective() == tile.perspective) { if(hdmap.getPerspective() == tile.perspective) {
/* If limited to one map, and this isn't it, skip */
if((mapname != null) && (!hdmap.getName().equals(mapname)))
continue;
shaders.add(hdmap.getShader().getStateInstance(hdmap, cache, mapiter)); shaders.add(hdmap.getShader().getStateInstance(hdmap, cache, mapiter));
} }
} }

View file

@ -76,8 +76,8 @@ public class HDMapTile extends MapTile {
@Override @Override
public boolean isBlockTypeDataNeeded() { return MapManager.mapman.hdmapman.isBlockTypeDataNeeded(this); } public boolean isBlockTypeDataNeeded() { return MapManager.mapman.hdmapman.isBlockTypeDataNeeded(this); }
public boolean render(MapChunkCache cache) { public boolean render(MapChunkCache cache, String mapname) {
return perspective.render(cache, this); return perspective.render(cache, this, mapname);
} }
public List<DynmapChunk> getRequiredChunks() { public List<DynmapChunk> getRequiredChunks() {

View file

@ -18,7 +18,7 @@ public interface HDPerspective {
/* Get chunks needed for given tile */ /* Get chunks needed for given tile */
List<DynmapChunk> getRequiredChunks(MapTile tile); List<DynmapChunk> getRequiredChunks(MapTile tile);
/* Render given tile */ /* Render given tile */
boolean render(MapChunkCache cache, HDMapTile tile); boolean render(MapChunkCache cache, HDMapTile tile, String mapname);
public boolean isBiomeDataNeeded(); public boolean isBiomeDataNeeded();
public boolean isHightestBlockYDataNeeded(); public boolean isHightestBlockYDataNeeded();

View file

@ -888,11 +888,11 @@ public class IsoHDPerspective implements HDPerspective {
} }
@Override @Override
public boolean render(MapChunkCache cache, HDMapTile tile) { public boolean render(MapChunkCache cache, HDMapTile tile, String mapname) {
Color rslt = new Color(); Color rslt = new Color();
MapIterator mapiter = cache.getIterator(0, 0, 0); MapIterator mapiter = cache.getIterator(0, 0, 0);
/* Build shader state object for each shader */ /* Build shader state object for each shader */
HDShaderState[] shaderstate = MapManager.mapman.hdmapman.getShaderStateForTile(tile, cache, mapiter); HDShaderState[] shaderstate = MapManager.mapman.hdmapman.getShaderStateForTile(tile, cache, mapiter, mapname);
int numshaders = shaderstate.length; int numshaders = shaderstate.length;
if(numshaders == 0) if(numshaders == 0)
return false; return false;

View file

@ -75,7 +75,7 @@ public class KzedMapTile extends MapTile {
return getWorld().getName() + ":" + getFilename(); return getWorld().getName() + ":" + getFilename();
} }
public boolean render(MapChunkCache cache) { public boolean render(MapChunkCache cache, String mapname) {
return map.render(cache, this, MapManager.mapman.getTileFile(this)); return map.render(cache, this, MapManager.mapman.getTileFile(this));
} }

View file

@ -84,7 +84,7 @@ public class KzedZoomedMapTile extends MapTile {
} }
@Override @Override
public boolean render(MapChunkCache cache) { public boolean render(MapChunkCache cache, String mapname) {
return false; return false;
} }

View file

@ -12,9 +12,11 @@ commands:
/<command> show - shows the player from the map. /<command> show - shows the player from the map.
/<command> show TheDude - shows the player 'TheDude' from the map. /<command> show TheDude - shows the player 'TheDude' from the map.
/<command> render - Renders the tile at your location. /<command> render - Renders the tile at your location.
/<command> fullrender - (Attempts to) render entire world from your location. /<command> fullrender - Render all maps for entire world from your location.
/<command> fullrender world - (Attempts to) render entire world 'world'. /<command> fullrender world - Render all maps for entire world 'world'.
/<command> radiusrender ## - (Attempts to) render at least ## block radius from your location. /<command> fullrender world:mapname - Render map 'mapname' of world 'world'.
/<command> radiusrender ## - Render at least ## block radius from your location on all maps.
/<command> radiusrender ## mapname - Render at least ## block radius from your location on map 'mapname'
/<command> cancelrender - Cancels any active renders on current world /<command> cancelrender - Cancels any active renders on current world
/<command> cancelrender world - Cancels any active renders of world 'world' /<command> cancelrender world - Cancels any active renders of world 'world'
/<command> stats - Show render statistics. /<command> stats - Show render statistics.