(svn r12919) -Fix [FS#1965]: flood road tiles even when there are road works in progress
authorsmatz
Tue, 29 Apr 2008 16:36:44 +0000
changeset 10378 ecad8e9b4cb6
parent 10377 69e632bacb40
child 10379 192780749293
(svn r12919) -Fix [FS#1965]: flood road tiles even when there are road works in progress
src/road_cmd.cpp
--- a/src/road_cmd.cpp	Tue Apr 29 10:26:22 2008 +0000
+++ b/src/road_cmd.cpp	Tue Apr 29 16:36:44 2008 +0000
@@ -233,7 +233,7 @@
 			const RoadBits other = GetOtherRoadBits(tile, rt);
 			const Foundation f = GetRoadFoundation(tileh, present);
 
-			if (HasRoadWorks(tile)) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS);
+			if (HasRoadWorks(tile) && _current_player != OWNER_WATER) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS);
 
 			/* Autocomplete to a straight road
 			 * @li on steep slopes
@@ -260,6 +260,16 @@
 
 			if (town_check) ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM);
 			if (flags & DC_EXEC) {
+				if (HasRoadWorks(tile)) {
+					/* flooding tile with road works, don't forget to remove the effect vehicle too */
+					assert(_current_player == OWNER_WATER);
+					Vehicle *v;
+					FOR_ALL_VEHICLES(v) {
+						if (v->type == VEH_EFFECT && TileVirtXY(v->x_pos, v->y_pos) == tile) {
+							delete v;
+						}
+					}
+				}
 				if (present == ROAD_NONE) {
 					RoadTypes rts = GetRoadTypes(tile) & ComplementRoadTypes(RoadTypeToRoadTypes(rt));
 					if (rts == ROADTYPES_NONE) {