Fix tile coord calculation for tile hash on kzed render - too sparse

because not divided by tile dimensions (inconsistent with flat :<)
This commit is contained in:
Mike Primm 2011-06-01 19:08:53 -05:00
parent 5dbb69f2fe
commit cf71b38259

View File

@ -231,7 +231,9 @@ public class DefaultTileRenderer implements MapTileRenderer {
TileHashManager hashman = MapManager.mapman.hashman; TileHashManager hashman = MapManager.mapman.hashman;
long crc = hashman.calculateTileHash(img.argb_buf); long crc = hashman.calculateTileHash(img.argb_buf);
boolean updated_fname = false; boolean updated_fname = false;
if((!fname.exists()) || (crc != hashman.getImageHashCode(mtile.getKey(), null, mtile.px, mtile.py))) { int tx = mtile.px/KzedMap.tileWidth;
int ty = mtile.py/KzedMap.tileHeight;
if((!fname.exists()) || (crc != hashman.getImageHashCode(mtile.getKey(), null, tx, ty))) {
Debug.debug("saving image " + fname.getPath()); Debug.debug("saving image " + fname.getPath());
try { try {
ImageIO.write(img.buf_img, "png", fname); ImageIO.write(img.buf_img, "png", fname);
@ -241,7 +243,7 @@ public class DefaultTileRenderer implements MapTileRenderer {
Debug.error("Failed to save image (NullPointerException): " + fname.getPath(), e); Debug.error("Failed to save image (NullPointerException): " + fname.getPath(), e);
} }
MapManager.mapman.pushUpdate(mtile.getWorld(), new Client.Tile(mtile.getFilename())); MapManager.mapman.pushUpdate(mtile.getWorld(), new Client.Tile(mtile.getFilename()));
hashman.updateHashCode(mtile.getKey(), null, mtile.px, mtile.py, crc); hashman.updateHashCode(mtile.getKey(), null, tx, ty, crc);
updated_fname = true; updated_fname = true;
} }
KzedMap.freeBufferedImage(img); KzedMap.freeBufferedImage(img);
@ -253,7 +255,7 @@ public class DefaultTileRenderer implements MapTileRenderer {
File dfname = new File(fname.getParent(), mtile.getDayFilename()); File dfname = new File(fname.getParent(), mtile.getDayFilename());
if(img_day != null) { if(img_day != null) {
crc = hashman.calculateTileHash(img.argb_buf); crc = hashman.calculateTileHash(img.argb_buf);
if((!dfname.exists()) || (crc != hashman.getImageHashCode(mtile.getKey(), "day", mtile.px, mtile.py))) { if((!dfname.exists()) || (crc != hashman.getImageHashCode(mtile.getKey(), "day", tx, ty))) {
Debug.debug("saving image " + dfname.getPath()); Debug.debug("saving image " + dfname.getPath());
try { try {
ImageIO.write(img_day.buf_img, "png", dfname); ImageIO.write(img_day.buf_img, "png", dfname);
@ -263,7 +265,7 @@ public class DefaultTileRenderer implements MapTileRenderer {
Debug.error("Failed to save image (NullPointerException): " + dfname.getPath(), e); Debug.error("Failed to save image (NullPointerException): " + dfname.getPath(), e);
} }
MapManager.mapman.pushUpdate(mtile.getWorld(), new Client.Tile(mtile.getDayFilename())); MapManager.mapman.pushUpdate(mtile.getWorld(), new Client.Tile(mtile.getDayFilename()));
hashman.updateHashCode(mtile.getKey(), "day", mtile.px, mtile.py, crc); hashman.updateHashCode(mtile.getKey(), "day", tx, ty, crc);
updated_dfname = true; updated_dfname = true;
} }
KzedMap.freeBufferedImage(img_day); KzedMap.freeBufferedImage(img_day);