From 408d3d44bf5a4a7388a8bae3b732db5dbe02a908 Mon Sep 17 00:00:00 2001 From: "jason@long.name" Date: Wed, 27 Feb 2013 01:30:23 +0000 Subject: [PATCH] autobulldoze- fix behavior of wire tool now when there's not enough money to build wire, the auto-bulldoze will not have any effect git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@590 d9718cc8-9f43-0410-858b-315f434eb58c --- src/micropolisj/engine/MicropolisTool.java | 26 +++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/micropolisj/engine/MicropolisTool.java b/src/micropolisj/engine/MicropolisTool.java index 67daa0f..fde34bc 100644 --- a/src/micropolisj/engine/MicropolisTool.java +++ b/src/micropolisj/engine/MicropolisTool.java @@ -331,6 +331,22 @@ public enum MicropolisTool } } + /** + * Checks whether the tile can be auto-bulldozed for + * placement of road, rail, or wire. + */ + static boolean canAutoBulldozeRRW(int tileValue) + { + //FIXME- explain why LASTTINYEXP is the upper bound here, + // when the Z-version of this function uses LASTTINYEXP+2 + + // can we autobulldoze this tile? + return ( + (tileValue >= FIRSTRIVEDGE && tileValue <= LASTRUBBLE) || + (tileValue >= TINYEXP && tileValue <= LASTTINYEXP) + ); + } + /** * Checks whether the tile can be auto-bulldozed for * placement of a zone. @@ -529,7 +545,6 @@ public enum MicropolisTool if (!engine.testBounds(xpos, ypos)) return ToolResult.UH_OH; - autoDoze(engine, xpos, ypos); ToolResult result = layWire(engine, xpos, ypos); fixZone(engine, xpos, ypos); return result; @@ -876,8 +891,13 @@ public enum MicropolisTool default: if (tile != DIRT) { - //cannot do wire here - return ToolResult.NONE; + if (engine.autoBulldoze && canAutoBulldozeRRW(tile)) { + cost += 1; //autodoze cost + } + else { + //cannot do wire here + return ToolResult.NONE; + } } //wire on dirt