99 * This as for example docks and shipdepots do not store |
99 * This as for example docks and shipdepots do not store |
100 * whether the tile used to be canal or 'normal' water. |
100 * whether the tile used to be canal or 'normal' water. |
101 * @param t the tile to change. |
101 * @param t the tile to change. |
102 * @param o the owner of the new tile. |
102 * @param o the owner of the new tile. |
103 */ |
103 */ |
104 void MakeWaterOrCanalDependingOnSurroundings(TileIndex t, Owner o) |
104 void SetWaterClassDependingOnSurroundings(TileIndex t) |
105 { |
105 { |
106 assert(GetTileSlope(t, NULL) == SLOPE_FLAT); |
106 assert(GetTileSlope(t, NULL) == SLOPE_FLAT); |
107 |
107 |
108 /* Mark tile dirty in all cases */ |
108 /* Mark tile dirty in all cases */ |
109 MarkTileDirtyByTile(t); |
109 MarkTileDirtyByTile(t); |
110 |
110 |
111 /* Non-sealevel -> canal */ |
|
112 if (TileHeight(t) != 0) { |
|
113 MakeCanal(t, o, Random()); |
|
114 return; |
|
115 } |
|
116 |
|
117 bool has_water = false; |
111 bool has_water = false; |
118 bool has_canal = false; |
112 bool has_canal = false; |
|
113 bool has_river = false; |
119 |
114 |
120 for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) { |
115 for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) { |
121 TileIndex neighbour = TileAddByDiagDir(t, dir); |
116 TileIndex neighbour = TileAddByDiagDir(t, dir); |
122 switch (GetTileType(neighbour)) { |
117 switch (GetTileType(neighbour)) { |
123 case MP_WATER: |
118 case MP_WATER: |
124 has_water |= IsSea(neighbour) || IsCoast(neighbour) || (IsShipDepot(neighbour) && GetShipDepotWaterOwner(neighbour) == OWNER_WATER); |
119 has_water |= IsSea(neighbour) || IsCoast(neighbour) || (IsShipDepot(neighbour) && GetShipDepotWaterOwner(neighbour) == OWNER_WATER); |
125 has_canal |= IsCanal(neighbour) || (IsShipDepot(neighbour) && GetShipDepotWaterOwner(neighbour) != OWNER_WATER); |
120 has_canal |= IsCanal(neighbour) || (IsShipDepot(neighbour) && GetShipDepotWaterOwner(neighbour) != OWNER_WATER); |
|
121 has_river |= IsRiver(neighbour); |
126 break; |
122 break; |
127 |
123 |
128 case MP_RAILWAY: |
124 case MP_RAILWAY: |
129 /* Shore or flooded halftile */ |
125 /* Shore or flooded halftile */ |
130 has_water |= (GetRailGroundType(neighbour) == RAIL_GROUND_WATER); |
126 has_water |= (GetRailGroundType(neighbour) == RAIL_GROUND_WATER); |
136 break; |
132 break; |
137 |
133 |
138 default: break; |
134 default: break; |
139 } |
135 } |
140 } |
136 } |
141 if (has_canal || !has_water) { |
137 |
142 MakeCanal(t, o, Random()); |
138 if (has_river && !has_canal) { |
|
139 SetWaterClass(t, WATER_CLASS_RIVER); |
|
140 } else if (has_canal || !has_water) { |
|
141 SetWaterClass(t, WATER_CLASS_CANAL); |
143 } else { |
142 } else { |
144 MakeWater(t); |
143 SetWaterClass(t, WATER_CLASS_SEA); |
145 } |
144 } |
146 } |
145 } |
147 |
146 |
148 |
147 |
149 /** Build a ship depot. |
148 /** Build a ship depot. |
160 |
159 |
161 Axis axis = Extract<Axis, 0>(p1); |
160 Axis axis = Extract<Axis, 0>(p1); |
162 |
161 |
163 tile2 = tile + (axis == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1)); |
162 tile2 = tile + (axis == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1)); |
164 |
163 |
165 if (!IsWaterTile(tile) || !IsWaterTile(tile2)) |
164 if (!IsWaterTile(tile) || !IsWaterTile(tile2)) { |
166 return_cmd_error(STR_3801_MUST_BE_BUILT_ON_WATER); |
165 return_cmd_error(STR_3801_MUST_BE_BUILT_ON_WATER); |
|
166 } |
167 |
167 |
168 if (IsBridgeAbove(tile) || IsBridgeAbove(tile2)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
168 if (IsBridgeAbove(tile) || IsBridgeAbove(tile2)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
169 |
169 |
|
170 if (GetTileSlope(tile, NULL) != SLOPE_FLAT || GetTileSlope(tile2, NULL) != SLOPE_FLAT) { |
|
171 /* Prevent depots on rapids */ |
|
172 return_cmd_error(STR_0239_SITE_UNSUITABLE); |
|
173 } |
|
174 |
|
175 WaterClass wc1 = GetWaterClass(tile); |
|
176 WaterClass wc2 = GetWaterClass(tile2); |
170 Owner o1 = GetTileOwner(tile); |
177 Owner o1 = GetTileOwner(tile); |
171 Owner o2 = GetTileOwner(tile2); |
178 Owner o2 = GetTileOwner(tile2); |
172 ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
179 ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
173 if (CmdFailed(ret)) return CMD_ERROR; |
180 if (CmdFailed(ret)) return CMD_ERROR; |
174 ret = DoCommand(tile2, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
181 ret = DoCommand(tile2, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
179 AutoPtrT<Depot> d_auto_delete = depot; |
186 AutoPtrT<Depot> d_auto_delete = depot; |
180 |
187 |
181 if (flags & DC_EXEC) { |
188 if (flags & DC_EXEC) { |
182 depot->town_index = ClosestTownFromTile(tile, (uint)-1)->index; |
189 depot->town_index = ClosestTownFromTile(tile, (uint)-1)->index; |
183 |
190 |
184 MakeShipDepot(tile, _current_player, DEPOT_NORTH, axis, o1); |
191 MakeShipDepot(tile, _current_player, DEPOT_NORTH, axis, wc1, o1); |
185 MakeShipDepot(tile2, _current_player, DEPOT_SOUTH, axis, o2); |
192 MakeShipDepot(tile2, _current_player, DEPOT_SOUTH, axis, wc2, o2); |
186 MarkTileDirtyByTile(tile); |
193 MarkTileDirtyByTile(tile); |
187 MarkTileDirtyByTile(tile2); |
194 MarkTileDirtyByTile(tile2); |
188 d_auto_delete.Detach(); |
195 d_auto_delete.Detach(); |
189 } |
196 } |
190 |
197 |
191 return CommandCost(EXPENSES_CONSTRUCTION, _price.build_ship_depot); |
198 return CommandCost(EXPENSES_CONSTRUCTION, _price.build_ship_depot); |
192 } |
199 } |
193 |
200 |
194 void MakeWaterOrCanalDependingOnOwner(TileIndex tile, Owner o) |
201 void MakeWaterKeepingClass(TileIndex tile, Owner o) |
195 { |
202 { |
196 if (o == OWNER_WATER) { |
203 assert(IsTileType(tile, MP_WATER) || (IsTileType(tile, MP_STATION) && (IsBuoy(tile) || IsDock(tile)))); |
197 MakeWater(tile); |
204 |
198 } else { |
205 switch (GetWaterClass(tile)) { |
199 MakeCanal(tile, o, Random()); |
206 case WATER_CLASS_SEA: MakeWater(tile); break; |
|
207 case WATER_CLASS_CANAL: MakeCanal(tile, o, Random()); break; |
|
208 case WATER_CLASS_RIVER: MakeRiver(tile, Random()); break; |
200 } |
209 } |
201 } |
210 } |
202 |
211 |
203 static CommandCost RemoveShipDepot(TileIndex tile, uint32 flags) |
212 static CommandCost RemoveShipDepot(TileIndex tile, uint32 flags) |
204 { |
213 { |
214 |
223 |
215 if (flags & DC_EXEC) { |
224 if (flags & DC_EXEC) { |
216 /* Kill the depot, which is registered at the northernmost tile. Use that one */ |
225 /* Kill the depot, which is registered at the northernmost tile. Use that one */ |
217 delete GetDepotByTile(tile2 < tile ? tile2 : tile); |
226 delete GetDepotByTile(tile2 < tile ? tile2 : tile); |
218 |
227 |
219 MakeWaterOrCanalDependingOnOwner(tile, GetShipDepotWaterOwner(tile)); |
228 MakeWaterKeepingClass(tile, GetShipDepotWaterOwner(tile)); |
220 MakeWaterOrCanalDependingOnOwner(tile2, GetShipDepotWaterOwner(tile2)); |
229 MakeWaterKeepingClass(tile2, GetShipDepotWaterOwner(tile2)); |
221 MarkTileDirtyByTile(tile); |
230 MarkTileDirtyByTile(tile); |
222 MarkTileDirtyByTile(tile2); |
231 MarkTileDirtyByTile(tile2); |
223 } |
232 } |
224 |
233 |
225 return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_ship_depot); |
234 return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_ship_depot); |
235 ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
244 ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
236 if (CmdFailed(ret)) return CMD_ERROR; |
245 if (CmdFailed(ret)) return CMD_ERROR; |
237 |
246 |
238 delta = TileOffsByDiagDir(dir); |
247 delta = TileOffsByDiagDir(dir); |
239 /* lower tile */ |
248 /* lower tile */ |
|
249 WaterClass wc_lower = IsWaterTile(tile - delta) ? GetWaterClass(tile - delta) : WATER_CLASS_CANAL; |
|
250 |
240 ret = DoCommand(tile - delta, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
251 ret = DoCommand(tile - delta, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
241 if (CmdFailed(ret)) return CMD_ERROR; |
252 if (CmdFailed(ret)) return CMD_ERROR; |
242 if (GetTileSlope(tile - delta, NULL) != SLOPE_FLAT) { |
253 if (GetTileSlope(tile - delta, NULL) != SLOPE_FLAT) { |
243 return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
254 return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
244 } |
255 } |
245 |
256 |
246 /* upper tile */ |
257 /* upper tile */ |
|
258 WaterClass wc_upper = IsWaterTile(tile + delta) ? GetWaterClass(tile + delta) : WATER_CLASS_CANAL; |
|
259 |
247 ret = DoCommand(tile + delta, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
260 ret = DoCommand(tile + delta, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
248 if (CmdFailed(ret)) return CMD_ERROR; |
261 if (CmdFailed(ret)) return CMD_ERROR; |
249 if (GetTileSlope(tile + delta, NULL) != SLOPE_FLAT) { |
262 if (GetTileSlope(tile + delta, NULL) != SLOPE_FLAT) { |
250 return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
263 return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
251 } |
264 } |
255 (MayHaveBridgeAbove(tile + delta) && IsBridgeAbove(tile + delta))) { |
268 (MayHaveBridgeAbove(tile + delta) && IsBridgeAbove(tile + delta))) { |
256 return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
269 return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
257 } |
270 } |
258 |
271 |
259 if (flags & DC_EXEC) { |
272 if (flags & DC_EXEC) { |
260 MakeLock(tile, _current_player, dir); |
273 MakeLock(tile, _current_player, dir, wc_lower, wc_upper); |
261 MarkTileDirtyByTile(tile); |
274 MarkTileDirtyByTile(tile); |
262 MarkTileDirtyByTile(tile - delta); |
275 MarkTileDirtyByTile(tile - delta); |
263 MarkTileDirtyByTile(tile + delta); |
276 MarkTileDirtyByTile(tile + delta); |
264 MarkCanalsAndRiversAroundDirty(tile - delta); |
277 MarkCanalsAndRiversAroundDirty(tile - delta); |
265 MarkCanalsAndRiversAroundDirty(tile + delta); |
278 MarkCanalsAndRiversAroundDirty(tile + delta); |
278 if (!EnsureNoVehicleOnGround(tile) || !EnsureNoVehicleOnGround(tile + delta) || !EnsureNoVehicleOnGround(tile - delta)) |
291 if (!EnsureNoVehicleOnGround(tile) || !EnsureNoVehicleOnGround(tile + delta) || !EnsureNoVehicleOnGround(tile - delta)) |
279 return CMD_ERROR; |
292 return CMD_ERROR; |
280 |
293 |
281 if (flags & DC_EXEC) { |
294 if (flags & DC_EXEC) { |
282 DoClearSquare(tile); |
295 DoClearSquare(tile); |
283 MakeWaterOrCanalDependingOnSurroundings(tile + delta, _current_player); |
296 MakeWaterKeepingClass(tile + delta, GetTileOwner(tile)); |
284 MakeWaterOrCanalDependingOnSurroundings(tile - delta, _current_player); |
297 MakeWaterKeepingClass(tile - delta, GetTileOwner(tile)); |
|
298 MarkTileDirtyByTile(tile - delta); |
|
299 MarkTileDirtyByTile(tile + delta); |
285 MarkCanalsAndRiversAroundDirty(tile - delta); |
300 MarkCanalsAndRiversAroundDirty(tile - delta); |
286 MarkCanalsAndRiversAroundDirty(tile + delta); |
301 MarkCanalsAndRiversAroundDirty(tile + delta); |
287 } |
302 } |
288 |
303 |
289 return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_water * 2); |
304 return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_water * 2); |
299 { |
314 { |
300 DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile, NULL)); |
315 DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile, NULL)); |
301 if (dir == INVALID_DIAGDIR) return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
316 if (dir == INVALID_DIAGDIR) return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
302 |
317 |
303 /* Disallow building of locks on river rapids */ |
318 /* Disallow building of locks on river rapids */ |
304 if (IsRiverTile(tile)) return_cmd_error(STR_0239_SITE_UNSUITABLE); |
319 if (IsWaterTile(tile)) return_cmd_error(STR_0239_SITE_UNSUITABLE); |
305 |
320 |
306 return DoBuildShiplift(tile, dir, flags); |
321 return DoBuildShiplift(tile, dir, flags); |
307 } |
322 } |
308 |
323 |
309 /** Build a piece of canal. |
324 /** Build a piece of canal. |
377 |
392 |
378 static CommandCost ClearTile_Water(TileIndex tile, byte flags) |
393 static CommandCost ClearTile_Water(TileIndex tile, byte flags) |
379 { |
394 { |
380 switch (GetWaterTileType(tile)) { |
395 switch (GetWaterTileType(tile)) { |
381 case WATER_TILE_CLEAR: |
396 case WATER_TILE_CLEAR: |
382 case WATER_TILE_RIVER: |
|
383 if (flags & DC_NO_WATER) return_cmd_error(STR_3807_CAN_T_BUILD_ON_WATER); |
397 if (flags & DC_NO_WATER) return_cmd_error(STR_3807_CAN_T_BUILD_ON_WATER); |
384 |
398 |
385 /* Make sure it's not an edge tile. */ |
399 /* Make sure it's not an edge tile. */ |
386 if (!IsInsideMM(TileX(tile), 1, MapMaxX() - 1) || |
400 if (!IsInsideMM(TileX(tile), 1, MapMaxX() - 1) || |
387 !IsInsideMM(TileY(tile), 1, MapMaxY() - 1)) { |
401 !IsInsideMM(TileY(tile), 1, MapMaxY() - 1)) { |
516 case 0: DrawGroundSprite(base + 7, PAL_NONE); break; |
530 case 0: DrawGroundSprite(base + 7, PAL_NONE); break; |
517 case 9: if (!IsWateredTile(TILE_ADDXY(tile, -1, -1), DIR_S)) DrawGroundSprite(base + 11, PAL_NONE); break; |
531 case 9: if (!IsWateredTile(TILE_ADDXY(tile, -1, -1), DIR_S)) DrawGroundSprite(base + 11, PAL_NONE); break; |
518 } |
532 } |
519 } |
533 } |
520 |
534 |
|
535 /** Draw a plain sea water tile with no edges */ |
|
536 void DrawSeaWater(TileIndex tile) |
|
537 { |
|
538 DrawGroundSprite(SPR_FLAT_WATER_TILE, PAL_NONE); |
|
539 } |
|
540 |
521 /** draw a canal styled water tile with dikes around */ |
541 /** draw a canal styled water tile with dikes around */ |
522 void DrawCanalWater(TileIndex tile) |
542 void DrawCanalWater(TileIndex tile, bool draw_base) |
523 { |
543 { |
|
544 if (draw_base) DrawGroundSprite(SPR_FLAT_WATER_TILE, PAL_NONE); |
|
545 |
524 /* Test for custom graphics, else use the default */ |
546 /* Test for custom graphics, else use the default */ |
525 SpriteID dikes_base = GetCanalSprite(CF_DIKES, tile); |
547 SpriteID dikes_base = GetCanalSprite(CF_DIKES, tile); |
526 if (dikes_base == 0) dikes_base = SPR_CANAL_DIKES_BASE; |
548 if (dikes_base == 0) dikes_base = SPR_CANAL_DIKES_BASE; |
527 |
549 |
528 DrawWaterEdges(dikes_base, tile); |
550 DrawWaterEdges(dikes_base, tile); |
564 wdts->unk, ti->z + wdts->delta_z, |
586 wdts->unk, ti->z + wdts->delta_z, |
565 IsTransparencySet(TO_BUILDINGS)); |
587 IsTransparencySet(TO_BUILDINGS)); |
566 } |
588 } |
567 } |
589 } |
568 |
590 |
569 static void DrawRiverWater(const TileInfo *ti) |
591 void DrawRiverWater(const TileInfo *ti, bool draw_base) |
570 { |
592 { |
571 SpriteID image = SPR_FLAT_WATER_TILE; |
593 SpriteID image = SPR_FLAT_WATER_TILE; |
572 SpriteID edges_base = GetCanalSprite(CF_RIVER_EDGE, ti->tile); |
594 SpriteID edges_base = GetCanalSprite(CF_RIVER_EDGE, ti->tile); |
573 |
595 |
574 if (ti->tileh != SLOPE_FLAT) { |
596 if (ti->tileh != SLOPE_FLAT) { |
590 case SLOPE_NW: image += 3; edges_base += 48; break; |
612 case SLOPE_NW: image += 3; edges_base += 48; break; |
591 } |
613 } |
592 } |
614 } |
593 } |
615 } |
594 |
616 |
595 DrawGroundSprite(image, PAL_NONE); |
617 if (draw_base) DrawGroundSprite(image, PAL_NONE); |
596 |
618 |
597 /* Draw river edges if available. */ |
619 /* Draw river edges if available. */ |
598 if (edges_base > 48) DrawWaterEdges(edges_base, ti->tile); |
620 if (edges_base > 48) DrawWaterEdges(edges_base, ti->tile); |
599 } |
621 } |
600 |
622 |
617 |
639 |
618 static void DrawTile_Water(TileInfo *ti) |
640 static void DrawTile_Water(TileInfo *ti) |
619 { |
641 { |
620 switch (GetWaterTileType(ti->tile)) { |
642 switch (GetWaterTileType(ti->tile)) { |
621 case WATER_TILE_CLEAR: |
643 case WATER_TILE_CLEAR: |
622 DrawGroundSprite(SPR_FLAT_WATER_TILE, PAL_NONE); |
644 switch (GetWaterClass(ti->tile)) { |
623 if (IsCanal(ti->tile)) DrawCanalWater(ti->tile); |
645 case WATER_CLASS_SEA: DrawSeaWater(ti->tile); break; |
|
646 case WATER_CLASS_CANAL: DrawCanalWater(ti->tile, true); break; |
|
647 case WATER_CLASS_RIVER: DrawRiverWater(ti, true); break; |
|
648 } |
624 DrawBridgeMiddle(ti); |
649 DrawBridgeMiddle(ti); |
625 break; |
650 break; |
626 |
651 |
627 case WATER_TILE_COAST: { |
652 case WATER_TILE_COAST: { |
628 DrawShoreTile(ti->tileh); |
653 DrawShoreTile(ti->tileh); |
635 } break; |
660 } break; |
636 |
661 |
637 case WATER_TILE_DEPOT: |
662 case WATER_TILE_DEPOT: |
638 DrawWaterStuff(ti, _shipdepot_display_seq[GetSection(ti->tile)], PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)), 0); |
663 DrawWaterStuff(ti, _shipdepot_display_seq[GetSection(ti->tile)], PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)), 0); |
639 break; |
664 break; |
640 |
|
641 case WATER_TILE_RIVER: |
|
642 DrawRiverWater(ti); |
|
643 DrawBridgeMiddle(ti); |
|
644 break; |
|
645 } |
665 } |
646 } |
666 } |
647 |
667 |
648 void DrawShipDepotSprite(int x, int y, int image) |
668 void DrawShipDepotSprite(int x, int y, int image) |
649 { |
669 { |
678 |
698 |
679 static void GetTileDesc_Water(TileIndex tile, TileDesc *td) |
699 static void GetTileDesc_Water(TileIndex tile, TileDesc *td) |
680 { |
700 { |
681 switch (GetWaterTileType(tile)) { |
701 switch (GetWaterTileType(tile)) { |
682 case WATER_TILE_CLEAR: |
702 case WATER_TILE_CLEAR: |
683 case WATER_TILE_RIVER: |
|
684 if (!IsCanal(tile)) { |
703 if (!IsCanal(tile)) { |
685 td->str = STR_3804_WATER; |
704 td->str = STR_3804_WATER; |
686 } else { |
705 } else { |
687 td->str = STR_LANDINFO_CANAL; |
706 td->str = STR_LANDINFO_CANAL; |
688 } |
707 } |
840 case MP_WATER: |
859 case MP_WATER: |
841 if (IsCoast(tile)) { |
860 if (IsCoast(tile)) { |
842 Slope tileh = GetTileSlope(tile, NULL); |
861 Slope tileh = GetTileSlope(tile, NULL); |
843 return (IsSlopeWithOneCornerRaised(tileh) ? FLOOD_ACTIVE : FLOOD_DRYUP); |
862 return (IsSlopeWithOneCornerRaised(tileh) ? FLOOD_ACTIVE : FLOOD_DRYUP); |
844 } else { |
863 } else { |
845 return ((IsSea(tile) || (IsShipDepot(tile) && (GetShipDepotWaterOwner(tile) == OWNER_WATER))) ? FLOOD_ACTIVE : FLOOD_NONE); |
864 return (GetWaterClass(tile) == WATER_CLASS_SEA) ? FLOOD_ACTIVE : FLOOD_NONE; |
846 } |
865 } |
847 |
866 |
848 case MP_RAILWAY: |
867 case MP_RAILWAY: |
849 if (GetRailGroundType(tile) == RAIL_GROUND_WATER) { |
868 if (GetRailGroundType(tile) == RAIL_GROUND_WATER) { |
850 return (IsSlopeWithOneCornerRaised(GetTileSlope(tile, NULL)) ? FLOOD_ACTIVE : FLOOD_DRYUP); |
869 return (IsSlopeWithOneCornerRaised(GetTileSlope(tile, NULL)) ? FLOOD_ACTIVE : FLOOD_DRYUP); |
853 |
872 |
854 case MP_TREES: |
873 case MP_TREES: |
855 return (GetTreeGround(tile) == TREE_GROUND_SHORE ? FLOOD_DRYUP : FLOOD_NONE); |
874 return (GetTreeGround(tile) == TREE_GROUND_SHORE ? FLOOD_DRYUP : FLOOD_NONE); |
856 |
875 |
857 case MP_STATION: |
876 case MP_STATION: |
858 if (IsSeaBuoyTile(tile)) return FLOOD_ACTIVE; |
877 if (IsBuoy(tile) && GetWaterClass(tile) == WATER_CLASS_SEA) return FLOOD_ACTIVE; |
859 if (IsOilRig(tile) || IsDock(tile)) return FLOOD_PASSIVE; |
878 if (IsOilRig(tile) || IsDock(tile)) return FLOOD_PASSIVE; |
860 return FLOOD_NONE; |
879 return FLOOD_NONE; |
861 |
880 |
862 case MP_INDUSTRY: |
881 case MP_INDUSTRY: |
863 return ((GetIndustrySpec(GetIndustryType(tile))->behaviour & INDUSTRYBEH_BUILT_ONWATER) != 0 ? FLOOD_PASSIVE : FLOOD_NONE); |
882 return ((GetIndustrySpec(GetIndustryType(tile))->behaviour & INDUSTRYBEH_BUILT_ONWATER) != 0 ? FLOOD_PASSIVE : FLOOD_NONE); |
1071 TrackBits ts; |
1090 TrackBits ts; |
1072 |
1091 |
1073 if (mode != TRANSPORT_WATER) return 0; |
1092 if (mode != TRANSPORT_WATER) return 0; |
1074 |
1093 |
1075 switch (GetWaterTileType(tile)) { |
1094 switch (GetWaterTileType(tile)) { |
1076 case WATER_TILE_CLEAR: ts = TRACK_BIT_ALL; break; |
1095 case WATER_TILE_CLEAR: ts = (GetTileSlope(tile, NULL) == SLOPE_FLAT) ? TRACK_BIT_ALL : TRACK_BIT_NONE; break; |
1077 case WATER_TILE_COAST: ts = (TrackBits)coast_tracks[GetTileSlope(tile, NULL) & 0xF]; break; |
1096 case WATER_TILE_COAST: ts = (TrackBits)coast_tracks[GetTileSlope(tile, NULL) & 0xF]; break; |
1078 case WATER_TILE_LOCK: ts = AxisToTrackBits(DiagDirToAxis(GetLockDirection(tile))); break; |
1097 case WATER_TILE_LOCK: ts = AxisToTrackBits(DiagDirToAxis(GetLockDirection(tile))); break; |
1079 case WATER_TILE_DEPOT: ts = AxisToTrackBits(GetShipDepotAxis(tile)); break; |
1098 case WATER_TILE_DEPOT: ts = AxisToTrackBits(GetShipDepotAxis(tile)); break; |
1080 case WATER_TILE_RIVER: ts = (GetTileSlope(tile, NULL) == SLOPE_FLAT) ? TRACK_BIT_ALL : TRACK_BIT_NONE; break; |
|
1081 default: return 0; |
1099 default: return 0; |
1082 } |
1100 } |
1083 if (TileX(tile) == 0) { |
1101 if (TileX(tile) == 0) { |
1084 /* NE border: remove tracks that connects NE tile edge */ |
1102 /* NE border: remove tracks that connects NE tile edge */ |
1085 ts &= ~(TRACK_BIT_X | TRACK_BIT_UPPER | TRACK_BIT_RIGHT); |
1103 ts &= ~(TRACK_BIT_X | TRACK_BIT_UPPER | TRACK_BIT_RIGHT); |