Tabs and spaces.

This commit is contained in:
zeeZ 2011-05-16 14:51:18 +02:00
parent b01e0c8cdc
commit 05f3ced64f
33 changed files with 306 additions and 306 deletions

View file

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

View file

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

View file

@ -21,7 +21,7 @@ public class HighlightTileRenderer extends DefaultTileRenderer {
highlightBlocks.add((Integer)highlightObj);
}
}
@Override
protected void scan(World world, int x, int y, int z, int seq, boolean isnether, final Color result) {
result.setTransparent();
@ -31,20 +31,20 @@ public class HighlightTileRenderer extends DefaultTileRenderer {
}
int id = world.getBlockTypeIdAt(x, y, z);
if(isnether) { /* Make bedrock ceiling into air in nether */
if(id != 0) {
/* Remember first color we see, in case we wind up solid */
if(result.isTransparent())
if(colorScheme.colors[id] != null)
result.setColor(colorScheme.colors[id][seq]);
id = 0;
}
else
isnether = false;
if(isnether) { /* Make bedrock ceiling into air in nether */
if(id != 0) {
/* Remember first color we see, in case we wind up solid */
if(result.isTransparent())
if(colorScheme.colors[id] != null)
result.setColor(colorScheme.colors[id][seq]);
id = 0;
}
else
isnether = false;
}
byte data = 0;
if(colorScheme.datacolors[id] != null) { /* If data colored */
data = world.getBlockAt(x, y, z).getData();
if(colorScheme.datacolors[id] != null) { /* If data colored */
data = world.getBlockAt(x, y, z).getData();
}
switch (seq) {
@ -67,9 +67,9 @@ public class HighlightTileRenderer extends DefaultTileRenderer {
if (id != 0) {
Color[] colors;
if(data != 0)
colors = colorScheme.datacolors[id][data];
colors = colorScheme.datacolors[id][data];
else
colors = colorScheme.colors[id];
colors = colorScheme.colors[id];
if (colors != null) {
Color c = colors[seq];
@ -85,9 +85,9 @@ public class HighlightTileRenderer extends DefaultTileRenderer {
* if (c.getAlpha() == 255) { return c; }
*/
/* this block is transparent, so recurse */
// No need to blend if result is opaque.
if (result.getAlpha() < 255) {
if (result.getAlpha() < 255) {
int cr = result.getRed();
int cg = result.getGreen();
int cb = result.getBlue();
@ -96,7 +96,7 @@ public class HighlightTileRenderer extends DefaultTileRenderer {
cg *= ca;
cb *= ca;
int na = 255 - ca;
result.setRGBA((c.getRed() * na + cr) >> 8, (c.getGreen() * na + cg) >> 8, (c.getBlue() * na + cb) >> 8,
Math.min(255, c.getAlpha()+ca) // Not really correct, but gets the job done without recursion while still looking ok.
);

View file

@ -67,7 +67,7 @@ public class KzedMap extends MapType {
@Override
public MapTile[] getTiles(Location l) {
World world = l.getWorld();
int x = l.getBlockX();
int y = l.getBlockY();
int z = l.getBlockZ();
@ -141,7 +141,7 @@ public class KzedMap extends MapType {
/**
* Test if point x,z is inside rectangle with corner at r0x,r0z and with
* size vectors s1x,s1z and s2x,s2z
*
*
*/
private boolean testPointInRectangle(int x, int z, int r0x, int r0z, int s1x, int s1z,
int s2x, int s2z) {
@ -150,7 +150,7 @@ public class KzedMap extends MapType {
int dots1 = xr*s1x + zr*s1z;
int dots2 = xr*s2x + zr*s2z;
/* If dot product of relative point and each side is between zero and dot product
* of each side and itself, we're inside
* of each side and itself, we're inside
*/
if((dots1 >= 0) && (dots1 <= (s1x*s1x+s1z*s1z)) &&
(dots2 >= 0) && (dots2 <= (s2x*s2x+s2z*s2z))) {
@ -162,11 +162,11 @@ public class KzedMap extends MapType {
public DynmapChunk[] getRequiredChunks(MapTile tile) {
if (tile instanceof KzedMapTile) {
KzedMapTile t = (KzedMapTile) tile;
int ix = KzedMap.anchorx + t.px / 2 + t.py / 2;
//int iy = 127;
int iz = KzedMap.anchorz + t.px / 2 - t.py / 2;
int x1 = ix - KzedMap.tileHeight / 2;
int x2 = ix + KzedMap.tileWidth / 2 + KzedMap.tileHeight / 2;
@ -183,10 +183,10 @@ public class KzedMap extends MapType {
* render path to y=0), correspond to ix-64, iz+64 to
* ix,iz+128 to ix+64,iz+64 to ix,iz. Projection of
* the prism on to the x,z plane (which is all that matters for
* chunks) yields a diagonal rectangular area from ix-64(x1),iz+64
* to ix,iz+128(z2) to ix+128(x2),iz to ix+64,iz-64(z1).
* chunks) yields a diagonal rectangular area from ix-64(x1),iz+64
* to ix,iz+128(z2) to ix+128(x2),iz to ix+64,iz-64(z1).
* Chunks outside this are not needed - we scan a simple rectangle
* (chunk grid aligned) and skip adding the ones that are outside.
* (chunk grid aligned) and skip adding the ones that are outside.
* This results in 42% less chunks being loaded.
*/
ArrayList<DynmapChunk> chunks = new ArrayList<DynmapChunk>();
@ -211,7 +211,7 @@ public class KzedMap extends MapType {
chunks.add(chunk);
}
}
DynmapChunk[] result = new DynmapChunk[chunks.size()];
chunks.toArray(result);
return result;

View file

@ -9,7 +9,7 @@ public class KzedMapTile extends MapTile {
public KzedMap map;
public MapTileRenderer renderer;
public int px, py;
// Hack.
public File file = null;