autobulldoze: fix behavior of road and rail tools

now when there's not enough money to build a rail or road,
the auto-bulldoze will not have any effect

git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@591 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
jason@long.name 2013-02-27 01:30:30 +00:00
parent 408d3d44bf
commit 21ecd20092

View file

@ -483,7 +483,6 @@ public enum MicropolisTool
if (!engine.testBounds(xpos, ypos))
return ToolResult.UH_OH;
autoDoze(engine, xpos, ypos);
ToolResult result = layRail(engine, xpos, ypos);
fixZone(engine, xpos, ypos);
return result;
@ -494,7 +493,6 @@ public enum MicropolisTool
if (!engine.testBounds(xpos, ypos))
return ToolResult.UH_OH;
autoDoze(engine, xpos, ypos);
ToolResult result = layRoad(engine, xpos, ypos);
fixZone(engine, xpos, ypos);
return result;
@ -673,9 +671,14 @@ public enum MicropolisTool
break;
default:
//TODO- check if auto-bulldoze is enabled
if (tile != DIRT) {
return ToolResult.NONE;
if (engine.autoBulldoze && canAutoBulldozeRRW(tile)) {
cost += 1; //autodoze cost
}
else {
// cannot do rail here
return ToolResult.NONE;
}
}
//rail on dirt
@ -775,9 +778,15 @@ public enum MicropolisTool
break;
default:
// TODO- auto-bulldoze here
if (tile != DIRT)
return ToolResult.NONE;
if (tile != DIRT) {
if (engine.autoBulldoze && canAutoBulldozeRRW(tile)) {
cost += 1; //autodoze cost
}
else {
// cannot do road here
return ToolResult.NONE;
}
}
// road on dirt
engine.setTile(xpos, ypos, (char) (TileConstants.ROADS | BULLBIT | BURNBIT));