Tabs and spaces.

This commit is contained in:
zeeZ 2011-05-16 20:51:18 +08:00 committed by Christian
parent 1ba9fe9cff
commit b76e6059ae
33 changed files with 306 additions and 306 deletions

View file

@ -13,7 +13,7 @@ public class UpdateQueue {
public void pushUpdate(Object obj) { public void pushUpdate(Object obj) {
synchronized (lock) { synchronized (lock) {
/* Do inside lock - prevent delay between time and actual work */ /* Do inside lock - prevent delay between time and actual work */
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
long deadline = now - maxUpdateAge; long deadline = now - maxUpdateAge;
ListIterator<Update> i = updateQueue.listIterator(0); ListIterator<Update> i = updateQueue.listIterator(0);

View file

@ -91,36 +91,36 @@ public class FlatMap extends MapType {
int my; int my;
int blockType; int blockType;
if(isnether) { if(isnether) {
/* Scan until we hit air */ /* Scan until we hit air */
my = 127; my = 127;
while((blockType = w.getBlockTypeIdAt(mx, my, mz)) != 0) { while((blockType = w.getBlockTypeIdAt(mx, my, mz)) != 0) {
my--; my--;
if(my < 0) { /* Solid - use top */ if(my < 0) { /* Solid - use top */
my = 127; my = 127;
blockType = w.getBlockTypeIdAt(mx, my, mz); blockType = w.getBlockTypeIdAt(mx, my, mz);
break; break;
} }
} }
if(blockType == 0) { /* Hit air - now find non-air */ if(blockType == 0) { /* Hit air - now find non-air */
while((blockType = w.getBlockTypeIdAt(mx, my, mz)) == 0) { while((blockType = w.getBlockTypeIdAt(mx, my, mz)) == 0) {
my--; my--;
if(my < 0) { if(my < 0) {
my = 0; my = 0;
break; break;
} }
} }
} }
} }
else { else {
my = w.getHighestBlockYAt(mx, mz) - 1; my = w.getHighestBlockYAt(mx, mz) - 1;
if(my > maximumHeight) my = maximumHeight; if(my > maximumHeight) my = maximumHeight;
blockType = w.getBlockTypeIdAt(mx, my, mz); blockType = w.getBlockTypeIdAt(mx, my, mz);
} }
byte data = 0; byte data = 0;
Color[] colors = colorScheme.colors[blockType]; Color[] colors = colorScheme.colors[blockType];
if(colorScheme.datacolors[blockType] != null) { if(colorScheme.datacolors[blockType] != null) {
data = w.getBlockAt(mx, my, mz).getData(); data = w.getBlockAt(mx, my, mz).getData();
colors = colorScheme.datacolors[blockType][data]; colors = colorScheme.datacolors[blockType][data];
} }
if (colors == null) if (colors == null)
continue; continue;
@ -167,19 +167,19 @@ public class FlatMap extends MapType {
final MapTile mtile = tile; final MapTile mtile = tile;
final BufferedImage img = im; final BufferedImage img = im;
MapManager.mapman.enqueueImageWrite(new Runnable() { MapManager.mapman.enqueueImageWrite(new Runnable() {
public void run() { public void run() {
Debug.debug("saving image " + fname.getPath()); Debug.debug("saving image " + fname.getPath());
try { try {
ImageIO.write(img, "png", fname); ImageIO.write(img, "png", fname);
} catch (IOException e) { } catch (IOException e) {
Debug.error("Failed to save image: " + fname.getPath(), e); Debug.error("Failed to save image: " + fname.getPath(), e);
} catch (java.lang.NullPointerException e) { } catch (java.lang.NullPointerException e) {
Debug.error("Failed to save image (NullPointerException): " + fname.getPath(), e); Debug.error("Failed to save image (NullPointerException): " + fname.getPath(), e);
} }
img.flush(); img.flush();
MapManager.mapman.pushUpdate(mtile.getWorld(), MapManager.mapman.pushUpdate(mtile.getWorld(),
new Client.Tile(mtile.getFilename())); new Client.Tile(mtile.getFilename()));
} }
}); });
return rendered; return rendered;

View file

@ -20,11 +20,11 @@ public class CaveTileRenderer extends DefaultTileRenderer {
return; return;
int id = world.getBlockTypeIdAt(x, y, z); int id = world.getBlockTypeIdAt(x, y, z);
if(isnether) { /* Make ceiling into air in nether */ if(isnether) { /* Make ceiling into air in nether */
if(id != 0) if(id != 0)
id = 0; id = 0;
else else
isnether = false; isnether = false;
} }
switch (seq) { switch (seq) {

View file

@ -60,7 +60,7 @@ public class DefaultTileRenderer implements MapTileRenderer {
/* Don't mess with existing height-clipped renders */ /* Don't mess with existing height-clipped renders */
if(maximumHeight < 127) if(maximumHeight < 127)
isnether = false; isnether = false;
int jx, jz; int jx, jz;
@ -126,88 +126,88 @@ public class DefaultTileRenderer implements MapTileRenderer {
final File fname = outputFile; final File fname = outputFile;
final KzedMapTile mtile = tile; final KzedMapTile mtile = tile;
final BufferedImage img = im; final BufferedImage img = im;
final KzedZoomedMapTile zmtile = new KzedZoomedMapTile(mtile.getWorld(), final KzedZoomedMapTile zmtile = new KzedZoomedMapTile(mtile.getWorld(),
(KzedMap) mtile.getMap(), mtile); (KzedMap) mtile.getMap(), mtile);
final File zoomFile = MapManager.mapman.getTileFile(zmtile); final File zoomFile = MapManager.mapman.getTileFile(zmtile);
MapManager.mapman.enqueueImageWrite(new Runnable() { MapManager.mapman.enqueueImageWrite(new Runnable() {
public void run() { public void run() {
doFileWrites(fname, mtile, img, zmtile, zoomFile); doFileWrites(fname, mtile, img, zmtile, zoomFile);
} }
}); });
return !isempty; return !isempty;
} }
private void doFileWrites(final File fname, final KzedMapTile mtile, private void doFileWrites(final File fname, final KzedMapTile mtile,
final BufferedImage img, final KzedZoomedMapTile zmtile, final File zoomFile) { final BufferedImage img, final KzedZoomedMapTile zmtile, final File zoomFile) {
Debug.debug("saving image " + fname.getPath()); Debug.debug("saving image " + fname.getPath());
try { try {
ImageIO.write(img, "png", fname); ImageIO.write(img, "png", fname);
} catch (IOException e) { } catch (IOException e) {
Debug.error("Failed to save image: " + fname.getPath(), e); Debug.error("Failed to save image: " + fname.getPath(), e);
} catch (java.lang.NullPointerException e) { } catch (java.lang.NullPointerException e) {
Debug.error("Failed to save image (NullPointerException): " + fname.getPath(), e); Debug.error("Failed to save image (NullPointerException): " + fname.getPath(), e);
} }
mtile.file = fname; mtile.file = fname;
// Since we've already got the new tile, and we're on an async thread, just // Since we've already got the new tile, and we're on an async thread, just
// make the zoomed tile here // make the zoomed tile here
int px = mtile.px; int px = mtile.px;
int py = mtile.py; int py = mtile.py;
int zpx = zmtile.getTileX(); int zpx = zmtile.getTileX();
int zpy = zmtile.getTileY(); int zpy = zmtile.getTileY();
/* scaled size */ /* scaled size */
int scw = KzedMap.tileWidth / 2; int scw = KzedMap.tileWidth / 2;
int sch = KzedMap.tileHeight / 2; int sch = KzedMap.tileHeight / 2;
/* origin in zoomed-out tile */ /* origin in zoomed-out tile */
int ox = 0; int ox = 0;
int oy = 0; int oy = 0;
if (zpx != px) if (zpx != px)
ox = scw; ox = scw;
if (zpy != py) if (zpy != py)
oy = sch; oy = sch;
BufferedImage zIm = null; BufferedImage zIm = null;
try { try {
zIm = ImageIO.read(zoomFile); zIm = ImageIO.read(zoomFile);
} catch (IOException e) { } catch (IOException e) {
} catch (IndexOutOfBoundsException e) { } catch (IndexOutOfBoundsException e) {
} }
if (zIm == null) { if (zIm == null) {
/* create new one */ /* create new one */
zIm = new BufferedImage(KzedMap.tileWidth, KzedMap.tileHeight, BufferedImage.TYPE_INT_RGB); zIm = new BufferedImage(KzedMap.tileWidth, KzedMap.tileHeight, BufferedImage.TYPE_INT_RGB);
Debug.debug("New zoom-out tile created " + zmtile.getFilename()); Debug.debug("New zoom-out tile created " + zmtile.getFilename());
} else { } else {
Debug.debug("Loaded zoom-out tile from " + zmtile.getFilename()); Debug.debug("Loaded zoom-out tile from " + zmtile.getFilename());
} }
/* blit scaled rendered tile onto zoom-out tile */ /* blit scaled rendered tile onto zoom-out tile */
Graphics2D g2 = zIm.createGraphics(); Graphics2D g2 = zIm.createGraphics();
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g2.drawImage(img, ox, oy, scw, sch, null); g2.drawImage(img, ox, oy, scw, sch, null);
img.flush(); img.flush();
/* save zoom-out tile */ /* save zoom-out tile */
try { try {
ImageIO.write(zIm, "png", zoomFile); ImageIO.write(zIm, "png", zoomFile);
Debug.debug("Saved zoom-out tile at " + zoomFile.getName()); Debug.debug("Saved zoom-out tile at " + zoomFile.getName());
} catch (IOException e) { } catch (IOException e) {
Debug.error("Failed to save zoom-out tile: " + zoomFile.getName(), e); Debug.error("Failed to save zoom-out tile: " + zoomFile.getName(), e);
} catch (java.lang.NullPointerException e) { } catch (java.lang.NullPointerException e) {
Debug.error("Failed to save zoom-out tile (NullPointerException): " + zoomFile.getName(), e); Debug.error("Failed to save zoom-out tile (NullPointerException): " + zoomFile.getName(), e);
} }
zIm.flush(); zIm.flush();
/* Push updates for both files.*/ /* Push updates for both files.*/
MapManager.mapman.pushUpdate(mtile.getWorld(), MapManager.mapman.pushUpdate(mtile.getWorld(),
new Client.Tile(mtile.getFilename())); new Client.Tile(mtile.getFilename()));
MapManager.mapman.pushUpdate(zmtile.getWorld(), MapManager.mapman.pushUpdate(zmtile.getWorld(),
new Client.Tile(zmtile.getFilename())); new Client.Tile(zmtile.getFilename()));
} }
@ -219,19 +219,19 @@ public class DefaultTileRenderer implements MapTileRenderer {
} }
int id = world.getBlockTypeIdAt(x, y, z); int id = world.getBlockTypeIdAt(x, y, z);
byte data = 0; byte data = 0;
if(isnether) { /* Make bedrock ceiling into air in nether */ if(isnether) { /* Make bedrock ceiling into air in nether */
if(id != 0) { if(id != 0) {
/* Remember first color we see, in case we wind up solid */ /* Remember first color we see, in case we wind up solid */
if(result.isTransparent()) if(result.isTransparent())
if(colorScheme.colors[id] != null) if(colorScheme.colors[id] != null)
result.setColor(colorScheme.colors[id][seq]); result.setColor(colorScheme.colors[id][seq]);
id = 0; id = 0;
} }
else else
isnether = false; isnether = false;
} }
if(colorScheme.datacolors[id] != null) { /* If data colored */ if(colorScheme.datacolors[id] != null) { /* If data colored */
data = world.getBlockAt(x, y, z).getData(); data = world.getBlockAt(x, y, z).getData();
} }
switch (seq) { switch (seq) {
case 0: case 0:
@ -257,9 +257,9 @@ public class DefaultTileRenderer implements MapTileRenderer {
} }
Color[] colors; Color[] colors;
if(data != 0) if(data != 0)
colors = colorScheme.datacolors[id][data]; colors = colorScheme.datacolors[id][data];
else else
colors = colorScheme.colors[id]; colors = colorScheme.colors[id];
if (colors != null) { if (colors != null) {
Color c = colors[seq]; Color c = colors[seq];
if (c.getAlpha() > 0) { if (c.getAlpha() > 0) {

View file

@ -31,20 +31,20 @@ public class HighlightTileRenderer extends DefaultTileRenderer {
} }
int id = world.getBlockTypeIdAt(x, y, z); int id = world.getBlockTypeIdAt(x, y, z);
if(isnether) { /* Make bedrock ceiling into air in nether */ if(isnether) { /* Make bedrock ceiling into air in nether */
if(id != 0) { if(id != 0) {
/* Remember first color we see, in case we wind up solid */ /* Remember first color we see, in case we wind up solid */
if(result.isTransparent()) if(result.isTransparent())
if(colorScheme.colors[id] != null) if(colorScheme.colors[id] != null)
result.setColor(colorScheme.colors[id][seq]); result.setColor(colorScheme.colors[id][seq]);
id = 0; id = 0;
} }
else else
isnether = false; isnether = false;
} }
byte data = 0; byte data = 0;
if(colorScheme.datacolors[id] != null) { /* If data colored */ if(colorScheme.datacolors[id] != null) { /* If data colored */
data = world.getBlockAt(x, y, z).getData(); data = world.getBlockAt(x, y, z).getData();
} }
switch (seq) { switch (seq) {
@ -67,9 +67,9 @@ public class HighlightTileRenderer extends DefaultTileRenderer {
if (id != 0) { if (id != 0) {
Color[] colors; Color[] colors;
if(data != 0) if(data != 0)
colors = colorScheme.datacolors[id][data]; colors = colorScheme.datacolors[id][data];
else else
colors = colorScheme.colors[id]; colors = colorScheme.colors[id];
if (colors != null) { if (colors != null) {
Color c = colors[seq]; Color c = colors[seq];