From 8b428bfc29d74a1ba1ab37504eaa47ee299da2af Mon Sep 17 00:00:00 2001 From: "jason@long.name" Date: Wed, 27 Feb 2013 01:30:10 +0000 Subject: [PATCH] autobulldoze: prepare for movement of auto-bulldoze code When road/rail/wire tool is used, auto-bulldozing occurs before checking the cost of the road/rail/wire being placed. This means when the user is low on funds, the wire tool may end up bulldozing only, even though there is not enough money for building what they want. This patch prepares the way for moving where the auto-bulldoze check is done in the case of the road/rail/wire tool. git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@588 d9718cc8-9f43-0410-858b-315f434eb58c --- src/micropolisj/engine/MicropolisTool.java | 40 +++++++++++++--------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/micropolisj/engine/MicropolisTool.java b/src/micropolisj/engine/MicropolisTool.java index 5c7bb55..8646ce9 100644 --- a/src/micropolisj/engine/MicropolisTool.java +++ b/src/micropolisj/engine/MicropolisTool.java @@ -575,10 +575,6 @@ public enum MicropolisTool char tile = (char) (engine.getTile(xpos, ypos) & LOMASK); switch (tile) { - case DIRT: //rail on dirt - engine.setTile(xpos, ypos, (char) (LHRAIL | BULLBIT | BURNBIT)); - break; - case RIVER: // rail on water case REDGE: case CHANNEL: @@ -655,7 +651,14 @@ public enum MicropolisTool break; default: - return ToolResult.NONE; + //TODO- check if auto-bulldoze is enabled + if (tile != DIRT) { + return ToolResult.NONE; + } + + //rail on dirt + engine.setTile(xpos, ypos, (char) (LHRAIL | BULLBIT | BURNBIT)); + break; } engine.spend(cost); @@ -674,10 +677,6 @@ public enum MicropolisTool char tile = (char) (engine.getTile(xpos, ypos) & LOMASK); switch (tile) { - case DIRT: - engine.setTile(xpos, ypos, (char) (TileConstants.ROADS | BULLBIT | BURNBIT)); - break; - case RIVER: // road on water case REDGE: case CHANNEL: // check how to build bridges, if possible. @@ -754,7 +753,13 @@ public enum MicropolisTool break; default: - return ToolResult.NONE; + // TODO- auto-bulldoze here + if (tile != DIRT) + return ToolResult.NONE; + + // road on dirt + engine.setTile(xpos, ypos, (char) (TileConstants.ROADS | BULLBIT | BURNBIT)); + break; } engine.spend(cost); @@ -775,10 +780,6 @@ public enum MicropolisTool switch (tile) { - case DIRT: //wire on dirt - engine.setTile(xpos, ypos, (char) (LHPOWER | CONDBIT | BULLBIT | BURNBIT)); - break; - case RIVER: // wire on water case REDGE: case CHANNEL: @@ -866,8 +867,15 @@ public enum MicropolisTool engine.setTile(xpos, ypos, (char) (RAILVPOWERH | CONDBIT | BURNBIT | BULLBIT)); break; - default: //cannot do wire here - return ToolResult.NONE; + default: + if (tile != DIRT) { + //cannot do wire here + return ToolResult.NONE; + } + + //wire on dirt + engine.setTile(xpos, ypos, (char) (LHPOWER | CONDBIT | BULLBIT | BURNBIT)); + break; } engine.spend(cost);