town_cmd.c
changeset 260 32fcaaf9f4ef
parent 193 0a7025304867
child 314 a71488713a05
--- a/town_cmd.c	Wed Sep 15 18:01:43 2004 +0000
+++ b/town_cmd.c	Wed Sep 15 18:36:33 2004 +0000
@@ -694,6 +694,7 @@
 	const TileIndexDiff *ptr;
 	int offs;
 	TileInfo ti;
+	byte old_player;
 
 	static const TileIndexDiff _town_coord_mod[] = {
 		TILE_XY(-1,0),
@@ -712,6 +713,7 @@
 	};
 
 	// Current player is a town
+	old_player = _current_player;
 	_current_player = OWNER_TOWN;
 
 	// Find a road that we can base the construction on.
@@ -719,7 +721,9 @@
 	ptr = _town_coord_mod;
 	do {
 		if (GetRoadBitsByTile(tile) != 0) {
-			return GrowTownAtRoad(t, tile);
+			int r = GrowTownAtRoad(t, tile);
+			_current_player = old_player;
+			return r;
 		}
 		offs = *ptr++;
 
@@ -737,6 +741,7 @@
 		if (ti.tileh == 0 && !(ti.type==MP_HOUSE && ti.map5==0)) {
 			if (DoCommandByTile(tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR) != CMD_ERROR) {
 				DoCommandByTile(tile, GenRandomRoadBits(), 0, DC_EXEC | DC_AUTO, CMD_BUILD_ROAD);
+				_current_player = old_player;
 				return true;
 			}
 		}
@@ -744,6 +749,7 @@
 		tile = TILE_ADD(tile, offs);
 	} while (offs != 0);
 
+	_current_player = old_player;
 	return false;
 }