(svn r10871) [NewGRF_ports] -Codechange: do not pay for clearing water tiles when placing watery tile on them anyway. NewGRF_ports
authorrubidium
Sun, 12 Aug 2007 18:18:48 +0000
branchNewGRF_ports
changeset 6799 2adc1052a548
parent 6798 61d108b5f76c
child 6800 6c09e1e86fcb
(svn r10871) [NewGRF_ports] -Codechange: do not pay for clearing water tiles when placing watery tile on them anyway.
src/station_cmd.cpp
--- a/src/station_cmd.cpp	Sun Aug 12 17:44:31 2007 +0000
+++ b/src/station_cmd.cpp	Sun Aug 12 18:18:48 2007 +0000
@@ -750,9 +750,10 @@
 					}
 				}
 			} else if (check_clear) {
+				bool water_tile = IsClearWaterTile(tile_cur);
 				CommandCost ret = DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 				if (CmdFailed(ret)) return ret;
-				cost.AddCost(ret);
+				if (!water_tile) cost.AddCost(ret);
 			}
 		}
 	} END_TILE_LOOP(tile_cur, w, h, tile)
@@ -1795,14 +1796,25 @@
 
 	byte *layout_ptr;
 	byte layout;
+	byte *mask_ptr;
 
 	if (newfsmairport) {
 		layout_ptr = (byte*)alloca((w * h) + 2);
 		GetFSMportsLayout(layout_ptr, w, h, fsmportsspec, layout_set);
 		layout_ptr++; //skip orientation
 		layout_ptr++; //skip minipic ID
+
+		if (fsmportsspec->layout_mask != NULL) {
+			mask_ptr = (byte*)alloca((w * h) + 2);
+			memcpy(mask_ptr, fsmportsspec->layout_mask[layout_set], (w * h) + 2);  // width*length flagbytes, plus orientation byte
+			mask_ptr++; //skip orientation
+			mask_ptr++; //skip 0x00
+		} else {
+			mask_ptr = NULL;
+		}
 	} else {
 		layout_ptr = (byte*)_airport_sections[st->airport_type];
+		mask_ptr = NULL;
 	}
 
 	{
@@ -1814,8 +1826,13 @@
 				if (flags & DC_EXEC) {
 					DeleteAnimatedTile(tile_cur);
 					DoClearSquare(tile_cur);
+
+					/* It was a water tile */
+					if (mask_ptr != NULL && *mask_ptr & 0x80) MakeWater(tile_cur);
 				}
 			}
+			if (mask_ptr != NULL) mask_ptr++;
+
 		END_TILE_LOOP(tile_cur, w,h,tile)
 	}