Tabs -> spaces

git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@331 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Dave Hoover
2007-06-26 00:07:57 +00:00
parent 1c92282772
commit 6b1066169f
35 changed files with 441 additions and 441 deletions
+5 -5
View File
@@ -28,29 +28,29 @@ package com.threerings.puzzle;
public class Log
{
public static com.samskivert.util.Log log =
new com.samskivert.util.Log("puzzle");
new com.samskivert.util.Log("puzzle");
/** Convenience function. */
public static void debug (String message)
{
log.debug(message);
log.debug(message);
}
/** Convenience function. */
public static void info (String message)
{
log.info(message);
log.info(message);
}
/** Convenience function. */
public static void warning (String message)
{
log.warning(message);
log.warning(message);
}
/** Convenience function. */
public static void logStackTrace (Throwable t)
{
log.logStackTrace(com.samskivert.util.Log.WARNING, t);
log.logStackTrace(com.samskivert.util.Log.WARNING, t);
}
}
@@ -656,9 +656,9 @@ public abstract class PuzzleController extends GameController
if (cmd.equals(TOGGLE_CHATTING)) {
setChatting(!isChatting());
} else {
} else {
return super.handleAction(action);
}
}
return true;
}
@@ -44,7 +44,7 @@ public class DropBlockSprite extends DropSprite
public DropBlockSprite (
DropBoardView view, int col, int row, int orient, int[] pieces)
{
super(view, col, row, pieces, 0);
super(view, col, row, pieces, 0);
_orient = orient;
}
@@ -63,7 +63,7 @@ public class DropBlockSprite extends DropSprite
DropBoardView view, int col, int row, int orient, int[] pieces,
int renderOrder)
{
super(view, col, row, pieces, 0, renderOrder);
super(view, col, row, pieces, 0, renderOrder);
_orient = orient;
}
@@ -73,7 +73,7 @@ public class DropBlockSprite extends DropSprite
{
super.init();
setOrientation(_orient);
setOrientation(_orient);
}
/**
@@ -151,18 +151,18 @@ public class DropBlockSprite extends DropSprite
*/
public void setOrientation (int orient)
{
super.setOrientation(orient);
super.setOrientation(orient);
int edx = 0, edy = 0;
if (orient == NORTH) {
edy = -1;
} else if (orient == WEST) {
edx = -1;
}
int edx = 0, edy = 0;
if (orient == NORTH) {
edy = -1;
} else if (orient == WEST) {
edx = -1;
}
// update the sprite image offset
setRowOffset(edy);
setColumnOffset(edx);
setRowOffset(edy);
setColumnOffset(edx);
// update the external piece position and drop block bounds
updateDropInfo();
@@ -171,9 +171,9 @@ public class DropBlockSprite extends DropSprite
// documentation inherited
public void toString (StringBuilder buf)
{
super.toString(buf);
buf.append(", erow=").append(_erow);
buf.append(", ecol=").append(_ecol);
super.toString(buf);
buf.append(", erow=").append(_erow);
buf.append(", ecol=").append(_ecol);
}
/**
@@ -231,11 +231,11 @@ public class DropBlockSprite extends DropSprite
*/
protected int calculateExternalRow ()
{
if (_orient == NORTH) {
return (_row - 1);
} else if (_orient == SOUTH) {
return (_row + 1);
} else {
if (_orient == NORTH) {
return (_row - 1);
} else if (_orient == SOUTH) {
return (_row + 1);
} else {
return _row;
}
}
@@ -246,11 +246,11 @@ public class DropBlockSprite extends DropSprite
*/
protected int calculateExternalColumn ()
{
if (_orient == WEST) {
return (_col - 1);
} else if (_orient == EAST) {
return (_col + 1);
} else {
if (_orient == WEST) {
return (_col - 1);
} else if (_orient == EAST) {
return (_col + 1);
} else {
return _col;
}
}
@@ -410,7 +410,7 @@ public abstract class DropBoardView extends PuzzleBoardView
*/
public DropSprite createPieces (int col, int row, int[] pieces, int dist)
{
return new DropSprite(this, col, row, pieces, dist);
return new DropSprite(this, col, row, pieces, dist);
}
/**
@@ -539,9 +539,9 @@ public abstract class DropBoardView extends PuzzleBoardView
// documentation inherited
public Dimension getPreferredSize ()
{
int wid = _bwid * _pwid;
int wid = _bwid * _pwid;
int hei = _bhei * _phei;
return new Dimension(wid, hei);
return new Dimension(wid, hei);
}
/**
@@ -274,9 +274,9 @@ public abstract class DropControllerDelegate extends PuzzleControllerDelegate
} else if (cmd.equals(END_DROP_BLOCK)) {
handleDropBlock(false);
} else {
} else {
return super.handleAction(action);
}
}
return true;
}
@@ -322,7 +322,7 @@ public abstract class DropControllerDelegate extends PuzzleControllerDelegate
if (checkBlockLanded(source, false, false)) {
startBounceTimer(source);
}
}
}
return handled;
}
@@ -355,7 +355,7 @@ public abstract class DropControllerDelegate extends PuzzleControllerDelegate
int fcol = col + (pos.x - bb.x);
// Log.info("Valid move [row=" + frow + ", col=" + col + "].");
_blocksprite.setBoardLocation(frow, fcol);
}
}
}
/**
@@ -386,8 +386,8 @@ public abstract class DropControllerDelegate extends PuzzleControllerDelegate
// ", col=" + info[1] + ", row=" + info[2] +
// ", blocksprite=" + _blocksprite + "].");
// update the piece image
_dview.rotateDropBlock(_blocksprite, info[0]);
// update the piece image
_dview.rotateDropBlock(_blocksprite, info[0]);
// place the block in its newly rotated location
_blocksprite.setBoardLocation(info[2], info[1]);
@@ -72,8 +72,8 @@ public class DropSprite extends Sprite
_view = view;
_col = col;
_row = row;
_pieces = pieces;
_dist = (dist == 0) ? 1 : dist;
_pieces = pieces;
_dist = (dist == 0) ? 1 : dist;
_orient = NORTH;
_unit = _view.getPieceHeight();
setRenderOrder(renderOrder);
@@ -86,10 +86,10 @@ public class DropSprite extends Sprite
// size the bounds to fit our pieces
updateBounds();
// set up the piece location
setBoardLocation(_row, _col);
// calculate vertical render offset based on the number of pieces
setRowOffset(-(_pieces.length - 1));
// set up the piece location
setBoardLocation(_row, _col);
// calculate vertical render offset based on the number of pieces
setRowOffset(-(_pieces.length - 1));
}
/**
@@ -97,7 +97,7 @@ public class DropSprite extends Sprite
*/
public int getDistance ()
{
return _dist;
return _dist;
}
/**
@@ -105,7 +105,7 @@ public class DropSprite extends Sprite
*/
public int getColumn ()
{
return _col;
return _col;
}
/**
@@ -113,7 +113,7 @@ public class DropSprite extends Sprite
*/
public int getRow ()
{
return _row;
return _row;
}
/**
@@ -121,7 +121,7 @@ public class DropSprite extends Sprite
*/
public int[] getPieces ()
{
return _pieces;
return _pieces;
}
/**
@@ -129,7 +129,7 @@ public class DropSprite extends Sprite
*/
public float getVelocity ()
{
return _vel;
return _vel;
}
/**
@@ -137,9 +137,9 @@ public class DropSprite extends Sprite
*/
public void setBoardLocation (int row, int col)
{
_row = row;
_col = col;
updatePosition();
_row = row;
_col = col;
updatePosition();
}
/**
@@ -147,8 +147,8 @@ public class DropSprite extends Sprite
*/
public void setColumn (int col)
{
_col = col;
updatePosition();
_col = col;
updatePosition();
}
/**
@@ -156,8 +156,8 @@ public class DropSprite extends Sprite
*/
public void setRow (int row)
{
_row = row;
updatePosition();
_row = row;
updatePosition();
}
/**
@@ -165,9 +165,9 @@ public class DropSprite extends Sprite
*/
public void setColumnOffset (int count)
{
_offx = count;
_offx = count;
updateRenderOffset();
updateRenderOrigin();
updateRenderOrigin();
}
/**
@@ -175,9 +175,9 @@ public class DropSprite extends Sprite
*/
public void setRowOffset (int count)
{
_offy = count;
_offy = count;
updateRenderOffset();
updateRenderOrigin();
updateRenderOrigin();
}
/**
@@ -213,8 +213,8 @@ public class DropSprite extends Sprite
_rowstamp = now - msecs;
}
// update the velocity
_vel = velocity;
// update the velocity
_vel = velocity;
}
/**
@@ -229,17 +229,17 @@ public class DropSprite extends Sprite
_dist = 1;
}
if (_stopstamp > 0) {
// we're dropping from a stand-still
if (_stopstamp > 0) {
// we're dropping from a stand-still
long delta = _view.getTimeStamp() - _stopstamp;
_rowstamp += delta;
_rowstamp += delta;
_stopstamp = 0;
} else {
} else {
// we're continuing a previous drop, so make use of any
// previously existing time
_rowstamp = _endstamp;
}
}
}
/**
@@ -307,7 +307,7 @@ public class DropSprite extends Sprite
// documentation inherited
public boolean inside (Shape shape)
{
return shape.contains(_bounds);
return shape.contains(_bounds);
}
/**
@@ -324,8 +324,8 @@ public class DropSprite extends Sprite
return 0.0f;
}
long msecs = Math.max(0, timestamp - _rowstamp);
float travpix = msecs * _vel;
long msecs = Math.max(0, timestamp - _rowstamp);
float travpix = msecs * _vel;
float pctdone = (travpix / _unit);
// Log.info("getPercentDone [timestamp=" + timestamp +
@@ -333,7 +333,7 @@ public class DropSprite extends Sprite
// ", travpix=" + travpix + ", pctdone=" + pctdone +
// ", vel=" + _vel + "].");
return pctdone;
return pctdone;
}
// documentation inherited
@@ -373,7 +373,7 @@ public class DropSprite extends Sprite
// documentation inherited
public void tick (long timestamp)
{
super.tick(timestamp);
super.tick(timestamp);
// initialize our rowstamp if we haven't done so already
if (_rowstamp == 0) {
@@ -387,18 +387,18 @@ public class DropSprite extends Sprite
PieceMovedOp pmop = null;
// figure out how far along the current board coordinate we should be
float pctdone = getPercentDone(timestamp);
if (pctdone >= 1.0f) {
// note that we've reached the next row
// figure out how far along the current board coordinate we should be
float pctdone = getPercentDone(timestamp);
if (pctdone >= 1.0f) {
// note that we've reached the next row
advancePosition();
// update remaining drop distance
_dist--;
// update remaining drop distance
_dist--;
// calculate any remaining time to be used
long used = (long)(_unit / _vel);
_endstamp = _rowstamp + used;
// calculate any remaining time to be used
long used = (long)(_unit / _vel);
_endstamp = _rowstamp + used;
_rowstamp = _endstamp;
// update our percent done because we've moved down a row
@@ -406,7 +406,7 @@ public class DropSprite extends Sprite
// inform observers that we've reached our destination
pmop = new PieceMovedOp(this, timestamp, _col, _row);
}
}
// constrain the sprite's position to the destination row
pctdone = Math.min(pctdone, 1.0f);
@@ -453,11 +453,11 @@ public class DropSprite extends Sprite
{
super.toString(buf);
buf.append(", orient=").append(DirectionUtil.toShortString(_orient));
buf.append(", row=").append(_row);
buf.append(", col=").append(_col);
buf.append(", offx=").append(_offx);
buf.append(", offy=").append(_offy);
buf.append(", dist=").append(_dist);
buf.append(", row=").append(_row);
buf.append(", col=").append(_col);
buf.append(", offx=").append(_offx);
buf.append(", offy=").append(_offy);
buf.append(", dist=").append(_dist);
}
/**
@@ -467,7 +467,7 @@ public class DropSprite extends Sprite
{
_view.getPiecePosition(_col, _row, _srcPos);
_view.getPiecePosition(_col, _row+1, _destPos);
setLocation(_srcPos.x, _srcPos.y);
setLocation(_srcPos.x, _srcPos.y);
}
// documentation inherited
@@ -160,14 +160,14 @@ public class DropBoard extends Board
*/
public int getDropDistance (int col, int row)
{
int dist = 0;
for (int yy = row + 1; yy < _bhei; yy++) {
if (getPiece(col, yy) != PIECE_NONE) {
return dist;
}
dist++;
}
return dist;
int dist = 0;
for (int yy = row + 1; yy < _bhei; yy++) {
if (getPiece(col, yy) != PIECE_NONE) {
return dist;
}
dist++;
}
return dist;
}
/**
@@ -591,9 +591,9 @@ public class DropBoard extends Board
padwid *= 2;
}
for (int y = 0; y < _bhei; y++) {
StringBuilder buf = new StringBuilder();
for (int x = 0; x < _bwid; x++) {
for (int y = 0; y < _bhei; y++) {
StringBuilder buf = new StringBuilder();
for (int x = 0; x < _bwid; x++) {
int piece = getPiece(x, y);
String str = formatPiece(piece);
if (dother != null) {
@@ -603,9 +603,9 @@ public class DropBoard extends Board
}
}
buf.append(StringUtils.rightPad(str, padwid));
}
System.err.println(buf.toString());
}
}
System.err.println(buf.toString());
}
}
/** Returns a string representation of this instance. */
@@ -129,7 +129,7 @@ public abstract class DropManagerDelegate extends PuzzleManagerDelegate
*/
protected boolean dropPieces (DropBoard board)
{
return (_dropper.dropPieces(board, null) > 0);
return (_dropper.dropPieces(board, null) > 0);
}
/**
@@ -43,33 +43,33 @@ public class PieceDropper
*/
public static class PieceDropInfo
{
/** The starting row of the bottom piece being dropped. */
public int row;
/** The starting row of the bottom piece being dropped. */
public int row;
/** The column number. */
public int col;
/** The column number. */
public int col;
/** The distance to drop the pieces. */
public int dist;
/** The distance to drop the pieces. */
public int dist;
/** The pieces to be dropped. */
public int[] pieces;
/** The pieces to be dropped. */
public int[] pieces;
/**
* Constructs a piece drop info object.
*/
public PieceDropInfo (int col, int row, int dist)
{
this.col = col;
this.row = row;
this.dist = dist;
}
public PieceDropInfo (int col, int row, int dist)
{
this.col = col;
this.row = row;
this.dist = dist;
}
/** Returns a string representation of this instance. */
public String toString ()
{
public String toString ()
{
return StringUtil.fieldsToString(this);
}
}
}
/**
@@ -100,11 +100,11 @@ public class PieceDropper
public int dropPieces (DropBoard board, DropObserver drobs)
{
int dropped = 0, bhei = board.getHeight(), bwid = board.getWidth();
for (int yy = bhei - 1; yy >= 0; yy--) {
for (int xx = 0; xx < bwid; xx++) {
for (int yy = bhei - 1; yy >= 0; yy--) {
for (int xx = 0; xx < bwid; xx++) {
dropped += dropPieces(board, xx, yy, drobs);
}
}
}
}
// if the board wants pieces to be dropped in to fill the gaps, do
// that now
@@ -133,14 +133,14 @@ public class PieceDropper
protected int dropPieces (
DropBoard board, int xx, int yy, DropObserver drobs)
{
// skip empty or fixed pieces
int piece = board.getPiece(xx, yy);
// skip empty or fixed pieces
int piece = board.getPiece(xx, yy);
if (!_logic.isDroppablePiece(piece)) {
return 0;
}
return 0;
}
int dropped = 0;
if (_logic.isConstrainedPiece(piece)) {
if (_logic.isConstrainedPiece(piece)) {
// find out where this constrained block starts and ends
int start = _logic.getConstrainedEdge(board, xx, yy, LEFT);
int end = _logic.getConstrainedEdge(board, xx, yy, RIGHT);
@@ -159,27 +159,27 @@ public class PieceDropper
for (int xpos = start; xpos <= end; xpos++) {
dist = Math.min(dist, board.getDropDistance(xpos, yy));
}
if (dist == 0) {
return 0;
}
if (dist == 0) {
return 0;
}
// scoot along the bottom edge of the block, noting the drop
// for each column
// scoot along the bottom edge of the block, noting the drop
// for each column
for (int xpos = start; xpos <= end; xpos++) {
piece = board.getPiece(xpos, yy);
drop(board, piece, xpos, yy, yy + dist, drobs);
dropped++;
}
}
} else {
// get the distance to drop the pieces
int dist = board.getDropDistance(xx, yy);
if (dist == 0) {
return 0;
}
} else {
// get the distance to drop the pieces
int dist = board.getDropDistance(xx, yy);
if (dist == 0) {
return 0;
}
drop(board, piece, xx, yy, yy + dist, drobs);
dropped++;
}
}
return dropped;
}
@@ -41,9 +41,9 @@ public class PointSet
*/
public PointSet (int rangeX, int rangeY)
{
_rangeX = rangeX;
_rangeY = rangeY;
_points = new boolean[rangeX][rangeY];
_rangeX = rangeX;
_rangeY = rangeY;
_points = new boolean[rangeX][rangeY];
}
/**
@@ -57,12 +57,12 @@ public class PointSet
*/
public boolean add (int x, int y)
{
boolean present = _points[x][y];
_points[x][y] = true;
if (!present) {
_count++;
}
return present;
boolean present = _points[x][y];
_points[x][y] = true;
if (!present) {
_count++;
}
return present;
}
/**
@@ -72,11 +72,11 @@ public class PointSet
*/
public void addAll (PointSet set)
{
Iterator iter = set.iterator();
Point pt;
while ((pt = (Point)iter.next()) != null) {
add(pt.x, pt.y);
}
Iterator iter = set.iterator();
Point pt;
while ((pt = (Point)iter.next()) != null) {
add(pt.x, pt.y);
}
}
/**
@@ -84,17 +84,17 @@ public class PointSet
*/
public void clear ()
{
if (_count == 0) {
// no need to clear anything
return;
}
if (_count == 0) {
// no need to clear anything
return;
}
for (int xx = 0; xx < _rangeX; xx++) {
for (int yy = 0; yy < _rangeY; yy++) {
_points[xx][yy] = false;
}
}
_count = 0;
for (int xx = 0; xx < _rangeX; xx++) {
for (int yy = 0; yy < _rangeY; yy++) {
_points[xx][yy] = false;
}
}
_count = 0;
}
/**
@@ -107,7 +107,7 @@ public class PointSet
*/
public boolean contains (int x, int y)
{
return (_points[x][y]);
return (_points[x][y]);
}
/**
@@ -117,7 +117,7 @@ public class PointSet
*/
public boolean isEmpty ()
{
return (_count == 0);
return (_count == 0);
}
/**
@@ -131,7 +131,7 @@ public class PointSet
*/
public Iterator iterator ()
{
return new PointIterator();
return new PointIterator();
}
/**
@@ -145,12 +145,12 @@ public class PointSet
*/
public boolean remove (int x, int y)
{
boolean present = _points[x][y];
_points[x][y] = false;
if (present) {
_count--;
}
return present;
boolean present = _points[x][y];
_points[x][y] = false;
if (present) {
_count--;
}
return present;
}
/**
@@ -160,7 +160,7 @@ public class PointSet
*/
public int size ()
{
return _count;
return _count;
}
/**
@@ -168,70 +168,70 @@ public class PointSet
*/
public String toString ()
{
StringBuilder buf = new StringBuilder();
buf.append("[");
Iterator iter = iterator();
Point val;
while ((val = (Point)iter.next()) != null) {
buf.append("(").append(val.x);
buf.append(",").append(val.y);
buf.append(")");
StringBuilder buf = new StringBuilder();
buf.append("[");
Iterator iter = iterator();
Point val;
while ((val = (Point)iter.next()) != null) {
buf.append("(").append(val.x);
buf.append(",").append(val.y);
buf.append(")");
if (iter.hasNext()) {
buf.append(", ");
}
}
return buf.append("]").toString();
if (iter.hasNext()) {
buf.append(", ");
}
}
return buf.append("]").toString();
}
protected class PointIterator implements Iterator
{
public boolean hasNext ()
{
return (_curCount < _count);
}
public boolean hasNext ()
{
return (_curCount < _count);
}
public Object next ()
{
if (_curCount == _count) {
return null;
}
public Object next ()
{
if (_curCount == _count) {
return null;
}
while (!_points[_curX][_curY]) {
advance();
}
while (!_points[_curX][_curY]) {
advance();
}
_curCount++;
_point.setLocation(_curX, _curY);
_curCount++;
_point.setLocation(_curX, _curY);
if (_curCount < _count) {
advance();
}
if (_curCount < _count) {
advance();
}
return _point;
}
return _point;
}
public void remove ()
{
throw new UnsupportedOperationException();
}
public void remove ()
{
throw new UnsupportedOperationException();
}
protected void advance ()
{
if ((++_curX) >= _rangeX) {
_curX = 0;
_curY++;
}
protected void advance ()
{
if ((++_curX) >= _rangeX) {
_curX = 0;
_curY++;
}
if (_curY >= _rangeY) {
Log.warning("Advanced past point range.");
_curY = 0;
}
}
if (_curY >= _rangeY) {
Log.warning("Advanced past point range.");
_curY = 0;
}
}
protected int _curCount = 0;
protected int _curX = 0, _curY = 0;
protected Point _point = new Point();
protected int _curCount = 0;
protected int _curX = 0, _curY = 0;
protected Point _point = new Point();
}
/** The dimensions of the point array. */