From 21ecd200927ed41a315a6d5d952d59e1e5439d18 Mon Sep 17 00:00:00 2001 From: "jason@long.name" Date: Wed, 27 Feb 2013 01:30:30 +0000 Subject: [PATCH] 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 --- src/micropolisj/engine/MicropolisTool.java | 23 +++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/micropolisj/engine/MicropolisTool.java b/src/micropolisj/engine/MicropolisTool.java index fde34bc..81cd5fe 100644 --- a/src/micropolisj/engine/MicropolisTool.java +++ b/src/micropolisj/engine/MicropolisTool.java @@ -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));