Fix initial zoomout processing (unnecessary updates), extra tile invalidates

This commit is contained in:
Mike Primm 2011-08-15 06:43:08 +08:00 committed by mikeprimm
parent 5091063d02
commit aa9a1f888d
6 changed files with 53 additions and 19 deletions

View file

@ -352,8 +352,9 @@ public class DynmapPlugin extends JavaPlugin {
return; return;
Location loc = event.getBlock().getLocation(); Location loc = event.getBlock().getLocation();
mm.sscache.invalidateSnapshot(loc); mm.sscache.invalidateSnapshot(loc);
if(onplace) if(onplace) {
mm.touch(loc); mm.touch(loc);
}
} }
@Override @Override
@ -362,8 +363,9 @@ public class DynmapPlugin extends JavaPlugin {
return; return;
Location loc = event.getBlock().getLocation(); Location loc = event.getBlock().getLocation();
mm.sscache.invalidateSnapshot(loc); mm.sscache.invalidateSnapshot(loc);
if(onbreak) if(onbreak) {
mm.touch(loc); mm.touch(loc);
}
} }
@Override @Override
@ -372,8 +374,9 @@ public class DynmapPlugin extends JavaPlugin {
return; return;
Location loc = event.getBlock().getLocation(); Location loc = event.getBlock().getLocation();
mm.sscache.invalidateSnapshot(loc); mm.sscache.invalidateSnapshot(loc);
if(onleaves) if(onleaves) {
mm.touch(loc); mm.touch(loc);
}
} }
@Override @Override
@ -382,8 +385,9 @@ public class DynmapPlugin extends JavaPlugin {
return; return;
Location loc = event.getBlock().getLocation(); Location loc = event.getBlock().getLocation();
mm.sscache.invalidateSnapshot(loc); mm.sscache.invalidateSnapshot(loc);
if(onburn) if(onburn) {
mm.touch(loc); mm.touch(loc);
}
} }
@Override @Override
@ -392,8 +396,9 @@ public class DynmapPlugin extends JavaPlugin {
return; return;
Location loc = event.getBlock().getLocation(); Location loc = event.getBlock().getLocation();
mm.sscache.invalidateSnapshot(loc); mm.sscache.invalidateSnapshot(loc);
if(onblockform) if(onblockform) {
mm.touch(loc); mm.touch(loc);
}
} }
@Override @Override
public void onBlockFade(BlockFadeEvent event) { public void onBlockFade(BlockFadeEvent event) {
@ -401,8 +406,9 @@ public class DynmapPlugin extends JavaPlugin {
return; return;
Location loc = event.getBlock().getLocation(); Location loc = event.getBlock().getLocation();
mm.sscache.invalidateSnapshot(loc); mm.sscache.invalidateSnapshot(loc);
if(onblockfade) if(onblockfade) {
mm.touch(loc); mm.touch(loc);
}
} }
@Override @Override
public void onBlockSpread(BlockSpreadEvent event) { public void onBlockSpread(BlockSpreadEvent event) {
@ -410,8 +416,9 @@ public class DynmapPlugin extends JavaPlugin {
return; return;
Location loc = event.getBlock().getLocation(); Location loc = event.getBlock().getLocation();
mm.sscache.invalidateSnapshot(loc); mm.sscache.invalidateSnapshot(loc);
if(onblockspread) if(onblockspread) {
mm.touch(loc); mm.touch(loc);
}
} }
@Override @Override
public void onBlockPistonRetract(BlockPistonRetractEvent event) { public void onBlockPistonRetract(BlockPistonRetractEvent event) {
@ -421,8 +428,9 @@ public class DynmapPlugin extends JavaPlugin {
Location loc = b.getLocation(); Location loc = b.getLocation();
mm.sscache.invalidateSnapshot(loc); mm.sscache.invalidateSnapshot(loc);
BlockFace dir = event.getDirection(); BlockFace dir = event.getDirection();
if(onpiston) if(onpiston) {
mm.touchVolume(loc, b.getRelative(dir, 2).getLocation()); mm.touchVolume(loc, b.getRelative(dir, 2).getLocation());
}
for(int i = 0; i < 2; i++) { for(int i = 0; i < 2; i++) {
b = b.getRelative(dir, 1); b = b.getRelative(dir, 1);
mm.sscache.invalidateSnapshot(b.getLocation()); mm.sscache.invalidateSnapshot(b.getLocation());
@ -436,8 +444,9 @@ public class DynmapPlugin extends JavaPlugin {
Location loc = b.getLocation(); Location loc = b.getLocation();
mm.sscache.invalidateSnapshot(loc); mm.sscache.invalidateSnapshot(loc);
BlockFace dir = event.getDirection(); BlockFace dir = event.getDirection();
if(onpiston) if(onpiston) {
mm.touchVolume(loc, b.getRelative(dir, 1+event.getLength()).getLocation()); mm.touchVolume(loc, b.getRelative(dir, 1+event.getLength()).getLocation());
}
for(int i = 0; i < 1+event.getLength(); i++) { for(int i = 0; i < 1+event.getLength(); i++) {
b = b.getRelative(dir, 1); b = b.getRelative(dir, 1);
mm.sscache.invalidateSnapshot(b.getLocation()); mm.sscache.invalidateSnapshot(b.getLocation());

View file

@ -105,12 +105,21 @@ public class DynmapWorld {
} }
} }
private static final String COORDSTART = "-0123456789";
private static class PNGFileFilter implements FilenameFilter { private static class PNGFileFilter implements FilenameFilter {
String prefix; String prefix;
String suffix; String suffix;
public PNGFileFilter(String pre, MapType.ImageFormat fmt) { prefix = pre; suffix = "." + fmt.getFileExt(); } public PNGFileFilter(String pre, MapType.ImageFormat fmt) {
if((pre != null) && (pre.length() > 0))
prefix = pre;
suffix = "." + fmt.getFileExt();
}
public boolean accept(File f, String n) { public boolean accept(File f, String n) {
if(n.endsWith(suffix) && n.startsWith(prefix)) { if(n.endsWith(suffix)) {
if((prefix != null) && (!n.startsWith(prefix)))
return false;
if((prefix == null) && (COORDSTART.indexOf(n.charAt(0)) < 0))
return false;
File fn = new File(f, n); File fn = new File(f, n);
return fn.isFile(); return fn.isFile();
} }

View file

@ -658,8 +658,8 @@ public class MapManager {
} }
public void invalidateTile(MapTile tile) { public void invalidateTile(MapTile tile) {
Debug.debug("Invalidating tile " + tile.getFilename()); if(tileQueue.push(tile))
tileQueue.push(tile); Debug.debug("Invalidating tile " + tile.getFilename());
} }
public static void scheduleDelayedJob(Runnable job, long delay_in_msec) { public static void scheduleDelayedJob(Runnable job, long delay_in_msec) {

View file

@ -538,6 +538,22 @@ public class FlatMap extends MapType {
return map.getAdjecentTiles(this); return map.getAdjecentTiles(this);
} }
@Override
public int hashCode() {
return x ^ y ^ size ^ map.getName().hashCode();
}
@Override
public boolean equals(Object x) {
if(x instanceof FlatMapTile) {
return equals((FlatMapTile)x);
}
return false;
}
public boolean equals(FlatMapTile o) {
return (o.x == x) && (o.y == y) && (o.map == map);
}
@Override @Override
public String getKey() { public String getKey() {
return world.world.getName() + "." + map.getPrefix(); return world.world.getName() + "." + map.getPrefix();

View file

@ -40,7 +40,7 @@ public class HDMapTile extends MapTile {
@Override @Override
public int hashCode() { public int hashCode() {
return perspective.getName().hashCode() ^ getWorld().hashCode(); return tx ^ ty ^ perspective.getName().hashCode() ^ getWorld().getName().hashCode();
} }
@Override @Override
@ -48,11 +48,11 @@ public class HDMapTile extends MapTile {
if (obj instanceof HDMapTile) { if (obj instanceof HDMapTile) {
return equals((HDMapTile) obj); return equals((HDMapTile) obj);
} }
return super.equals(obj); return false;
} }
public boolean equals(HDMapTile o) { public boolean equals(HDMapTile o) {
return o.tx == tx && o.ty == ty && o.getWorld().equals(getWorld()) && (perspective.equals(o.perspective)); return o.tx == tx && o.ty == ty && (perspective == o.perspective) && (o.getWorld() == getWorld());
} }
public String getKey() { public String getKey() {

View file

@ -52,7 +52,7 @@ public class KzedMapTile extends MapTile {
@Override @Override
public int hashCode() { public int hashCode() {
return getFilename().hashCode() ^ getWorld().hashCode(); return px ^ py ^ map.getName().hashCode() ^ getWorld().getName().hashCode();
} }
@Override @Override
@ -60,11 +60,11 @@ public class KzedMapTile extends MapTile {
if (obj instanceof KzedMapTile) { if (obj instanceof KzedMapTile) {
return equals((KzedMapTile) obj); return equals((KzedMapTile) obj);
} }
return super.equals(obj); return false;
} }
public boolean equals(KzedMapTile o) { public boolean equals(KzedMapTile o) {
return o.px == px && o.py == py && o.getWorld().equals(getWorld()); return o.px == px && o.py == py && (o.map == map) && (o.getWorld() == getWorld());
} }
public String getKey() { public String getKey() {