author | richk |
Tue, 17 Jun 2008 13:22:13 +0000 | |
branch | NewGRF_ports |
changeset 10994 | cd9968b6f96b |
parent 10991 | d8811e327d12 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10274
diff
changeset
|
3 |
/** @file water_cmd.cpp Handling of water tiles. */ |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1796
diff
changeset
|
6 |
#include "openttd.h" |
3189
1af302c5abd0
(svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
3183
diff
changeset
|
7 |
#include "bridge_map.h" |
6486
4f8af35b11eb
(svn r8908) -Codechange: declaration of DrawBridgeMiddle does not belong in a map accessors header.
rubidium
parents:
6460
diff
changeset
|
8 |
#include "bridge.h" |
6460 | 9 |
#include "cmd_helper.h" |
3338
2c60ed0dcce3
(svn r4120) Use the new station functions where appropriate
tron
parents:
3275
diff
changeset
|
10 |
#include "station_map.h" |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
11 |
#include "tile_cmd.h" |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
12 |
#include "landscape.h" |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
13 |
#include "viewport_func.h" |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
14 |
#include "command_func.h" |
0 | 15 |
#include "town.h" |
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6880
diff
changeset
|
16 |
#include "news_func.h" |
10242
52b4a9006029
(svn r12774) [NewGRF_ports] -Sync: with trunk r12742:12772.
richk
parents:
10184
diff
changeset
|
17 |
#include "depot_base.h" |
52b4a9006029
(svn r12774) [NewGRF_ports] -Sync: with trunk r12742:12772.
richk
parents:
10184
diff
changeset
|
18 |
#include "depot_func.h" |
1752
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1632
diff
changeset
|
19 |
#include "vehicle_gui.h" |
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
2657
diff
changeset
|
20 |
#include "train.h" |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
21 |
#include "roadveh.h" |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
22 |
#include "water.h" |
3111
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
3017
diff
changeset
|
23 |
#include "water_map.h" |
6868
7eb395287b3d
(svn r11037) [NewGRF_ports] -Sync: with trunk r10844:11035.
rubidium
parents:
6857
diff
changeset
|
24 |
#include "industry_map.h" |
5210
dc52acfad05c
(svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents:
4848
diff
changeset
|
25 |
#include "newgrf.h" |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
26 |
#include "newgrf_canal.h" |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
27 |
#include "transparency.h" |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
28 |
#include "strings_func.h" |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
29 |
#include "functions.h" |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
30 |
#include "window_func.h" |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
31 |
#include "vehicle_func.h" |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
32 |
#include "sound_func.h" |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
33 |
#include "variables.h" |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
34 |
#include "player_func.h" |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
35 |
#include "settings_type.h" |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
36 |
#include "clear_map.h" |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
37 |
#include "tree_map.h" |
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6880
diff
changeset
|
38 |
#include "station_base.h" |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6880
diff
changeset
|
39 |
#include "airport.h" |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6880
diff
changeset
|
40 |
#include "newgrf_cargo.h" |
10274
b3c58f3df92b
(svn r12806) [NewGRF_ports] -Sync: with trunk r12773:12805.
richk
parents:
10242
diff
changeset
|
41 |
#include "effectvehicle_func.h" |
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10274
diff
changeset
|
42 |
#include "oldpool_func.h" |
10994
cd9968b6f96b
(svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents:
10991
diff
changeset
|
43 |
#include "tunnelbridge_map.h" |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
44 |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
45 |
#include "table/sprites.h" |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
46 |
#include "table/strings.h" |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
47 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
48 |
/** |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
49 |
* Describes the behaviour of a tile during flooding. |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
50 |
*/ |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
51 |
enum FloodingBehaviour { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
52 |
FLOOD_NONE, ///< The tile does not flood neighboured tiles. |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
53 |
FLOOD_ACTIVE, ///< The tile floods neighboured tiles. |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
54 |
FLOOD_PASSIVE, ///< The tile does not actively flood neighboured tiles, but it prevents them from drying up. |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
55 |
FLOOD_DRYUP, ///< The tile drys up if it is not constantly flooded from neighboured tiles. |
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2186
diff
changeset
|
56 |
}; |
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2186
diff
changeset
|
57 |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
58 |
/** |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
59 |
* Describes from which directions a specific slope can be flooded (if the tile is floodable at all). |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
60 |
*/ |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
61 |
static const uint8 _flood_from_dirs[] = { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
62 |
(1 << DIR_NW) | (1 << DIR_SW) | (1 << DIR_SE) | (1 << DIR_NE), // SLOPE_FLAT |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
63 |
(1 << DIR_NE) | (1 << DIR_SE), // SLOPE_W |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
64 |
(1 << DIR_NW) | (1 << DIR_NE), // SLOPE_S |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
65 |
(1 << DIR_NE), // SLOPE_SW |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
66 |
(1 << DIR_NW) | (1 << DIR_SW), // SLOPE_E |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
67 |
0, // SLOPE_EW |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
68 |
(1 << DIR_NW), // SLOPE_SE |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
69 |
(1 << DIR_N ) | (1 << DIR_NW) | (1 << DIR_NE), // SLOPE_WSE, SLOPE_STEEP_S |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
70 |
(1 << DIR_SW) | (1 << DIR_SE), // SLOPE_N |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
71 |
(1 << DIR_SE), // SLOPE_NW |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
72 |
0, // SLOPE_NS |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
73 |
(1 << DIR_E ) | (1 << DIR_NE) | (1 << DIR_SE), // SLOPE_NWS, SLOPE_STEEP_W |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
74 |
(1 << DIR_SW), // SLOPE_NE |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
75 |
(1 << DIR_S ) | (1 << DIR_SW) | (1 << DIR_SE), // SLOPE_ENW, SLOPE_STEEP_N |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
76 |
(1 << DIR_W ) | (1 << DIR_SW) | (1 << DIR_NW), // SLOPE_SEN, SLOPE_STEEP_E |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
77 |
}; |
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2186
diff
changeset
|
78 |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
79 |
/** |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
80 |
* Marks tile dirty if it is a canal or river tile. |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
81 |
* Called to avoid glitches when flooding tiles next to canal tile. |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
82 |
* |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
83 |
* @param tile tile to check |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
84 |
*/ |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
85 |
static inline void MarkTileDirtyIfCanalOrRiver(TileIndex tile) |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
86 |
{ |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
87 |
if (IsTileType(tile, MP_WATER) && (IsCanal(tile) || IsRiver(tile))) MarkTileDirtyByTile(tile); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
88 |
} |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
89 |
|
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
90 |
/** |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
91 |
* Marks the tiles around a tile as dirty, if they are canals or rivers. |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
92 |
* |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
93 |
* @param tile The center of the tile where all other tiles are marked as dirty |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
94 |
* @ingroup dirty |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
95 |
*/ |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
96 |
static void MarkCanalsAndRiversAroundDirty(TileIndex tile) |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
97 |
{ |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
98 |
for (Direction dir = DIR_BEGIN; dir < DIR_END; dir++) { |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
99 |
MarkTileDirtyIfCanalOrRiver(tile + TileOffsByDir(dir)); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
100 |
} |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
101 |
} |
0 | 102 |
|
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
103 |
/** |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
104 |
* Makes a tile canal or water depending on the surroundings. |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
105 |
* |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
106 |
* Must only be used for converting old savegames. Use WaterClass now. |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
107 |
* |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
108 |
* This as for example docks and shipdepots do not store |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
109 |
* whether the tile used to be canal or 'normal' water. |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
110 |
* @param t the tile to change. |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
111 |
* @param o the owner of the new tile. |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
112 |
*/ |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
113 |
void SetWaterClassDependingOnSurroundings(TileIndex t) |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
114 |
{ |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
115 |
assert(GetTileSlope(t, NULL) == SLOPE_FLAT); |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
116 |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
117 |
/* Mark tile dirty in all cases */ |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
118 |
MarkTileDirtyByTile(t); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
119 |
|
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
120 |
if (TileX(t) == 0 || TileY(t) == 0 || TileX(t) == MapMaxX() - 1 || TileY(t) == MapMaxY() - 1) { |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
121 |
/* tiles at map borders are always WATER_CLASS_SEA */ |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
122 |
SetWaterClass(t, WATER_CLASS_SEA); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
123 |
return; |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
124 |
} |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
125 |
|
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
126 |
bool has_water = false; |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
127 |
bool has_canal = false; |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
128 |
bool has_river = false; |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
129 |
|
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
130 |
for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) { |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
131 |
TileIndex neighbour = TileAddByDiagDir(t, dir); |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
132 |
switch (GetTileType(neighbour)) { |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
133 |
case MP_WATER: |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
134 |
/* clear water and shipdepots have already a WaterClass associated */ |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
135 |
if (IsCoast(neighbour)) { |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
136 |
has_water = true; |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
137 |
} else if (!IsLock(neighbour)) { |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
138 |
switch (GetWaterClass(neighbour)) { |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
139 |
case WATER_CLASS_SEA: has_water = true; break; |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
140 |
case WATER_CLASS_CANAL: has_canal = true; break; |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
141 |
case WATER_CLASS_RIVER: has_river = true; break; |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
142 |
default: NOT_REACHED(); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
143 |
} |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
144 |
} |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
145 |
break; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
146 |
|
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
147 |
case MP_RAILWAY: |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
148 |
/* Shore or flooded halftile */ |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
149 |
has_water |= (GetRailGroundType(neighbour) == RAIL_GROUND_WATER); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
150 |
break; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
151 |
|
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
152 |
case MP_TREES: |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
153 |
/* trees on shore */ |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
154 |
has_water |= (GetTreeGround(neighbour) == TREE_GROUND_SHORE); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
155 |
break; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
156 |
|
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
157 |
default: break; |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
158 |
} |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
159 |
} |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
160 |
|
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
161 |
if (has_river && !has_canal) { |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
162 |
SetWaterClass(t, WATER_CLASS_RIVER); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
163 |
} else if (has_canal || !has_water) { |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
164 |
SetWaterClass(t, WATER_CLASS_CANAL); |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
165 |
} else { |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
166 |
SetWaterClass(t, WATER_CLASS_SEA); |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
167 |
} |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
168 |
} |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
169 |
|
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
170 |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1752
diff
changeset
|
171 |
/** Build a ship depot. |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3439
diff
changeset
|
172 |
* @param tile tile where ship depot is built |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
173 |
* @param flags type of operation |
6460 | 174 |
* @param p1 bit 0 depot orientation (Axis) |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1752
diff
changeset
|
175 |
* @param p2 unused |
0 | 176 |
*/ |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
177 |
CommandCost CmdBuildShipDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 178 |
{ |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3439
diff
changeset
|
179 |
TileIndex tile2; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
180 |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
181 |
CommandCost ret; |
0 | 182 |
|
6460 | 183 |
Axis axis = Extract<Axis, 0>(p1); |
184 |
||
185 |
tile2 = tile + (axis == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1)); |
|
0 | 186 |
|
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
187 |
if (!IsWaterTile(tile) || !IsWaterTile(tile2)) { |
0 | 188 |
return_cmd_error(STR_3801_MUST_BE_BUILT_ON_WATER); |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
189 |
} |
0 | 190 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5210
diff
changeset
|
191 |
if (IsBridgeAbove(tile) || IsBridgeAbove(tile2)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5210
diff
changeset
|
192 |
|
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
193 |
if (GetTileSlope(tile, NULL) != SLOPE_FLAT || GetTileSlope(tile2, NULL) != SLOPE_FLAT) { |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
194 |
/* Prevent depots on rapids */ |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
195 |
return_cmd_error(STR_0239_SITE_UNSUITABLE); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
196 |
} |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
197 |
|
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
198 |
WaterClass wc1 = GetWaterClass(tile); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
199 |
WaterClass wc2 = GetWaterClass(tile2); |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3439
diff
changeset
|
200 |
ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1752
diff
changeset
|
201 |
if (CmdFailed(ret)) return CMD_ERROR; |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3439
diff
changeset
|
202 |
ret = DoCommand(tile2, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1752
diff
changeset
|
203 |
if (CmdFailed(ret)) return CMD_ERROR; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
204 |
|
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10274
diff
changeset
|
205 |
if (!Depot::CanAllocateItem()) return CMD_ERROR; |
0 | 206 |
|
207 |
if (flags & DC_EXEC) { |
|
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10274
diff
changeset
|
208 |
Depot *depot = new Depot(tile); |
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1214
diff
changeset
|
209 |
depot->town_index = ClosestTownFromTile(tile, (uint)-1)->index; |
0 | 210 |
|
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
211 |
MakeShipDepot(tile, _current_player, DEPOT_NORTH, axis, wc1); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
212 |
MakeShipDepot(tile2, _current_player, DEPOT_SOUTH, axis, wc2); |
3372
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3338
diff
changeset
|
213 |
MarkTileDirtyByTile(tile); |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3338
diff
changeset
|
214 |
MarkTileDirtyByTile(tile2); |
0 | 215 |
} |
216 |
||
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
217 |
return CommandCost(EXPENSES_CONSTRUCTION, _price.build_ship_depot); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
218 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
219 |
|
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
220 |
void MakeWaterKeepingClass(TileIndex tile, Owner o) |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
221 |
{ |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
222 |
assert(IsTileType(tile, MP_WATER) || (IsTileType(tile, MP_STATION) && (IsBuoy(tile) || IsDock(tile)))); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
223 |
|
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
224 |
switch (GetWaterClass(tile)) { |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
225 |
case WATER_CLASS_SEA: MakeWater(tile); break; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
226 |
case WATER_CLASS_CANAL: MakeCanal(tile, o, Random()); break; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
227 |
case WATER_CLASS_RIVER: MakeRiver(tile, Random()); break; |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
228 |
} |
0 | 229 |
} |
230 |
||
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
231 |
static CommandCost RemoveShipDepot(TileIndex tile, uint32 flags) |
0 | 232 |
{ |
3373
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
233 |
if (!IsShipDepot(tile)) return CMD_ERROR; |
2951 | 234 |
if (!CheckTileOwnership(tile)) return CMD_ERROR; |
0 | 235 |
|
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
236 |
TileIndex tile2 = GetOtherShipDepotTile(tile); |
0 | 237 |
|
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
238 |
/* do not check for ship on tile when company goes bankrupt */ |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
239 |
if (!(flags & DC_BANKRUPT)) { |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
240 |
if (!EnsureNoVehicleOnGround(tile) || !EnsureNoVehicleOnGround(tile2)) return CMD_ERROR; |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
241 |
} |
0 | 242 |
|
243 |
if (flags & DC_EXEC) { |
|
3373
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
244 |
/* Kill the depot, which is registered at the northernmost tile. Use that one */ |
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6738
diff
changeset
|
245 |
delete GetDepotByTile(tile2 < tile ? tile2 : tile); |
0 | 246 |
|
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
247 |
MakeWaterKeepingClass(tile, GetTileOwner(tile)); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
248 |
MakeWaterKeepingClass(tile2, GetTileOwner(tile2)); |
3111
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
3017
diff
changeset
|
249 |
MarkTileDirtyByTile(tile); |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
3017
diff
changeset
|
250 |
MarkTileDirtyByTile(tile2); |
0 | 251 |
} |
252 |
||
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
253 |
return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_ship_depot); |
0 | 254 |
} |
255 |
||
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
256 |
/** build a shiplift */ |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
257 |
static CommandCost DoBuildShiplift(TileIndex tile, DiagDirection dir, uint32 flags) |
0 | 258 |
{ |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
259 |
CommandCost ret; |
0 | 260 |
int delta; |
261 |
||
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
262 |
/* middle tile */ |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3439
diff
changeset
|
263 |
ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
2737
f16e0a808897
(svn r3282) - Codechange: Replace tests against CMD_ERROR with CmdFailed()
peter1138
parents:
2676
diff
changeset
|
264 |
if (CmdFailed(ret)) return CMD_ERROR; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
265 |
|
4559
c853d2440065
(svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents:
4434
diff
changeset
|
266 |
delta = TileOffsByDiagDir(dir); |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
267 |
/* lower tile */ |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
268 |
WaterClass wc_lower = IsWaterTile(tile - delta) ? GetWaterClass(tile - delta) : WATER_CLASS_CANAL; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
269 |
|
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3439
diff
changeset
|
270 |
ret = DoCommand(tile - delta, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
2737
f16e0a808897
(svn r3282) - Codechange: Replace tests against CMD_ERROR with CmdFailed()
peter1138
parents:
2676
diff
changeset
|
271 |
if (CmdFailed(ret)) return CMD_ERROR; |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3491
diff
changeset
|
272 |
if (GetTileSlope(tile - delta, NULL) != SLOPE_FLAT) { |
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3491
diff
changeset
|
273 |
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3491
diff
changeset
|
274 |
} |
0 | 275 |
|
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
276 |
/* upper tile */ |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
277 |
WaterClass wc_upper = IsWaterTile(tile + delta) ? GetWaterClass(tile + delta) : WATER_CLASS_CANAL; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
278 |
|
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3439
diff
changeset
|
279 |
ret = DoCommand(tile + delta, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
2737
f16e0a808897
(svn r3282) - Codechange: Replace tests against CMD_ERROR with CmdFailed()
peter1138
parents:
2676
diff
changeset
|
280 |
if (CmdFailed(ret)) return CMD_ERROR; |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3491
diff
changeset
|
281 |
if (GetTileSlope(tile + delta, NULL) != SLOPE_FLAT) { |
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3491
diff
changeset
|
282 |
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3491
diff
changeset
|
283 |
} |
0 | 284 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5210
diff
changeset
|
285 |
if ((MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) || |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5210
diff
changeset
|
286 |
(MayHaveBridgeAbove(tile - delta) && IsBridgeAbove(tile - delta)) || |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5210
diff
changeset
|
287 |
(MayHaveBridgeAbove(tile + delta) && IsBridgeAbove(tile + delta))) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5210
diff
changeset
|
288 |
return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5210
diff
changeset
|
289 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5210
diff
changeset
|
290 |
|
0 | 291 |
if (flags & DC_EXEC) { |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
292 |
MakeLock(tile, _current_player, dir, wc_lower, wc_upper); |
3372
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3338
diff
changeset
|
293 |
MarkTileDirtyByTile(tile); |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3338
diff
changeset
|
294 |
MarkTileDirtyByTile(tile - delta); |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3338
diff
changeset
|
295 |
MarkTileDirtyByTile(tile + delta); |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
296 |
MarkCanalsAndRiversAroundDirty(tile - delta); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
297 |
MarkCanalsAndRiversAroundDirty(tile + delta); |
0 | 298 |
} |
299 |
||
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
300 |
return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_water * 22 >> 3); |
0 | 301 |
} |
302 |
||
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
303 |
static CommandCost RemoveShiplift(TileIndex tile, uint32 flags) |
0 | 304 |
{ |
4559
c853d2440065
(svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents:
4434
diff
changeset
|
305 |
TileIndexDiff delta = TileOffsByDiagDir(GetLockDirection(tile)); |
0 | 306 |
|
6725
23339968083f
(svn r10595) [NewGRF_ports] -Sync: with trunk r10559-10593
richk
parents:
6720
diff
changeset
|
307 |
if (!CheckTileOwnership(tile) && GetTileOwner(tile) != OWNER_NONE) return CMD_ERROR; |
3940
f3aa8e2969d4
(svn r5084) - Add owner attribute to canals and locks. This makes them more useful in multiplayer games, as before, anyone could delete any canal or lock tile. This doesn't affect whose ships can use whose canals or locks.
peter1138
parents:
3939
diff
changeset
|
308 |
|
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
309 |
/* make sure no vehicle is on the tile. */ |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
310 |
if (!EnsureNoVehicleOnGround(tile) || !EnsureNoVehicleOnGround(tile + delta) || !EnsureNoVehicleOnGround(tile - delta)) |
0 | 311 |
return CMD_ERROR; |
312 |
||
313 |
if (flags & DC_EXEC) { |
|
314 |
DoClearSquare(tile); |
|
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
315 |
MakeWaterKeepingClass(tile + delta, GetTileOwner(tile)); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
316 |
MakeWaterKeepingClass(tile - delta, GetTileOwner(tile)); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
317 |
MarkTileDirtyByTile(tile - delta); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
318 |
MarkTileDirtyByTile(tile + delta); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
319 |
MarkCanalsAndRiversAroundDirty(tile - delta); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
320 |
MarkCanalsAndRiversAroundDirty(tile + delta); |
0 | 321 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
322 |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
323 |
return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_water * 2); |
0 | 324 |
} |
325 |
||
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1784
diff
changeset
|
326 |
/** Builds a lock (ship-lift) |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3439
diff
changeset
|
327 |
* @param tile tile where to place the lock |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
328 |
* @param flags type of operation |
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1784
diff
changeset
|
329 |
* @param p1 unused |
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1784
diff
changeset
|
330 |
* @param p2 unused |
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1784
diff
changeset
|
331 |
*/ |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
332 |
CommandCost CmdBuildLock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 333 |
{ |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
334 |
DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile, NULL)); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
335 |
if (dir == INVALID_DIAGDIR) return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
889
7f8630bfea41
(svn r1375) -Fix: [1050990] Buying trains sometimes accounted for incorrectly. Was the result of the cost getting reset in a recursive call of docommand. That is fixed. In addition all cost-commands are typed explicitely. Please do not forget to do so or your costs will be credited to construction if you are unlucky.
darkvater
parents:
863
diff
changeset
|
336 |
|
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
337 |
/* Disallow building of locks on river rapids */ |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
338 |
if (IsWaterTile(tile)) return_cmd_error(STR_0239_SITE_UNSUITABLE); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
339 |
|
3157
40de8616c04c
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3111
diff
changeset
|
340 |
return DoBuildShiplift(tile, dir, flags); |
0 | 341 |
} |
342 |
||
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1784
diff
changeset
|
343 |
/** Build a piece of canal. |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3439
diff
changeset
|
344 |
* @param tile end tile of stretch-dragging |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
345 |
* @param flags type of operation |
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1784
diff
changeset
|
346 |
* @param p1 start tile of stretch-dragging |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
347 |
* @param p2 specifies canal (0), water (1) or river (2); last two can only be built in scenario editor |
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1784
diff
changeset
|
348 |
*/ |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
349 |
CommandCost CmdBuildCanal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 350 |
{ |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
351 |
CommandCost cost(EXPENSES_CONSTRUCTION); |
1632
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1605
diff
changeset
|
352 |
int size_x, size_y; |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3439
diff
changeset
|
353 |
int x; |
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3439
diff
changeset
|
354 |
int y; |
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1784
diff
changeset
|
355 |
int sx, sy; |
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1784
diff
changeset
|
356 |
|
2934
3b7eef9871f8
(svn r3490) -Fix: A bunch (10) of off-by-one errors when checking if a TileIndex points to a tile on the map
tron
parents:
2737
diff
changeset
|
357 |
if (p1 >= MapSize()) return CMD_ERROR; |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
358 |
|
6612
b511ba22a541
(svn r9105) -Fix [FS#629]: disable the ability to make flooding water with the canal build tool. In the scenario editor you can still make both canals and flooding water at height level 0.
rubidium
parents:
6585
diff
changeset
|
359 |
/* Outside of the editor you can only build canals, not oceans */ |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
360 |
if (p2 != 0 && _game_mode != GM_EDITOR) return CMD_ERROR; |
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1784
diff
changeset
|
361 |
|
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3439
diff
changeset
|
362 |
x = TileX(tile); |
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3439
diff
changeset
|
363 |
y = TileY(tile); |
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1784
diff
changeset
|
364 |
sx = TileX(p1); |
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1784
diff
changeset
|
365 |
sy = TileY(p1); |
1632
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1605
diff
changeset
|
366 |
|
6432 | 367 |
if (x < sx) Swap(x, sx); |
368 |
if (y < sy) Swap(y, sy); |
|
1632
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1605
diff
changeset
|
369 |
size_x = (x - sx) + 1; |
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1605
diff
changeset
|
370 |
size_y = (y - sy) + 1; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
371 |
|
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1784
diff
changeset
|
372 |
/* Outside the editor you can only drag canals, and not areas */ |
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1784
diff
changeset
|
373 |
if (_game_mode != GM_EDITOR && (sx != x && sy != y)) return CMD_ERROR; |
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1784
diff
changeset
|
374 |
|
1981 | 375 |
BEGIN_TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) { |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
376 |
CommandCost ret; |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5210
diff
changeset
|
377 |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
378 |
Slope slope = GetTileSlope(tile, NULL); |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
379 |
if (slope != SLOPE_FLAT && (p2 != 2 || !IsInclinedSlope(slope))) { |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3491
diff
changeset
|
380 |
return_cmd_error(STR_0007_FLAT_LAND_REQUIRED); |
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3491
diff
changeset
|
381 |
} |
0 | 382 |
|
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
383 |
/* can't make water of water! */ |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
384 |
if (IsTileType(tile, MP_WATER) && (!IsTileOwner(tile, OWNER_WATER) || p2 == 1)) continue; |
1632
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1605
diff
changeset
|
385 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5210
diff
changeset
|
386 |
ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5210
diff
changeset
|
387 |
if (CmdFailed(ret)) return ret; |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
388 |
cost.AddCost(ret); |
3183
cf71bd234ebd
(svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents:
3177
diff
changeset
|
389 |
|
3189
1af302c5abd0
(svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
3183
diff
changeset
|
390 |
if (flags & DC_EXEC) { |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
391 |
if (TileHeight(tile) == 0 && p2 == 1) { |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5210
diff
changeset
|
392 |
MakeWater(tile); |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
393 |
} else if (p2 == 2) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
394 |
MakeRiver(tile, Random()); |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5210
diff
changeset
|
395 |
} else { |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
396 |
MakeCanal(tile, _current_player, Random()); |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5210
diff
changeset
|
397 |
} |
3189
1af302c5abd0
(svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
3183
diff
changeset
|
398 |
MarkTileDirtyByTile(tile); |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
399 |
MarkCanalsAndRiversAroundDirty(tile); |
3189
1af302c5abd0
(svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
3183
diff
changeset
|
400 |
} |
3183
cf71bd234ebd
(svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents:
3177
diff
changeset
|
401 |
|
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
402 |
cost.AddCost(_price.clear_water); |
1632
c4ae19bfebf7
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents:
1605
diff
changeset
|
403 |
} END_TILE_LOOP(tile, size_x, size_y, 0); |
0 | 404 |
|
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
405 |
if (cost.GetCost() == 0) { |
3183
cf71bd234ebd
(svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents:
3177
diff
changeset
|
406 |
return_cmd_error(STR_1007_ALREADY_BUILT); |
cf71bd234ebd
(svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents:
3177
diff
changeset
|
407 |
} else { |
cf71bd234ebd
(svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents:
3177
diff
changeset
|
408 |
return cost; |
cf71bd234ebd
(svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents:
3177
diff
changeset
|
409 |
} |
0 | 410 |
} |
411 |
||
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
412 |
static CommandCost ClearTile_Water(TileIndex tile, byte flags) |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
413 |
{ |
3425
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3423
diff
changeset
|
414 |
switch (GetWaterTileType(tile)) { |
6507
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
6486
diff
changeset
|
415 |
case WATER_TILE_CLEAR: |
3425
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3423
diff
changeset
|
416 |
if (flags & DC_NO_WATER) return_cmd_error(STR_3807_CAN_T_BUILD_ON_WATER); |
0 | 417 |
|
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
418 |
/* Make sure it's not an edge tile. */ |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
419 |
if (!IsInsideMM(TileX(tile), 1, MapMaxX() - 1) || |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
420 |
!IsInsideMM(TileY(tile), 1, MapMaxY() - 1)) { |
3425
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3423
diff
changeset
|
421 |
return_cmd_error(STR_0002_TOO_CLOSE_TO_EDGE_OF_MAP); |
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3423
diff
changeset
|
422 |
} |
3017
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
423 |
|
6868
7eb395287b3d
(svn r11037) [NewGRF_ports] -Sync: with trunk r10844:11035.
rubidium
parents:
6857
diff
changeset
|
424 |
/* Make sure no vehicle is on the tile */ |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
425 |
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; |
6868
7eb395287b3d
(svn r11037) [NewGRF_ports] -Sync: with trunk r10844:11035.
rubidium
parents:
6857
diff
changeset
|
426 |
|
6725
23339968083f
(svn r10595) [NewGRF_ports] -Sync: with trunk r10559-10593
richk
parents:
6720
diff
changeset
|
427 |
if (GetTileOwner(tile) != OWNER_WATER && GetTileOwner(tile) != OWNER_NONE && !CheckTileOwnership(tile)) return CMD_ERROR; |
3940
f3aa8e2969d4
(svn r5084) - Add owner attribute to canals and locks. This makes them more useful in multiplayer games, as before, anyone could delete any canal or lock tile. This doesn't affect whose ships can use whose canals or locks.
peter1138
parents:
3939
diff
changeset
|
428 |
|
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
429 |
if (flags & DC_EXEC) { |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
430 |
DoClearSquare(tile); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
431 |
MarkCanalsAndRiversAroundDirty(tile); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
432 |
} |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
433 |
return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_water); |
0 | 434 |
|
6507
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
6486
diff
changeset
|
435 |
case WATER_TILE_COAST: { |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3491
diff
changeset
|
436 |
Slope slope = GetTileSlope(tile, NULL); |
3439 | 437 |
|
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
438 |
/* Make sure no vehicle is on the tile */ |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
439 |
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; |
3439 | 440 |
|
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
441 |
if (flags & DC_EXEC) { |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
442 |
DoClearSquare(tile); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
443 |
MarkCanalsAndRiversAroundDirty(tile); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
444 |
} |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
445 |
if (IsSlopeWithOneCornerRaised(slope)) { |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
446 |
return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_water); |
3439 | 447 |
} else { |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
448 |
return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_roughland); |
3425
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3423
diff
changeset
|
449 |
} |
3439 | 450 |
} |
451 |
||
6507
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
6486
diff
changeset
|
452 |
case WATER_TILE_LOCK: { |
3439 | 453 |
static const TileIndexDiffC _shiplift_tomiddle_offs[] = { |
454 |
{ 0, 0}, {0, 0}, { 0, 0}, {0, 0}, // middle |
|
455 |
{-1, 0}, {0, 1}, { 1, 0}, {0, -1}, // lower |
|
456 |
{ 1, 0}, {0, -1}, {-1, 0}, {0, 1}, // upper |
|
457 |
}; |
|
458 |
||
459 |
if (flags & DC_AUTO) return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED); |
|
460 |
if (_current_player == OWNER_WATER) return CMD_ERROR; |
|
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
461 |
/* move to the middle tile.. */ |
3439 | 462 |
return RemoveShiplift(tile + ToTileIndexDiff(_shiplift_tomiddle_offs[GetSection(tile)]), flags); |
463 |
} |
|
464 |
||
6507
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
6486
diff
changeset
|
465 |
case WATER_TILE_DEPOT: |
3425
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3423
diff
changeset
|
466 |
if (flags & DC_AUTO) return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED); |
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3423
diff
changeset
|
467 |
return RemoveShipDepot(tile, flags); |
3439 | 468 |
|
469 |
default: |
|
470 |
NOT_REACHED(); |
|
0 | 471 |
} |
472 |
} |
|
473 |
||
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
474 |
/** |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
475 |
* return true if a tile is a water tile wrt. a certain direction. |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
476 |
* |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
477 |
* @param tile The tile of interest. |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
478 |
* @param from The direction of interest. |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
479 |
* @return true iff the tile is water in the view of 'from'. |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
480 |
* |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
481 |
*/ |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
482 |
static bool IsWateredTile(TileIndex tile, Direction from) |
0 | 483 |
{ |
1214
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1209
diff
changeset
|
484 |
switch (GetTileType(tile)) { |
3977
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
485 |
case MP_WATER: |
10994
cd9968b6f96b
(svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents:
10991
diff
changeset
|
486 |
switch (GetWaterTileType(tile)) { |
cd9968b6f96b
(svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents:
10991
diff
changeset
|
487 |
default: NOT_REACHED(); |
cd9968b6f96b
(svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents:
10991
diff
changeset
|
488 |
case WATER_TILE_DEPOT: case WATER_TILE_CLEAR: return true; |
cd9968b6f96b
(svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents:
10991
diff
changeset
|
489 |
case WATER_TILE_LOCK: return DiagDirToAxis(GetLockDirection(tile)) == DiagDirToAxis(DirToDiagDir(from)); |
cd9968b6f96b
(svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents:
10991
diff
changeset
|
490 |
|
cd9968b6f96b
(svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents:
10991
diff
changeset
|
491 |
case WATER_TILE_COAST: |
cd9968b6f96b
(svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents:
10991
diff
changeset
|
492 |
switch (GetTileSlope(tile, NULL)) { |
cd9968b6f96b
(svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents:
10991
diff
changeset
|
493 |
case SLOPE_W: return (from == DIR_SE) || (from == DIR_E) || (from == DIR_NE); |
cd9968b6f96b
(svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents:
10991
diff
changeset
|
494 |
case SLOPE_S: return (from == DIR_NE) || (from == DIR_N) || (from == DIR_NW); |
cd9968b6f96b
(svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents:
10991
diff
changeset
|
495 |
case SLOPE_E: return (from == DIR_NW) || (from == DIR_W) || (from == DIR_SW); |
cd9968b6f96b
(svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents:
10991
diff
changeset
|
496 |
case SLOPE_N: return (from == DIR_SW) || (from == DIR_S) || (from == DIR_SE); |
cd9968b6f96b
(svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents:
10991
diff
changeset
|
497 |
default: return false; |
cd9968b6f96b
(svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents:
10991
diff
changeset
|
498 |
} |
4087
5ae6c880d66c
(svn r5403) - Feature: Allow building canals at sea-level, using ctrl to toggle canal or plain water tile. This allows building of non-raisable sea-level water ways (useful in multiplayer) and dikes for low-level areas.
peter1138
parents:
4077
diff
changeset
|
499 |
} |
3977
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
500 |
|
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
501 |
case MP_RAILWAY: |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
502 |
if (GetRailGroundType(tile) == RAIL_GROUND_WATER) { |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
503 |
assert(IsPlainRailTile(tile)); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
504 |
switch (GetTileSlope(tile, NULL)) { |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
505 |
case SLOPE_W: return (from == DIR_SE) || (from == DIR_E) || (from == DIR_NE); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
506 |
case SLOPE_S: return (from == DIR_NE) || (from == DIR_N) || (from == DIR_NW); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
507 |
case SLOPE_E: return (from == DIR_NW) || (from == DIR_W) || (from == DIR_SW); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
508 |
case SLOPE_N: return (from == DIR_SW) || (from == DIR_S) || (from == DIR_SE); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
509 |
default: return false; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
510 |
} |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
511 |
} |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
512 |
return false; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
513 |
|
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
514 |
case MP_STATION: return IsCustomFSMportsSpecIndex(tile) || IsOilRig(tile) || (IsDock(tile) && GetTileSlope(tile, NULL) == SLOPE_FLAT) || IsBuoy(tile); |
6868
7eb395287b3d
(svn r11037) [NewGRF_ports] -Sync: with trunk r10844:11035.
rubidium
parents:
6857
diff
changeset
|
515 |
case MP_INDUSTRY: return (GetIndustrySpec(GetIndustryType(tile))->behaviour & INDUSTRYBEH_BUILT_ONWATER) != 0; |
10994
cd9968b6f96b
(svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents:
10991
diff
changeset
|
516 |
case MP_TUNNELBRIDGE: return GetTunnelBridgeTransportType(tile) == TRANSPORT_WATER && ReverseDiagDir(GetTunnelBridgeDirection(tile)) == DirToDiagDir(from); |
6868
7eb395287b3d
(svn r11037) [NewGRF_ports] -Sync: with trunk r10844:11035.
rubidium
parents:
6857
diff
changeset
|
517 |
default: return false; |
1048 | 518 |
} |
0 | 519 |
} |
520 |
||
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
521 |
static void DrawWaterEdges(SpriteID base, TileIndex tile) |
0 | 522 |
{ |
523 |
uint wa; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
524 |
|
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
525 |
/* determine the edges around with water. */ |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
526 |
wa = IsWateredTile(TILE_ADDXY(tile, -1, 0), DIR_SW) << 0; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
527 |
wa += IsWateredTile(TILE_ADDXY(tile, 0, 1), DIR_NW) << 1; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
528 |
wa += IsWateredTile(TILE_ADDXY(tile, 1, 0), DIR_NE) << 2; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
529 |
wa += IsWateredTile(TILE_ADDXY(tile, 0, -1), DIR_SE) << 3; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
530 |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
531 |
if (!(wa & 1)) DrawGroundSprite(base, PAL_NONE); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
532 |
if (!(wa & 2)) DrawGroundSprite(base + 1, PAL_NONE); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
533 |
if (!(wa & 4)) DrawGroundSprite(base + 2, PAL_NONE); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
534 |
if (!(wa & 8)) DrawGroundSprite(base + 3, PAL_NONE); |
0 | 535 |
|
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
536 |
/* right corner */ |
2989 | 537 |
switch (wa & 0x03) { |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
538 |
case 0: DrawGroundSprite(base + 4, PAL_NONE); break; |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
539 |
case 3: if (!IsWateredTile(TILE_ADDXY(tile, -1, 1), DIR_W)) DrawGroundSprite(base + 8, PAL_NONE); break; |
2989 | 540 |
} |
0 | 541 |
|
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
542 |
/* bottom corner */ |
2989 | 543 |
switch (wa & 0x06) { |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
544 |
case 0: DrawGroundSprite(base + 5, PAL_NONE); break; |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
545 |
case 6: if (!IsWateredTile(TILE_ADDXY(tile, 1, 1), DIR_N)) DrawGroundSprite(base + 9, PAL_NONE); break; |
2989 | 546 |
} |
0 | 547 |
|
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
548 |
/* left corner */ |
2989 | 549 |
switch (wa & 0x0C) { |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
550 |
case 0: DrawGroundSprite(base + 6, PAL_NONE); break; |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
551 |
case 12: if (!IsWateredTile(TILE_ADDXY(tile, 1, -1), DIR_E)) DrawGroundSprite(base + 10, PAL_NONE); break; |
2989 | 552 |
} |
0 | 553 |
|
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
554 |
/* upper corner */ |
2989 | 555 |
switch (wa & 0x09) { |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
556 |
case 0: DrawGroundSprite(base + 7, PAL_NONE); break; |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
557 |
case 9: if (!IsWateredTile(TILE_ADDXY(tile, -1, -1), DIR_S)) DrawGroundSprite(base + 11, PAL_NONE); break; |
2989 | 558 |
} |
0 | 559 |
} |
560 |
||
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
561 |
/** Draw a plain sea water tile with no edges */ |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
562 |
static void DrawSeaWater(TileIndex tile) |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
563 |
{ |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
564 |
DrawGroundSprite(SPR_FLAT_WATER_TILE, PAL_NONE); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
565 |
} |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
566 |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
567 |
/** draw a canal styled water tile with dikes around */ |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
568 |
static void DrawCanalWater(TileIndex tile) |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
569 |
{ |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
570 |
DrawGroundSprite(SPR_FLAT_WATER_TILE, PAL_NONE); |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
571 |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
572 |
/* Test for custom graphics, else use the default */ |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
573 |
SpriteID dikes_base = GetCanalSprite(CF_DIKES, tile); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
574 |
if (dikes_base == 0) dikes_base = SPR_CANAL_DIKES_BASE; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
575 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
576 |
DrawWaterEdges(dikes_base, tile); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
577 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
578 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6507
diff
changeset
|
579 |
struct LocksDrawTileStruct { |
0 | 580 |
int8 delta_x, delta_y, delta_z; |
581 |
byte width, height, depth; |
|
582 |
SpriteID image; |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6507
diff
changeset
|
583 |
}; |
0 | 584 |
|
585 |
#include "table/water_land.h" |
|
586 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2261
diff
changeset
|
587 |
static void DrawWaterStuff(const TileInfo *ti, const WaterDrawTileStruct *wdts, |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
588 |
SpriteID palette, uint base, bool draw_ground |
1399
4503bd2bfb82
(svn r1903) Replace some casts and macro magic with proper typing, similar to r1902
tron
parents:
1363
diff
changeset
|
589 |
) |
0 | 590 |
{ |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
591 |
SpriteID image; |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
592 |
SpriteID water_base = GetCanalSprite(CF_WATERSLOPE, ti->tile); |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
593 |
SpriteID locks_base = GetCanalSprite(CF_LOCKS, ti->tile); |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
594 |
|
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
595 |
/* If no custom graphics, use defaults */ |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
596 |
if (water_base == 0) water_base = SPR_CANALS_BASE; |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
597 |
if (locks_base == 0) { |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
598 |
locks_base = SPR_SHIPLIFT_BASE; |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
599 |
} else { |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
600 |
/* If using custom graphics, ignore the variation on height */ |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
601 |
base = 0; |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
602 |
} |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
603 |
|
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
604 |
image = wdts++->image; |
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
605 |
if (image < 4) image += water_base; |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
606 |
if (draw_ground) DrawGroundSprite(image, PAL_NONE); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
607 |
|
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6880
diff
changeset
|
608 |
/* End now if buildings are invisible */ |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6880
diff
changeset
|
609 |
if (IsInvisibilitySet(TO_BUILDINGS)) return; |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6880
diff
changeset
|
610 |
|
1399
4503bd2bfb82
(svn r1903) Replace some casts and macro magic with proper typing, similar to r1902
tron
parents:
1363
diff
changeset
|
611 |
for (; wdts->delta_x != 0x80; wdts++) { |
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6738
diff
changeset
|
612 |
AddSortableSpriteToDraw(wdts->image + base + ((wdts->image < 24) ? locks_base : 0), palette, |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
613 |
ti->x + wdts->delta_x, ti->y + wdts->delta_y, |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
614 |
wdts->width, wdts->height, |
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6738
diff
changeset
|
615 |
wdts->unk, ti->z + wdts->delta_z, |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
616 |
IsTransparencySet(TO_BUILDINGS)); |
0 | 617 |
} |
618 |
} |
|
619 |
||
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
620 |
static void DrawRiverWater(const TileInfo *ti) |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
621 |
{ |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
622 |
SpriteID image = SPR_FLAT_WATER_TILE; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
623 |
SpriteID edges_base = GetCanalSprite(CF_RIVER_EDGE, ti->tile); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
624 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
625 |
if (ti->tileh != SLOPE_FLAT) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
626 |
image = GetCanalSprite(CF_RIVER_SLOPE, ti->tile); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
627 |
if (image == 0) { |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
628 |
switch (ti->tileh) { |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
629 |
case SLOPE_NW: image = SPR_WATER_SLOPE_Y_DOWN; break; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
630 |
case SLOPE_SW: image = SPR_WATER_SLOPE_X_UP; break; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
631 |
case SLOPE_SE: image = SPR_WATER_SLOPE_Y_UP; break; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
632 |
case SLOPE_NE: image = SPR_WATER_SLOPE_X_DOWN; break; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
633 |
default: image = SPR_FLAT_WATER_TILE; break; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
634 |
} |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
635 |
} else { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
636 |
switch (ti->tileh) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
637 |
default: NOT_REACHED(); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
638 |
case SLOPE_SE: edges_base += 12; break; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
639 |
case SLOPE_NE: image += 1; edges_base += 24; break; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
640 |
case SLOPE_SW: image += 2; edges_base += 36; break; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
641 |
case SLOPE_NW: image += 3; edges_base += 48; break; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
642 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
643 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
644 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
645 |
|
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
646 |
DrawGroundSprite(image, PAL_NONE); |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
647 |
|
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
648 |
/* Draw river edges if available. */ |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
649 |
if (edges_base > 48) DrawWaterEdges(edges_base, ti->tile); |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
650 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
651 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
652 |
void DrawShoreTile(Slope tileh) |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
653 |
{ |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
654 |
/* Converts the enum Slope into an offset based on SPR_SHORE_BASE. |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
655 |
* This allows to calculate the proper sprite to display for this Slope */ |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
656 |
static const byte tileh_to_shoresprite[32] = { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
657 |
0, 1, 2, 3, 4, 16, 6, 7, 8, 9, 17, 11, 12, 13, 14, 0, |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
658 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 10, 15, 0, |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
659 |
}; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
660 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
661 |
assert(!IsHalftileSlope(tileh)); // Halftile slopes need to get handled earlier. |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
662 |
assert(tileh != SLOPE_FLAT); // Shore is never flat |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
663 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
664 |
assert((tileh != SLOPE_EW) && (tileh != SLOPE_NS)); // No suitable sprites for current flooding behaviour |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
665 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
666 |
DrawGroundSprite(SPR_SHORE_BASE + tileh_to_shoresprite[tileh], PAL_NONE); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
667 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
668 |
|
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
669 |
void DrawWaterClassGround(const TileInfo *ti) { |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
670 |
switch (GetWaterClass(ti->tile)) { |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
671 |
case WATER_CLASS_SEA: DrawSeaWater(ti->tile); break; |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
672 |
case WATER_CLASS_CANAL: DrawCanalWater(ti->tile); break; |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
673 |
case WATER_CLASS_RIVER: DrawRiverWater(ti); break; |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
674 |
} |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
675 |
} |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
676 |
|
0 | 677 |
static void DrawTile_Water(TileInfo *ti) |
678 |
{ |
|
3402
0b72e324d300
(svn r4212) -Codechange: Add and make use of an accessor that retrieves the type of a water tile. Add an enum describing the different water tiles
celestar
parents:
3373
diff
changeset
|
679 |
switch (GetWaterTileType(ti->tile)) { |
6507
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
6486
diff
changeset
|
680 |
case WATER_TILE_CLEAR: |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
681 |
DrawWaterClassGround(ti); |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5210
diff
changeset
|
682 |
DrawBridgeMiddle(ti); |
3402
0b72e324d300
(svn r4212) -Codechange: Add and make use of an accessor that retrieves the type of a water tile. Add an enum describing the different water tiles
celestar
parents:
3373
diff
changeset
|
683 |
break; |
0 | 684 |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
685 |
case WATER_TILE_COAST: { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
686 |
DrawShoreTile(ti->tileh); |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5210
diff
changeset
|
687 |
DrawBridgeMiddle(ti); |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
688 |
} break; |
0 | 689 |
|
6507
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
6486
diff
changeset
|
690 |
case WATER_TILE_LOCK: { |
3425
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3423
diff
changeset
|
691 |
const WaterDrawTileStruct *t = _shiplift_display_seq[GetSection(ti->tile)]; |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
692 |
DrawWaterStuff(ti, t, 0, ti->z > t[3].delta_y ? 24 : 0, true); |
3402
0b72e324d300
(svn r4212) -Codechange: Add and make use of an accessor that retrieves the type of a water tile. Add an enum describing the different water tiles
celestar
parents:
3373
diff
changeset
|
693 |
} break; |
0b72e324d300
(svn r4212) -Codechange: Add and make use of an accessor that retrieves the type of a water tile. Add an enum describing the different water tiles
celestar
parents:
3373
diff
changeset
|
694 |
|
6507
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
6486
diff
changeset
|
695 |
case WATER_TILE_DEPOT: |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
696 |
DrawWaterClassGround(ti); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
697 |
DrawWaterStuff(ti, _shipdepot_display_seq[GetSection(ti->tile)], PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)), 0, false); |
3402
0b72e324d300
(svn r4212) -Codechange: Add and make use of an accessor that retrieves the type of a water tile. Add an enum describing the different water tiles
celestar
parents:
3373
diff
changeset
|
698 |
break; |
0 | 699 |
} |
700 |
} |
|
701 |
||
702 |
void DrawShipDepotSprite(int x, int y, int image) |
|
703 |
{ |
|
1399
4503bd2bfb82
(svn r1903) Replace some casts and macro magic with proper typing, similar to r1902
tron
parents:
1363
diff
changeset
|
704 |
const WaterDrawTileStruct *wdts = _shipdepot_display_seq[image]; |
0 | 705 |
|
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
706 |
DrawSprite(wdts++->image, PAL_NONE, x, y); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
707 |
|
1399
4503bd2bfb82
(svn r1903) Replace some casts and macro magic with proper typing, similar to r1902
tron
parents:
1363
diff
changeset
|
708 |
for (; wdts->delta_x != 0x80; wdts++) { |
0 | 709 |
Point pt = RemapCoords(wdts->delta_x, wdts->delta_y, wdts->delta_z); |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
710 |
DrawSprite(wdts->image, PLAYER_SPRITE_COLOR(_local_player), x + pt.x, y + pt.y); |
0 | 711 |
} |
712 |
} |
|
713 |
||
714 |
||
4231
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4171
diff
changeset
|
715 |
static uint GetSlopeZ_Water(TileIndex tile, uint x, uint y) |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
716 |
{ |
4231
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4171
diff
changeset
|
717 |
uint z; |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
718 |
Slope tileh = GetTileSlope(tile, &z); |
4231
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4171
diff
changeset
|
719 |
|
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4171
diff
changeset
|
720 |
return z + GetPartialZ(x & 0xF, y & 0xF, tileh); |
0 | 721 |
} |
722 |
||
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6738
diff
changeset
|
723 |
static Foundation GetFoundation_Water(TileIndex tile, Slope tileh) |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
724 |
{ |
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6738
diff
changeset
|
725 |
return FOUNDATION_NONE; |
39 | 726 |
} |
727 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
728 |
static void GetAcceptedCargo_Water(TileIndex tile, AcceptedCargo ac) |
0 | 729 |
{ |
730 |
/* not used */ |
|
731 |
} |
|
732 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
733 |
static void GetTileDesc_Water(TileIndex tile, TileDesc *td) |
0 | 734 |
{ |
3402
0b72e324d300
(svn r4212) -Codechange: Add and make use of an accessor that retrieves the type of a water tile. Add an enum describing the different water tiles
celestar
parents:
3373
diff
changeset
|
735 |
switch (GetWaterTileType(tile)) { |
6507
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
6486
diff
changeset
|
736 |
case WATER_TILE_CLEAR: |
10994
cd9968b6f96b
(svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents:
10991
diff
changeset
|
737 |
switch (GetWaterClass(tile)) { |
cd9968b6f96b
(svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents:
10991
diff
changeset
|
738 |
case WATER_CLASS_SEA: td->str = STR_3804_WATER; break; |
cd9968b6f96b
(svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents:
10991
diff
changeset
|
739 |
case WATER_CLASS_CANAL: td->str = STR_LANDINFO_CANAL; break; |
cd9968b6f96b
(svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents:
10991
diff
changeset
|
740 |
case WATER_CLASS_RIVER: td->str = STR_LANDINFO_RIVER; break; |
cd9968b6f96b
(svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents:
10991
diff
changeset
|
741 |
default: assert(0); break; |
3402
0b72e324d300
(svn r4212) -Codechange: Add and make use of an accessor that retrieves the type of a water tile. Add an enum describing the different water tiles
celestar
parents:
3373
diff
changeset
|
742 |
} |
0b72e324d300
(svn r4212) -Codechange: Add and make use of an accessor that retrieves the type of a water tile. Add an enum describing the different water tiles
celestar
parents:
3373
diff
changeset
|
743 |
break; |
6507
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
6486
diff
changeset
|
744 |
case WATER_TILE_COAST: td->str = STR_3805_COAST_OR_RIVERBANK; break; |
10994
cd9968b6f96b
(svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents:
10991
diff
changeset
|
745 |
case WATER_TILE_LOCK : td->str = STR_LANDINFO_LOCK; break; |
cd9968b6f96b
(svn r13548) [NewGRF_ports] -Sync: with trunk r13412:13544.
richk
parents:
10991
diff
changeset
|
746 |
case WATER_TILE_DEPOT: td->str = STR_3806_SHIP_DEPOT; break; |
3402
0b72e324d300
(svn r4212) -Codechange: Add and make use of an accessor that retrieves the type of a water tile. Add an enum describing the different water tiles
celestar
parents:
3373
diff
changeset
|
747 |
default: assert(0); break; |
2951 | 748 |
} |
0 | 749 |
|
10731
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
750 |
td->owner[0] = GetTileOwner(tile); |
0 | 751 |
} |
752 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
753 |
static void AnimateTile_Water(TileIndex tile) |
0 | 754 |
{ |
755 |
/* not used */ |
|
756 |
} |
|
757 |
||
758 |
||
6191
12d69f54e920
(svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents:
6156
diff
changeset
|
759 |
/** |
12d69f54e920
(svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents:
6156
diff
changeset
|
760 |
* Finds a vehicle to flood. |
12d69f54e920
(svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents:
6156
diff
changeset
|
761 |
* It does not find vehicles that are already crashed on bridges, i.e. flooded. |
12d69f54e920
(svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents:
6156
diff
changeset
|
762 |
* @param tile the tile where to find a vehicle to flood |
12d69f54e920
(svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents:
6156
diff
changeset
|
763 |
* @return a vehicle too flood or NULL when there is no vehicle too flood. |
12d69f54e920
(svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents:
6156
diff
changeset
|
764 |
*/ |
12d69f54e920
(svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents:
6156
diff
changeset
|
765 |
static Vehicle *FindFloodableVehicleOnTile(TileIndex tile) |
12d69f54e920
(svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents:
6156
diff
changeset
|
766 |
{ |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
767 |
if (IsTileType(tile, MP_STATION) && IsAirport(tile)) { |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
768 |
const Station *st = GetStationByTile(tile); |
6738
72d1a2997952
(svn r10683) [NewGRF_ports] -Revert: Too eager to un-const... global search/replace removed too many. Restores necessary ones... for the moment ;)
richk
parents:
6734
diff
changeset
|
769 |
const AirportFTAClass *airport = st->Airport(); |
6857
5012c47e576b
(svn r10960) [NewGRF_ports] -Change: Remove delta_z from the FSMport class. Will need to replace code at places marked with TODO.
richk
parents:
6770
diff
changeset
|
770 |
|
5012c47e576b
(svn r10960) [NewGRF_ports] -Change: Remove delta_z from the FSMport class. Will need to replace code at places marked with TODO.
richk
parents:
6770
diff
changeset
|
771 |
//TODO: account for irregular shaped airports, and orientation |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
772 |
for (uint x = 0; x < airport->size_x; x++) { |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
773 |
for (uint y = 0; y < airport->size_y; y++) { |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
774 |
tile = TILE_ADDXY(st->airport_tile, x, y); |
6857
5012c47e576b
(svn r10960) [NewGRF_ports] -Change: Remove delta_z from the FSMport class. Will need to replace code at places marked with TODO.
richk
parents:
6770
diff
changeset
|
775 |
//TODO: airport->delta_z no longer used. need to get actual height of individual tile in layout |
5012c47e576b
(svn r10960) [NewGRF_ports] -Change: Remove delta_z from the FSMport class. Will need to replace code at places marked with TODO.
richk
parents:
6770
diff
changeset
|
776 |
//Vehicle *v = FindVehicleOnTileZ(tile, 1 + airport->delta_z); |
5012c47e576b
(svn r10960) [NewGRF_ports] -Change: Remove delta_z from the FSMport class. Will need to replace code at places marked with TODO.
richk
parents:
6770
diff
changeset
|
777 |
//if (v != NULL && (v->vehstatus & VS_CRASHED) == 0) return v; |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
778 |
} |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
779 |
} |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
780 |
|
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
781 |
/* No vehicle could be flooded on this airport anymore */ |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
782 |
return NULL; |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
783 |
} |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
784 |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
785 |
/* if non-uniform stations are disabled, flood some train in this train station (if there is any) */ |
10991
d8811e327d12
(svn r13545) [NewGRF_ports] -Sync: with trunk r13281:13411.
richk
parents:
10731
diff
changeset
|
786 |
if (!_settings_game.station.nonuniform_stations && IsTileType(tile, MP_STATION) && GetStationType(tile) == STATION_RAIL) { |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
787 |
const Station *st = GetStationByTile(tile); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
788 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
789 |
BEGIN_TILE_LOOP(t, st->trainst_w, st->trainst_h, st->train_tile) |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
790 |
if (st->TileBelongsToRailStation(t)) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
791 |
Vehicle *v = FindVehicleOnTileZ(t, 0); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
792 |
if (v != NULL && (v->vehstatus & VS_CRASHED) == 0) return v; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
793 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
794 |
END_TILE_LOOP(t, st->trainst_w, st->trainst_h, st->train_tile) |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
795 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
796 |
return NULL; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
797 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
798 |
|
6191
12d69f54e920
(svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents:
6156
diff
changeset
|
799 |
if (!IsBridgeTile(tile)) return FindVehicleOnTileZ(tile, 0); |
12d69f54e920
(svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents:
6156
diff
changeset
|
800 |
|
12d69f54e920
(svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents:
6156
diff
changeset
|
801 |
TileIndex end = GetOtherBridgeEnd(tile); |
12d69f54e920
(svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents:
6156
diff
changeset
|
802 |
byte z = GetBridgeHeight(tile); |
12d69f54e920
(svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents:
6156
diff
changeset
|
803 |
Vehicle *v; |
12d69f54e920
(svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents:
6156
diff
changeset
|
804 |
|
12d69f54e920
(svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents:
6156
diff
changeset
|
805 |
/* check the start tile first since as this is closest to the water */ |
12d69f54e920
(svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents:
6156
diff
changeset
|
806 |
v = FindVehicleOnTileZ(tile, z); |
12d69f54e920
(svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents:
6156
diff
changeset
|
807 |
if (v != NULL && (v->vehstatus & VS_CRASHED) == 0) return v; |
12d69f54e920
(svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents:
6156
diff
changeset
|
808 |
|
12d69f54e920
(svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents:
6156
diff
changeset
|
809 |
/* check a vehicle in between both bridge heads */ |
12d69f54e920
(svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents:
6156
diff
changeset
|
810 |
v = FindVehicleBetween(tile, end, z, true); |
12d69f54e920
(svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents:
6156
diff
changeset
|
811 |
if (v != NULL) return v; |
12d69f54e920
(svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents:
6156
diff
changeset
|
812 |
|
12d69f54e920
(svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents:
6156
diff
changeset
|
813 |
/* check the end tile last to give fleeing vehicles a chance to escape */ |
12d69f54e920
(svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents:
6156
diff
changeset
|
814 |
v = FindVehicleOnTileZ(end, z); |
12d69f54e920
(svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents:
6156
diff
changeset
|
815 |
return (v != NULL && (v->vehstatus & VS_CRASHED) == 0) ? v : NULL; |
12d69f54e920
(svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents:
6156
diff
changeset
|
816 |
} |
12d69f54e920
(svn r8593) -Fix (FS#564): bridges do not get destroyed when the bridge head gets flooded and there is a vehicle on the bridge. Original patch by KeeperofTheSoul.
rubidium
parents:
6156
diff
changeset
|
817 |
|
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
818 |
static void FloodVehicle(Vehicle *v) |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
819 |
{ |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
820 |
if (!(v->vehstatus & VS_CRASHED)) { |
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
821 |
uint16 pass = 0; |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
822 |
|
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
823 |
if (v->type == VEH_TRAIN || v->type == VEH_ROAD || v->type == VEH_AIRCRAFT) { |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
824 |
if (v->type == VEH_AIRCRAFT) { |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
825 |
/* Crashing aircraft are always at z_pos == 1, never on z_pos == 0, |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
826 |
* because that's always the shadow. Except for the heliport, because |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
827 |
* that station has a big z_offset for the aircraft. */ |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
828 |
if (!IsTileType(v->tile, MP_STATION) || !IsAirport(v->tile) || GetTileMaxZ(v->tile) != 0) return; |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
829 |
const Station *st = GetStationByTile(v->tile); |
6738
72d1a2997952
(svn r10683) [NewGRF_ports] -Revert: Too eager to un-const... global search/replace removed too many. Restores necessary ones... for the moment ;)
richk
parents:
6734
diff
changeset
|
830 |
const AirportFTAClass *airport = st->Airport(); |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
831 |
|
6857
5012c47e576b
(svn r10960) [NewGRF_ports] -Change: Remove delta_z from the FSMport class. Will need to replace code at places marked with TODO.
richk
parents:
6770
diff
changeset
|
832 |
//TODO: airport->delta_z no longer used. need to get actual height of individual tile in layout |
5012c47e576b
(svn r10960) [NewGRF_ports] -Change: Remove delta_z from the FSMport class. Will need to replace code at places marked with TODO.
richk
parents:
6770
diff
changeset
|
833 |
//if (v->z_pos != airport->delta_z + 1) return; |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
834 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
835 |
|
6868
7eb395287b3d
(svn r11037) [NewGRF_ports] -Sync: with trunk r10844:11035.
rubidium
parents:
6857
diff
changeset
|
836 |
if (v->type != VEH_AIRCRAFT) v = v->First(); |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
837 |
|
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
838 |
/* crash all wagons, and count passengers */ |
10731
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
839 |
for (Vehicle *u = v; u != NULL; u = u->Next()) { |
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
840 |
if (IsCargoInClass(u->cargo_type, CC_PASSENGERS)) pass += u->cargo.Count(); |
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
841 |
u->vehstatus |= VS_CRASHED; |
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
842 |
MarkSingleVehicleDirty(u); |
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
843 |
} |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
844 |
|
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
845 |
switch (v->type) { |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
846 |
default: NOT_REACHED(); |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
847 |
case VEH_TRAIN: |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
848 |
if (IsFrontEngine(v)) pass += 4; // driver |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
849 |
v->u.rail.crash_anim_pos = 4000; // max 4440, disappear pretty fast |
10731
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
850 |
InvalidateWindowClassesData(WC_TRAINS_LIST, 0); |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
851 |
break; |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
852 |
|
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
853 |
case VEH_ROAD: |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
854 |
if (IsRoadVehFront(v)) pass += 1; // driver |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
855 |
v->u.road.crashed_ctr = 2000; // max 2220, disappear pretty fast |
10731
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
856 |
InvalidateWindowClassesData(WC_ROADVEH_LIST, 0); |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
857 |
break; |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
858 |
|
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
859 |
case VEH_AIRCRAFT: |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
860 |
pass += 2; // driver |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
861 |
v->u.air.crashed_counter = 9000; // max 10000, disappear pretty fast |
10731
67db0d431d5e
(svn r13281) [NewGRF_ports] -Sync: with trunk r13145:13280. Includes support for Noise Level on Prop 24 in .grf files.
richk
parents:
10724
diff
changeset
|
862 |
InvalidateWindowClassesData(WC_AIRCRAFT_LIST, 0); |
6720
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
863 |
break; |
35756db7e577
(svn r10560) [NewGRF_ports] -Sync: with trunk r10027-10559
richk
parents:
6719
diff
changeset
|
864 |
} |
2549 | 865 |
} else { |
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
866 |
return; |
2549 | 867 |
} |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
868 |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
869 |
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH); |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
870 |
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
871 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
872 |
SetDParam(0, pass); |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
873 |
AddNewsItem(STR_B006_FLOOD_VEHICLE_DESTROYED, |
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10274
diff
changeset
|
874 |
NS_ACCIDENT_VEHICLE, |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
875 |
v->index, |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
876 |
0); |
2549 | 877 |
CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE); |
878 |
SndPlayVehicleFx(SND_12_EXPLOSION, v); |
|
714
e3b9eda8dc45
(svn r1166) Fix: [ 1040119 ] Flooded wagons in depots don't keep constantly exploding any more
dominik
parents:
679
diff
changeset
|
879 |
} |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
880 |
} |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
881 |
|
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
882 |
/** |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
883 |
* Returns the behaviour of a tile during flooding. |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
884 |
* |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
885 |
* @return Behaviour of the tile |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
886 |
*/ |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
887 |
static FloodingBehaviour GetFloodingBehaviour(TileIndex tile) |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
888 |
{ |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
889 |
/* FLOOD_ACTIVE: 'single-corner-raised'-coast, sea, sea-shipdepots, sea-buoys, sea-docks (water part), rail with flooded halftile |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
890 |
* FLOOD_DRYUP: coast with more than one corner raised, coast with rail-track, coast with trees |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
891 |
* FLOOD_PASSIVE: oilrig, water-industries |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
892 |
* FLOOD_NONE: canals, rivers, everything else |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
893 |
*/ |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
894 |
switch (GetTileType(tile)) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
895 |
case MP_WATER: |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
896 |
if (IsCoast(tile)) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
897 |
Slope tileh = GetTileSlope(tile, NULL); |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
898 |
return (IsSlopeWithOneCornerRaised(tileh) ? FLOOD_ACTIVE : FLOOD_DRYUP); |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
899 |
} else { |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
900 |
return (GetWaterClass(tile) == WATER_CLASS_SEA) ? FLOOD_ACTIVE : FLOOD_NONE; |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
901 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
902 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
903 |
case MP_RAILWAY: |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
904 |
if (GetRailGroundType(tile) == RAIL_GROUND_WATER) { |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
905 |
return (IsSlopeWithOneCornerRaised(GetTileSlope(tile, NULL)) ? FLOOD_ACTIVE : FLOOD_DRYUP); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
906 |
} |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
907 |
return FLOOD_NONE; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
908 |
|
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
909 |
case MP_TREES: |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
910 |
return (GetTreeGround(tile) == TREE_GROUND_SHORE ? FLOOD_DRYUP : FLOOD_NONE); |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
911 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
912 |
case MP_STATION: |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
913 |
if (IsBuoy(tile) || (IsDock(tile) && GetTileSlope(tile, NULL) == SLOPE_FLAT)) { |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
914 |
return (GetWaterClass(tile) == WATER_CLASS_SEA ? FLOOD_ACTIVE : FLOOD_NONE); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
915 |
} |
6880
6d6f00b2baee
(svn r12354) [NewGRF_ports] -Fix: Correct bracket position.
richk
parents:
6879
diff
changeset
|
916 |
return (IsOilRig(tile) || GetStationByTile(tile)->FSMport_flood_protected) ? FLOOD_PASSIVE : FLOOD_NONE; |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
917 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
918 |
case MP_INDUSTRY: |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
919 |
return ((GetIndustrySpec(GetIndustryType(tile))->behaviour & INDUSTRYBEH_BUILT_ONWATER) != 0 ? FLOOD_PASSIVE : FLOOD_NONE); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
920 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
921 |
default: |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
922 |
return FLOOD_NONE; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
923 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
924 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
925 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
926 |
/** |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
927 |
* Floods a tile. |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
928 |
*/ |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
929 |
static void DoFloodTile(TileIndex target) |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
930 |
{ |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
931 |
assert(!IsTileType(target, MP_WATER)); |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
932 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
933 |
bool flooded = false; // Will be set to true if something is changed. |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
934 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
935 |
_current_player = OWNER_WATER; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
936 |
|
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
937 |
Slope tileh = GetTileSlope(target, NULL); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
938 |
if (tileh != SLOPE_FLAT) { |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
939 |
/* make coast.. */ |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
940 |
switch (GetTileType(target)) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
941 |
case MP_RAILWAY: { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
942 |
if (!IsPlainRailTile(target)) break; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
943 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
944 |
flooded = FloodHalftile(target); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
945 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
946 |
Vehicle *v = FindFloodableVehicleOnTile(target); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
947 |
if (v != NULL) FloodVehicle(v); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
948 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
949 |
break; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
950 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
951 |
|
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
952 |
case MP_TREES: |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
953 |
if (!IsSlopeWithOneCornerRaised(tileh)) { |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
954 |
SetTreeGroundDensity(target, TREE_GROUND_SHORE, 3); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
955 |
MarkTileDirtyByTile(target); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
956 |
flooded = true; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
957 |
break; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
958 |
} |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
959 |
/* FALL THROUGH */ |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
960 |
case MP_CLEAR: |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
961 |
if (CmdSucceeded(DoCommand(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
962 |
MakeShore(target); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
963 |
MarkTileDirtyByTile(target); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
964 |
flooded = true; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
965 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
966 |
break; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
967 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
968 |
default: |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
969 |
break; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
970 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
971 |
} else { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
972 |
/* Flood vehicles */ |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
973 |
Vehicle *v = FindFloodableVehicleOnTile(target); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
974 |
if (v != NULL) FloodVehicle(v); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
975 |
|
6873
86bf4ccb580d
(svn r11954) [NewGRF_ports] -Fix: Seaplane airports need protecting from flooding by adjacent tiles.
richk
parents:
6872
diff
changeset
|
976 |
/* Ensure sea-level FSMports do not flood */ |
86bf4ccb580d
(svn r11954) [NewGRF_ports] -Fix: Seaplane airports need protecting from flooding by adjacent tiles.
richk
parents:
6872
diff
changeset
|
977 |
if ((GetTileType(target) != MP_STATION) || !GetStationByTile(target)->FSMport_flood_protected) { |
86bf4ccb580d
(svn r11954) [NewGRF_ports] -Fix: Seaplane airports need protecting from flooding by adjacent tiles.
richk
parents:
6872
diff
changeset
|
978 |
/* flood flat tile */ |
86bf4ccb580d
(svn r11954) [NewGRF_ports] -Fix: Seaplane airports need protecting from flooding by adjacent tiles.
richk
parents:
6872
diff
changeset
|
979 |
if (CmdSucceeded(DoCommand(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) { |
86bf4ccb580d
(svn r11954) [NewGRF_ports] -Fix: Seaplane airports need protecting from flooding by adjacent tiles.
richk
parents:
6872
diff
changeset
|
980 |
MakeWater(target); |
86bf4ccb580d
(svn r11954) [NewGRF_ports] -Fix: Seaplane airports need protecting from flooding by adjacent tiles.
richk
parents:
6872
diff
changeset
|
981 |
MarkTileDirtyByTile(target); |
86bf4ccb580d
(svn r11954) [NewGRF_ports] -Fix: Seaplane airports need protecting from flooding by adjacent tiles.
richk
parents:
6872
diff
changeset
|
982 |
flooded = true; |
86bf4ccb580d
(svn r11954) [NewGRF_ports] -Fix: Seaplane airports need protecting from flooding by adjacent tiles.
richk
parents:
6872
diff
changeset
|
983 |
} |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
984 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
985 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
986 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
987 |
if (flooded) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
988 |
/* Mark surrounding canal tiles dirty too to avoid glitches */ |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
989 |
MarkCanalsAndRiversAroundDirty(target); |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
990 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
991 |
/* update signals if needed */ |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
992 |
UpdateSignalsInBuffer(); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
993 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
994 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
995 |
_current_player = OWNER_NONE; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
996 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
997 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
998 |
/** |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
999 |
* Drys a tile up. |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1000 |
*/ |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1001 |
static void DoDryUp(TileIndex tile) |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1002 |
{ |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1003 |
_current_player = OWNER_WATER; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1004 |
|
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1005 |
switch (GetTileType(tile)) { |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1006 |
case MP_RAILWAY: |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1007 |
assert(IsPlainRailTile(tile)); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1008 |
assert(GetRailGroundType(tile) == RAIL_GROUND_WATER); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1009 |
|
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1010 |
RailGroundType new_ground; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1011 |
switch (GetTrackBits(tile)) { |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1012 |
case TRACK_BIT_UPPER: new_ground = RAIL_GROUND_FENCE_HORIZ1; break; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1013 |
case TRACK_BIT_LOWER: new_ground = RAIL_GROUND_FENCE_HORIZ2; break; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1014 |
case TRACK_BIT_LEFT: new_ground = RAIL_GROUND_FENCE_VERT1; break; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1015 |
case TRACK_BIT_RIGHT: new_ground = RAIL_GROUND_FENCE_VERT2; break; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1016 |
default: NOT_REACHED(); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1017 |
} |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1018 |
SetRailGroundType(tile, new_ground); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1019 |
MarkTileDirtyByTile(tile); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1020 |
break; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1021 |
|
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1022 |
case MP_TREES: |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1023 |
SetTreeGroundDensity(tile, TREE_GROUND_GRASS, 3); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1024 |
MarkTileDirtyByTile(tile); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1025 |
break; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1026 |
|
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1027 |
case MP_WATER: |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1028 |
assert(IsCoast(tile)); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1029 |
|
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1030 |
if (CmdSucceeded(DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) { |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1031 |
MakeClear(tile, CLEAR_GRASS, 3); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1032 |
MarkTileDirtyByTile(tile); |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1033 |
} |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1034 |
break; |
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1035 |
|
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1036 |
default: NOT_REACHED(); |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1037 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1038 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1039 |
_current_player = OWNER_NONE; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1040 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1041 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1042 |
/** |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
1043 |
* Let a water tile floods its diagonal adjoining tiles |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
1044 |
* called from tunnelbridge_cmd, and by TileLoop_Industry() and TileLoop_Track() |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
1045 |
* |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
1046 |
* @param tile the water/shore tile that floods |
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
1047 |
*/ |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
1048 |
void TileLoop_Water(TileIndex tile) |
0 | 1049 |
{ |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1050 |
switch (GetFloodingBehaviour(tile)) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1051 |
case FLOOD_ACTIVE: |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1052 |
for (Direction dir = DIR_BEGIN; dir < DIR_END; dir++) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1053 |
TileIndex dest = AddTileIndexDiffCWrap(tile, TileIndexDiffCByDir(dir)); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1054 |
if (dest == INVALID_TILE) continue; |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
1055 |
/* do not try to flood water tiles - increases performance a lot */ |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
1056 |
if (IsTileType(dest, MP_WATER)) continue; |
2989 | 1057 |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1058 |
uint z_dest; |
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6880
diff
changeset
|
1059 |
Slope slope_dest = GetFoundationSlope(dest, &z_dest) & ~SLOPE_HALFTILE_MASK & ~SLOPE_STEEP; |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1060 |
if (z_dest > 0) continue; |
43
3b93861c5478
(svn r44) Fix: Coast line near edge of map and near oilrigs (Dribbel)
dominik
parents:
39
diff
changeset
|
1061 |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1062 |
if (!HasBit(_flood_from_dirs[slope_dest], ReverseDir(dir))) continue; |
43
3b93861c5478
(svn r44) Fix: Coast line near edge of map and near oilrigs (Dribbel)
dominik
parents:
39
diff
changeset
|
1063 |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1064 |
DoFloodTile(dest); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1065 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1066 |
break; |
43
3b93861c5478
(svn r44) Fix: Coast line near edge of map and near oilrigs (Dribbel)
dominik
parents:
39
diff
changeset
|
1067 |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1068 |
case FLOOD_DRYUP: { |
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6880
diff
changeset
|
1069 |
Slope slope_here = GetFoundationSlope(tile, NULL) & ~SLOPE_HALFTILE_MASK & ~SLOPE_STEEP; |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1070 |
uint check_dirs = _flood_from_dirs[slope_here]; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1071 |
uint dir; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1072 |
FOR_EACH_SET_BIT(dir, check_dirs) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1073 |
TileIndex dest = AddTileIndexDiffCWrap(tile, TileIndexDiffCByDir((Direction)dir)); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1074 |
if (dest == INVALID_TILE) continue; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1075 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1076 |
FloodingBehaviour dest_behaviour = GetFloodingBehaviour(dest); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1077 |
if ((dest_behaviour == FLOOD_ACTIVE) || (dest_behaviour == FLOOD_PASSIVE)) return; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1078 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1079 |
DoDryUp(tile); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1080 |
break; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1081 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1082 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1083 |
default: return; |
2639 | 1084 |
} |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1085 |
} |
43
3b93861c5478
(svn r44) Fix: Coast line near edge of map and near oilrigs (Dribbel)
dominik
parents:
39
diff
changeset
|
1086 |
|
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1087 |
void ConvertGroundTilesIntoWaterTiles() |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1088 |
{ |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1089 |
TileIndex tile; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1090 |
uint z; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1091 |
Slope slope; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1092 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1093 |
for (tile = 0; tile < MapSize(); ++tile) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1094 |
slope = GetTileSlope(tile, &z); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1095 |
if (IsTileType(tile, MP_CLEAR) && z == 0) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1096 |
/* Make both water for tiles at level 0 |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1097 |
* and make shore, as that looks much better |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1098 |
* during the generation. */ |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1099 |
switch (slope) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1100 |
case SLOPE_FLAT: |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1101 |
MakeWater(tile); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1102 |
break; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1103 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1104 |
case SLOPE_N: |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1105 |
case SLOPE_E: |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1106 |
case SLOPE_S: |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1107 |
case SLOPE_W: |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1108 |
MakeShore(tile); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1109 |
break; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1110 |
|
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1111 |
default: |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1112 |
uint check_dirs = _flood_from_dirs[slope & ~SLOPE_STEEP]; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1113 |
uint dir; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1114 |
FOR_EACH_SET_BIT(dir, check_dirs) { |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1115 |
TileIndex dest = TILE_ADD(tile, TileOffsByDir((Direction)dir)); |
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6880
diff
changeset
|
1116 |
Slope slope_dest = GetTileSlope(dest, NULL) & ~SLOPE_STEEP; |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1117 |
if (slope_dest == SLOPE_FLAT || IsSlopeWithOneCornerRaised(slope_dest)) { |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1118 |
MakeShore(tile); |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1119 |
break; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1120 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1121 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1122 |
break; |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1123 |
} |
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1124 |
} |
2639 | 1125 |
} |
0 | 1126 |
} |
1127 |
||
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
1128 |
static TrackStatus GetTileTrackStatus_Water(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side) |
0 | 1129 |
{ |
3423
03e0e97abf41
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3422
diff
changeset
|
1130 |
static const byte coast_tracks[] = {0, 32, 4, 0, 16, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0}; |
4169
b775328748af
(svn r5606) Replace some magic numbers by proper TrackBits enums and macros
tron
parents:
4101
diff
changeset
|
1131 |
|
b775328748af
(svn r5606) Replace some magic numbers by proper TrackBits enums and macros
tron
parents:
4101
diff
changeset
|
1132 |
TrackBits ts; |
b775328748af
(svn r5606) Replace some magic numbers by proper TrackBits enums and macros
tron
parents:
4101
diff
changeset
|
1133 |
|
2951 | 1134 |
if (mode != TRANSPORT_WATER) return 0; |
0 | 1135 |
|
3423
03e0e97abf41
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3422
diff
changeset
|
1136 |
switch (GetWaterTileType(tile)) { |
6877
889301acc299
(svn r12053) [NewGRF_ports] -Sync: with trunk r11949:12050.
rubidium
parents:
6873
diff
changeset
|
1137 |
case WATER_TILE_CLEAR: ts = (GetTileSlope(tile, NULL) == SLOPE_FLAT) ? TRACK_BIT_ALL : TRACK_BIT_NONE; break; |
6507
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
6486
diff
changeset
|
1138 |
case WATER_TILE_COAST: ts = (TrackBits)coast_tracks[GetTileSlope(tile, NULL) & 0xF]; break; |
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10274
diff
changeset
|
1139 |
case WATER_TILE_LOCK: ts = DiagDirToDiagTrackBits(GetLockDirection(tile)); break; |
6507
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
6486
diff
changeset
|
1140 |
case WATER_TILE_DEPOT: ts = AxisToTrackBits(GetShipDepotAxis(tile)); break; |
3423
03e0e97abf41
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3422
diff
changeset
|
1141 |
default: return 0; |
0 | 1142 |
} |
3900
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
1143 |
if (TileX(tile) == 0) { |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
1144 |
/* NE border: remove tracks that connects NE tile edge */ |
3900
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
1145 |
ts &= ~(TRACK_BIT_X | TRACK_BIT_UPPER | TRACK_BIT_RIGHT); |
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
1146 |
} |
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
1147 |
if (TileY(tile) == 0) { |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6660
diff
changeset
|
1148 |
/* NW border: remove tracks that connects NW tile edge */ |
3900
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
1149 |
ts &= ~(TRACK_BIT_Y | TRACK_BIT_LEFT | TRACK_BIT_UPPER); |
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
1150 |
} |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
1151 |
return CombineTrackStatus(TrackBitsToTrackdirBits(ts), TRACKDIR_BIT_NONE); |
0 | 1152 |
} |
1153 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
1154 |
static void ClickTile_Water(TileIndex tile) |
0 | 1155 |
{ |
6507
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
6486
diff
changeset
|
1156 |
if (GetWaterTileType(tile) == WATER_TILE_DEPOT) { |
3423
03e0e97abf41
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3422
diff
changeset
|
1157 |
TileIndex tile2 = GetOtherShipDepotTile(tile); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
1158 |
|
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6574
diff
changeset
|
1159 |
ShowDepotWindow(tile < tile2 ? tile : tile2, VEH_SHIP); |
0 | 1160 |
} |
1161 |
} |
|
1162 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2261
diff
changeset
|
1163 |
static void ChangeTileOwner_Water(TileIndex tile, PlayerID old_player, PlayerID new_player) |
0 | 1164 |
{ |
1901
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
1165 |
if (!IsTileOwner(tile, old_player)) return; |
0 | 1166 |
|
4848
56549aa3e234
(svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents:
4638
diff
changeset
|
1167 |
if (new_player != PLAYER_SPECTATOR) { |
1902 | 1168 |
SetTileOwner(tile, new_player); |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
1169 |
return; |
0 | 1170 |
} |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
1171 |
|
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
1172 |
/* Remove depot */ |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
1173 |
if (IsShipDepot(tile)) DoCommand(tile, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR); |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
1174 |
|
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
1175 |
/* Set owner of canals and locks ... and also canal under dock there was before. |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
1176 |
* Check if the new owner after removing depot isn't OWNER_WATER. */ |
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6877
diff
changeset
|
1177 |
if (IsTileOwner(tile, old_player)) SetTileOwner(tile, OWNER_NONE); |
0 | 1178 |
} |
1179 |
||
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
1180 |
static VehicleEnterTileStatus VehicleEnter_Water(Vehicle *v, TileIndex tile, int x, int y) |
0 | 1181 |
{ |
6317
c73bda71ac16
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents:
6205
diff
changeset
|
1182 |
return VETSB_CONTINUE; |
0 | 1183 |
} |
1184 |
||
6868
7eb395287b3d
(svn r11037) [NewGRF_ports] -Sync: with trunk r10844:11035.
rubidium
parents:
6857
diff
changeset
|
1185 |
static CommandCost TerraformTile_Water(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new) |
7eb395287b3d
(svn r11037) [NewGRF_ports] -Sync: with trunk r10844:11035.
rubidium
parents:
6857
diff
changeset
|
1186 |
{ |
7eb395287b3d
(svn r11037) [NewGRF_ports] -Sync: with trunk r10844:11035.
rubidium
parents:
6857
diff
changeset
|
1187 |
/* Canals can't be terraformed */ |
6871
5a9dc001e1ad
(svn r11566) [NewGRF_ports] -Sync: with trunk r11218:r11565.
rubidium
parents:
6870
diff
changeset
|
1188 |
if (IsWaterTile(tile) && IsCanal(tile)) return_cmd_error(STR_MUST_DEMOLISH_CANAL_FIRST); |
6868
7eb395287b3d
(svn r11037) [NewGRF_ports] -Sync: with trunk r10844:11035.
rubidium
parents:
6857
diff
changeset
|
1189 |
|
7eb395287b3d
(svn r11037) [NewGRF_ports] -Sync: with trunk r10844:11035.
rubidium
parents:
6857
diff
changeset
|
1190 |
return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
7eb395287b3d
(svn r11037) [NewGRF_ports] -Sync: with trunk r10844:11035.
rubidium
parents:
6857
diff
changeset
|
1191 |
} |
7eb395287b3d
(svn r11037) [NewGRF_ports] -Sync: with trunk r10844:11035.
rubidium
parents:
6857
diff
changeset
|
1192 |
|
0 | 1193 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1194 |
extern const TileTypeProcs _tile_type_water_procs = { |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4231
diff
changeset
|
1195 |
DrawTile_Water, /* draw_tile_proc */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4231
diff
changeset
|
1196 |
GetSlopeZ_Water, /* get_slope_z_proc */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4231
diff
changeset
|
1197 |
ClearTile_Water, /* clear_tile_proc */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4231
diff
changeset
|
1198 |
GetAcceptedCargo_Water, /* get_accepted_cargo_proc */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4231
diff
changeset
|
1199 |
GetTileDesc_Water, /* get_tile_desc_proc */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4231
diff
changeset
|
1200 |
GetTileTrackStatus_Water, /* get_tile_track_status_proc */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4231
diff
changeset
|
1201 |
ClickTile_Water, /* click_tile_proc */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4231
diff
changeset
|
1202 |
AnimateTile_Water, /* animate_tile_proc */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4231
diff
changeset
|
1203 |
TileLoop_Water, /* tile_loop_clear */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4231
diff
changeset
|
1204 |
ChangeTileOwner_Water, /* change_tile_owner_clear */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4231
diff
changeset
|
1205 |
NULL, /* get_produced_cargo_proc */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4231
diff
changeset
|
1206 |
VehicleEnter_Water, /* vehicle_enter_tile_proc */ |
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6738
diff
changeset
|
1207 |
GetFoundation_Water, /* get_foundation_proc */ |
6868
7eb395287b3d
(svn r11037) [NewGRF_ports] -Sync: with trunk r10844:11035.
rubidium
parents:
6857
diff
changeset
|
1208 |
TerraformTile_Water, /* terraform_tile_proc */ |
0 | 1209 |
}; |