author | tron |
Wed, 07 Jun 2006 19:35:21 +0000 | |
changeset 3977 | edb5b94e2094 |
parent 3940 | f3aa8e2969d4 |
child 4077 | d3022f976946 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1796
diff
changeset
|
4 |
#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
|
5 |
#include "bridge_map.h" |
3338
2c60ed0dcce3
(svn r4120) Use the new station functions where appropriate
tron
parents:
3275
diff
changeset
|
6 |
#include "station_map.h" |
1363
01d3de5d8039
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1359
diff
changeset
|
7 |
#include "table/sprites.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
497
diff
changeset
|
8 |
#include "table/strings.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2148
diff
changeset
|
9 |
#include "functions.h" |
679
e959706a3e4d
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
588
diff
changeset
|
10 |
#include "map.h" |
1209
a1ac96655b79
(svn r1713) Split off several functions which query/set information about a single tile from map.h and put them into a seperate file tile.h
tron
parents:
1132
diff
changeset
|
11 |
#include "tile.h" |
0 | 12 |
#include "vehicle.h" |
13 |
#include "viewport.h" |
|
14 |
#include "command.h" |
|
15 |
#include "town.h" |
|
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
16 |
#include "news.h" |
337
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
314
diff
changeset
|
17 |
#include "sound.h" |
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1214
diff
changeset
|
18 |
#include "depot.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" |
3111
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
3017
diff
changeset
|
21 |
#include "water_map.h" |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
22 |
|
3977
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
23 |
const SpriteID _water_shore_sprites[15] = { |
2517
b90693227193
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2502
diff
changeset
|
24 |
0, |
b90693227193
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2502
diff
changeset
|
25 |
SPR_SHORE_TILEH_1, |
b90693227193
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2502
diff
changeset
|
26 |
SPR_SHORE_TILEH_2, |
b90693227193
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2502
diff
changeset
|
27 |
SPR_SHORE_TILEH_3, |
b90693227193
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2502
diff
changeset
|
28 |
SPR_SHORE_TILEH_4, |
b90693227193
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2502
diff
changeset
|
29 |
0, |
b90693227193
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2502
diff
changeset
|
30 |
SPR_SHORE_TILEH_6, |
b90693227193
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2502
diff
changeset
|
31 |
0, |
b90693227193
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2502
diff
changeset
|
32 |
SPR_SHORE_TILEH_8, |
b90693227193
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2502
diff
changeset
|
33 |
SPR_SHORE_TILEH_9, |
b90693227193
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2502
diff
changeset
|
34 |
0, |
b90693227193
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2502
diff
changeset
|
35 |
0, |
b90693227193
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2502
diff
changeset
|
36 |
SPR_SHORE_TILEH_12, |
b90693227193
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2502
diff
changeset
|
37 |
0, |
b90693227193
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2502
diff
changeset
|
38 |
0 |
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2186
diff
changeset
|
39 |
}; |
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2186
diff
changeset
|
40 |
|
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2186
diff
changeset
|
41 |
|
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
42 |
static void FloodVehicle(Vehicle *v); |
0 | 43 |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1752
diff
changeset
|
44 |
/** 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
|
45 |
* @param tile tile where ship depot is built |
2657
d72100c6a799
(svn r3199) -Fix: There are only 2 possible directions for ship depots, not 4
tron
parents:
2652
diff
changeset
|
46 |
* @param p1 depot direction (0 == X or 1 == Y) |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1752
diff
changeset
|
47 |
* @param p2 unused |
0 | 48 |
*/ |
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
|
49 |
int32 CmdBuildShipDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 50 |
{ |
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
|
51 |
TileIndex tile2; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
52 |
|
0 | 53 |
int32 cost, ret; |
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1214
diff
changeset
|
54 |
Depot *depot; |
0 | 55 |
|
56 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
|
57 |
||
2657
d72100c6a799
(svn r3199) -Fix: There are only 2 possible directions for ship depots, not 4
tron
parents:
2652
diff
changeset
|
58 |
if (p1 > 1) return CMD_ERROR; |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1752
diff
changeset
|
59 |
|
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1752
diff
changeset
|
60 |
if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
0 | 61 |
|
1981 | 62 |
tile2 = tile + (p1 ? TileDiffXY(0, 1) : TileDiffXY(1, 0)); |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1752
diff
changeset
|
63 |
if (!EnsureNoVehicle(tile2)) return CMD_ERROR; |
0 | 64 |
|
65 |
if (!IsClearWaterTile(tile) || !IsClearWaterTile(tile2)) |
|
66 |
return_cmd_error(STR_3801_MUST_BE_BUILT_ON_WATER); |
|
67 |
||
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
|
68 |
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
|
69 |
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
|
70 |
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
|
71 |
if (CmdFailed(ret)) return CMD_ERROR; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
72 |
|
0 | 73 |
// pretend that we're not making land from the water even though we actually are. |
74 |
cost = 0; |
|
75 |
||
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1214
diff
changeset
|
76 |
depot = AllocateDepot(); |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1752
diff
changeset
|
77 |
if (depot == NULL) return CMD_ERROR; |
0 | 78 |
|
79 |
if (flags & DC_EXEC) { |
|
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1214
diff
changeset
|
80 |
depot->xy = tile; |
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1214
diff
changeset
|
81 |
depot->town_index = ClosestTownFromTile(tile, (uint)-1)->index; |
0 | 82 |
|
3372
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3338
diff
changeset
|
83 |
MakeShipDepot(tile,_current_player, DEPOT_NORTH, p1); |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3338
diff
changeset
|
84 |
MakeShipDepot(tile2,_current_player, DEPOT_SOUTH, p1); |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3338
diff
changeset
|
85 |
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
|
86 |
MarkTileDirtyByTile(tile2); |
0 | 87 |
} |
88 |
||
89 |
return cost + _price.build_ship_depot; |
|
90 |
} |
|
91 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
92 |
static int32 RemoveShipDepot(TileIndex tile, uint32 flags) |
0 | 93 |
{ |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
94 |
TileIndex tile2; |
0 | 95 |
|
3373
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
96 |
if (!IsShipDepot(tile)) return CMD_ERROR; |
2951 | 97 |
if (!CheckTileOwnership(tile)) return CMD_ERROR; |
98 |
if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
|
0 | 99 |
|
3373
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
100 |
tile2 = GetOtherShipDepotTile(tile); |
0 | 101 |
|
2951 | 102 |
if (!EnsureNoVehicle(tile2)) return CMD_ERROR; |
0 | 103 |
|
104 |
if (flags & DC_EXEC) { |
|
3373
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
105 |
/* Kill the depot, which is registered at the northernmost tile. Use that one */ |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
106 |
DoDeleteDepot(tile2 < tile ? tile2 : tile); |
0 | 107 |
|
3111
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
3017
diff
changeset
|
108 |
MakeWater(tile); |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
3017
diff
changeset
|
109 |
MakeWater(tile2); |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
3017
diff
changeset
|
110 |
MarkTileDirtyByTile(tile); |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
3017
diff
changeset
|
111 |
MarkTileDirtyByTile(tile2); |
0 | 112 |
} |
113 |
||
114 |
return _price.remove_ship_depot; |
|
115 |
} |
|
116 |
||
117 |
// build a shiplift |
|
3157
40de8616c04c
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3111
diff
changeset
|
118 |
static int32 DoBuildShiplift(TileIndex tile, DiagDirection dir, uint32 flags) |
0 | 119 |
{ |
120 |
int32 ret; |
|
121 |
int delta; |
|
122 |
||
123 |
// 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
|
124 |
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
|
125 |
if (CmdFailed(ret)) return CMD_ERROR; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
126 |
|
900 | 127 |
delta = TileOffsByDir(dir); |
0 | 128 |
// lower 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
|
129 |
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
|
130 |
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
|
131 |
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
|
132 |
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
|
133 |
} |
0 | 134 |
|
135 |
// upper 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
|
136 |
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
|
137 |
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
|
138 |
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
|
139 |
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
|
140 |
} |
0 | 141 |
|
142 |
if (flags & DC_EXEC) { |
|
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
|
143 |
MakeLock(tile, _current_player, dir); |
3372
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3338
diff
changeset
|
144 |
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
|
145 |
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
|
146 |
MarkTileDirtyByTile(tile + delta); |
0 | 147 |
} |
148 |
||
149 |
return _price.clear_water * 22 >> 3; |
|
150 |
} |
|
151 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
152 |
static int32 RemoveShiplift(TileIndex tile, uint32 flags) |
0 | 153 |
{ |
3373
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
154 |
TileIndexDiff delta = TileOffsByDir(GetLockDirection(tile)); |
0 | 155 |
|
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
|
156 |
if (!CheckTileOwnership(tile)) return CMD_ERROR; |
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
|
157 |
|
0 | 158 |
// make sure no vehicle is on the tile. |
159 |
if (!EnsureNoVehicle(tile) || !EnsureNoVehicle(tile + delta) || !EnsureNoVehicle(tile - delta)) |
|
160 |
return CMD_ERROR; |
|
161 |
||
162 |
if (flags & DC_EXEC) { |
|
163 |
DoClearSquare(tile); |
|
164 |
DoClearSquare(tile + delta); |
|
165 |
DoClearSquare(tile - delta); |
|
166 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
167 |
|
0 | 168 |
return _price.clear_water * 2; |
169 |
} |
|
170 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
171 |
static void MarkTilesAroundDirty(TileIndex tile) |
0 | 172 |
{ |
173 |
MarkTileDirtyByTile(TILE_ADDXY(tile, 0, 1)); |
|
174 |
MarkTileDirtyByTile(TILE_ADDXY(tile, 0, -1)); |
|
175 |
MarkTileDirtyByTile(TILE_ADDXY(tile, 1, 0)); |
|
176 |
MarkTileDirtyByTile(TILE_ADDXY(tile, -1, 0)); |
|
177 |
} |
|
178 |
||
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
|
179 |
/** 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
|
180 |
* @param tile tile where to place the lock |
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
|
181 |
* @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
|
182 |
* @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
|
183 |
*/ |
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
|
184 |
int32 CmdBuildLock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 185 |
{ |
3157
40de8616c04c
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3111
diff
changeset
|
186 |
DiagDirection dir; |
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
|
187 |
|
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
|
188 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
0 | 189 |
|
3157
40de8616c04c
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3111
diff
changeset
|
190 |
switch (GetTileSlope(tile, NULL)) { |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3491
diff
changeset
|
191 |
case SLOPE_SW: dir = DIAGDIR_SW; break; |
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3491
diff
changeset
|
192 |
case SLOPE_SE: dir = DIAGDIR_SE; break; |
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3491
diff
changeset
|
193 |
case SLOPE_NW: dir = DIAGDIR_NW; break; |
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3491
diff
changeset
|
194 |
case SLOPE_NE: dir = DIAGDIR_NE; break; |
3157
40de8616c04c
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3111
diff
changeset
|
195 |
default: return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
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
|
196 |
} |
3157
40de8616c04c
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3111
diff
changeset
|
197 |
return DoBuildShiplift(tile, dir, flags); |
0 | 198 |
} |
199 |
||
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
|
200 |
/** 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
|
201 |
* @param tile end tile of stretch-dragging |
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
|
202 |
* @param p1 start tile of stretch-dragging |
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
|
203 |
* @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
|
204 |
*/ |
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
|
205 |
int32 CmdBuildCanal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 206 |
{ |
3177 | 207 |
int32 cost; |
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
|
208 |
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
|
209 |
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
|
210 |
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
|
211 |
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
|
212 |
|
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
|
213 |
if (p1 >= MapSize()) 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
|
214 |
|
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
|
215 |
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
|
216 |
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
|
217 |
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
|
218 |
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
|
219 |
|
0 | 220 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
221 |
||
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
|
222 |
if (x < sx) intswap(x, sx); |
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
|
223 |
if (y < sy) intswap(y, sy); |
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
|
224 |
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
|
225 |
size_y = (y - sy) + 1; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
226 |
|
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
|
227 |
/* 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
|
228 |
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
|
229 |
|
0 | 230 |
cost = 0; |
1981 | 231 |
BEGIN_TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) { |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3491
diff
changeset
|
232 |
if (GetTileSlope(tile, 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
|
233 |
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
|
234 |
} |
0 | 235 |
|
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
|
236 |
// can't make water of water! |
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
|
237 |
if (IsTileType(tile, MP_WATER)) 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
|
238 |
|
3977
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
239 |
/* is middle piece of a bridge? */ |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
240 |
if (IsBridgeTile(tile) && IsBridgeMiddle(tile)) { |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
241 |
if (IsTransportUnderBridge(tile)) { |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
242 |
return_cmd_error(STR_5800_OBJECT_IN_THE_WAY); |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
243 |
} |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
244 |
|
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
245 |
if (IsWaterUnderBridge(tile)) return_cmd_error(STR_1007_ALREADY_BUILT); |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
246 |
|
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
247 |
if (flags & DC_EXEC) { |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
248 |
if (TileHeight(tile) == 0) { |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
249 |
SetWaterUnderBridge(tile); |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
250 |
} else { |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
251 |
SetCanalUnderBridge(tile, _current_player); |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
252 |
} |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
253 |
} |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
254 |
} else { |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
255 |
/* no bridge, try to clear it. */ |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
256 |
int32 ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
257 |
|
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
258 |
if (CmdFailed(ret)) return ret; |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
259 |
cost += ret; |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
260 |
|
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
261 |
if (flags & DC_EXEC) { |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
262 |
if (TileHeight(tile) == 0) { |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
263 |
MakeWater(tile); |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
264 |
} else { |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
265 |
MakeCanal(tile, _current_player); |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
266 |
} |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
267 |
} |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
268 |
} |
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
|
269 |
|
3189
1af302c5abd0
(svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
3183
diff
changeset
|
270 |
if (flags & DC_EXEC) { |
1af302c5abd0
(svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
3183
diff
changeset
|
271 |
MarkTileDirtyByTile(tile); |
1af302c5abd0
(svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
3183
diff
changeset
|
272 |
MarkTilesAroundDirty(tile); |
1af302c5abd0
(svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
3183
diff
changeset
|
273 |
} |
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
|
274 |
|
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
|
275 |
cost += _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
|
276 |
} END_TILE_LOOP(tile, size_x, size_y, 0); |
0 | 277 |
|
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
|
278 |
if (cost == 0) { |
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
|
279 |
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
|
280 |
} 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
|
281 |
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
|
282 |
} |
0 | 283 |
} |
284 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
285 |
static int32 ClearTile_Water(TileIndex tile, byte flags) |
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
286 |
{ |
3425
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3423
diff
changeset
|
287 |
switch (GetWaterTileType(tile)) { |
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3423
diff
changeset
|
288 |
case WATER_CLEAR: |
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3423
diff
changeset
|
289 |
if (flags & DC_NO_WATER) return_cmd_error(STR_3807_CAN_T_BUILD_ON_WATER); |
0 | 290 |
|
3425
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3423
diff
changeset
|
291 |
// Make sure no vehicle is on the tile |
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3423
diff
changeset
|
292 |
if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
0 | 293 |
|
3425
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3423
diff
changeset
|
294 |
// Make sure it's not an edge tile. |
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3423
diff
changeset
|
295 |
if (!IS_INT_INSIDE(TileX(tile), 1, MapMaxX() - 1) || |
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3423
diff
changeset
|
296 |
!IS_INT_INSIDE(TileY(tile), 1, MapMaxY() - 1)) { |
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3423
diff
changeset
|
297 |
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
|
298 |
} |
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
|
299 |
|
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
|
300 |
if (GetTileOwner(tile) != OWNER_WATER && !CheckTileOwnership(tile)) return CMD_ERROR; |
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
|
301 |
|
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
|
302 |
if (flags & DC_EXEC) DoClearSquare(tile); |
3425
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3423
diff
changeset
|
303 |
return _price.clear_water; |
0 | 304 |
|
3439 | 305 |
case WATER_COAST: { |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3491
diff
changeset
|
306 |
Slope slope = GetTileSlope(tile, NULL); |
3439 | 307 |
|
308 |
// Make sure no vehicle is on the tile |
|
309 |
if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
|
310 |
||
311 |
// Make sure it's not an edge tile. |
|
312 |
if (!IS_INT_INSIDE(TileX(tile), 1, MapMaxX() - 1) || |
|
313 |
!IS_INT_INSIDE(TileY(tile), 1, MapMaxY() - 1)) { |
|
314 |
return_cmd_error(STR_0002_TOO_CLOSE_TO_EDGE_OF_MAP); |
|
3425
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3423
diff
changeset
|
315 |
} |
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3423
diff
changeset
|
316 |
|
3439 | 317 |
if (flags & DC_EXEC) DoClearSquare(tile); |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3491
diff
changeset
|
318 |
if (slope == SLOPE_N || slope == SLOPE_E || slope == SLOPE_S || slope == SLOPE_W) { |
3439 | 319 |
return _price.clear_water; |
320 |
} else { |
|
321 |
return _price.purchase_land; |
|
3425
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3423
diff
changeset
|
322 |
} |
3439 | 323 |
} |
324 |
||
325 |
case WATER_LOCK: { |
|
326 |
static const TileIndexDiffC _shiplift_tomiddle_offs[] = { |
|
327 |
{ 0, 0}, {0, 0}, { 0, 0}, {0, 0}, // middle |
|
328 |
{-1, 0}, {0, 1}, { 1, 0}, {0, -1}, // lower |
|
329 |
{ 1, 0}, {0, -1}, {-1, 0}, {0, 1}, // upper |
|
330 |
}; |
|
331 |
||
332 |
if (flags & DC_AUTO) return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED); |
|
333 |
if (_current_player == OWNER_WATER) return CMD_ERROR; |
|
334 |
// move to the middle tile.. |
|
335 |
return RemoveShiplift(tile + ToTileIndexDiff(_shiplift_tomiddle_offs[GetSection(tile)]), flags); |
|
336 |
} |
|
337 |
||
3425
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3423
diff
changeset
|
338 |
case WATER_DEPOT: |
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3423
diff
changeset
|
339 |
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
|
340 |
|
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3423
diff
changeset
|
341 |
return RemoveShipDepot(tile, flags); |
3439 | 342 |
|
343 |
default: |
|
344 |
NOT_REACHED(); |
|
345 |
return 0; |
|
0 | 346 |
} |
3900
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
347 |
|
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
348 |
return 0; // useless but silences warning |
0 | 349 |
} |
350 |
||
351 |
// return true if a tile is a water tile. |
|
1048 | 352 |
static bool IsWateredTile(TileIndex tile) |
0 | 353 |
{ |
1214
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1209
diff
changeset
|
354 |
switch (GetTileType(tile)) { |
3977
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
355 |
case MP_WATER: |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
356 |
return !IsCoast(tile); |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
357 |
|
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
358 |
case MP_STATION: |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
359 |
return IsOilRig(tile) || IsDock(tile) || IsBuoy_(tile); |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
360 |
|
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
361 |
case MP_TUNNELBRIDGE: |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
362 |
return IsBridge(tile) && IsBridgeMiddle(tile) && IsWaterUnderBridge(tile); |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
363 |
|
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
364 |
default: |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
365 |
return false; |
1048 | 366 |
} |
0 | 367 |
} |
368 |
||
369 |
// draw a canal styled water tile with dikes around |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
370 |
void DrawCanalWater(TileIndex tile) |
0 | 371 |
{ |
372 |
uint wa; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
373 |
|
0 | 374 |
// determine the edges around with water. |
375 |
wa = IsWateredTile(TILE_ADDXY(tile, -1, 0)) << 0; |
|
376 |
wa += IsWateredTile(TILE_ADDXY(tile, 0, 1)) << 1; |
|
377 |
wa += IsWateredTile(TILE_ADDXY(tile, 1, 0)) << 2; |
|
378 |
wa += IsWateredTile(TILE_ADDXY(tile, 0, -1)) << 3; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
379 |
|
0 | 380 |
if (!(wa & 1)) DrawGroundSprite(SPR_CANALS_BASE + 57); |
381 |
if (!(wa & 2)) DrawGroundSprite(SPR_CANALS_BASE + 58); |
|
382 |
if (!(wa & 4)) DrawGroundSprite(SPR_CANALS_BASE + 59); |
|
383 |
if (!(wa & 8)) DrawGroundSprite(SPR_CANALS_BASE + 60); |
|
384 |
||
385 |
// right corner |
|
2989 | 386 |
switch (wa & 0x03) { |
387 |
case 0: DrawGroundSprite(SPR_CANALS_BASE + 57 + 4); break; |
|
388 |
case 3: if (!IsWateredTile(TILE_ADDXY(tile, -1, 1))) DrawGroundSprite(SPR_CANALS_BASE + 57 + 8); break; |
|
389 |
} |
|
0 | 390 |
|
391 |
// bottom corner |
|
2989 | 392 |
switch (wa & 0x06) { |
393 |
case 0: DrawGroundSprite(SPR_CANALS_BASE + 57 + 5); break; |
|
394 |
case 6: if (!IsWateredTile(TILE_ADDXY(tile, 1, 1))) DrawGroundSprite(SPR_CANALS_BASE + 57 + 9); break; |
|
395 |
} |
|
0 | 396 |
|
397 |
// left corner |
|
2989 | 398 |
switch (wa & 0x0C) { |
399 |
case 0: DrawGroundSprite(SPR_CANALS_BASE + 57 + 6); break; |
|
400 |
case 12: if (!IsWateredTile(TILE_ADDXY(tile, 1, -1))) DrawGroundSprite(SPR_CANALS_BASE + 57 + 10); break; |
|
401 |
} |
|
0 | 402 |
|
403 |
// upper corner |
|
2989 | 404 |
switch (wa & 0x09) { |
405 |
case 0: DrawGroundSprite(SPR_CANALS_BASE + 57 + 7); break; |
|
406 |
case 9: if (!IsWateredTile(TILE_ADDXY(tile, -1, -1))) DrawGroundSprite(SPR_CANALS_BASE + 57 + 11); break; |
|
407 |
} |
|
0 | 408 |
} |
409 |
||
410 |
typedef struct LocksDrawTileStruct { |
|
411 |
int8 delta_x, delta_y, delta_z; |
|
412 |
byte width, height, depth; |
|
413 |
SpriteID image; |
|
414 |
} LocksDrawTileStruct; |
|
415 |
||
416 |
#include "table/water_land.h" |
|
417 |
||
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
|
418 |
static void DrawWaterStuff(const TileInfo *ti, const WaterDrawTileStruct *wdts, |
1399
4503bd2bfb82
(svn r1903) Replace some casts and macro magic with proper typing, similar to r1902
tron
parents:
1363
diff
changeset
|
419 |
uint32 palette, uint base |
4503bd2bfb82
(svn r1903) Replace some casts and macro magic with proper typing, similar to r1902
tron
parents:
1363
diff
changeset
|
420 |
) |
0 | 421 |
{ |
1399
4503bd2bfb82
(svn r1903) Replace some casts and macro magic with proper typing, similar to r1902
tron
parents:
1363
diff
changeset
|
422 |
DrawGroundSprite(wdts++->image); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
423 |
|
1399
4503bd2bfb82
(svn r1903) Replace some casts and macro magic with proper typing, similar to r1902
tron
parents:
1363
diff
changeset
|
424 |
for (; wdts->delta_x != 0x80; wdts++) { |
2989 | 425 |
uint32 image = wdts->image + base; |
0 | 426 |
if (_display_opt & DO_TRANS_BUILDINGS) { |
2148
47ba4a1b1c3b
(svn r2658) -Codechange: Use MAKE_TRANSPARENT to display a transparented sprite
celestar
parents:
2049
diff
changeset
|
427 |
MAKE_TRANSPARENT(image); |
497
2d6d31173813
(svn r787) Invert the sense of the DO_TRANS_BUILDINGS flag to be consistent with its own name and all other DO_* flags.
tron
parents:
473
diff
changeset
|
428 |
} else { |
0 | 429 |
image |= palette; |
430 |
} |
|
431 |
AddSortableSpriteToDraw(image, ti->x + wdts->delta_x, ti->y + wdts->delta_y, wdts->width, wdts->height, wdts->unk, ti->z + wdts->delta_z); |
|
432 |
} |
|
433 |
} |
|
434 |
||
435 |
static void DrawTile_Water(TileInfo *ti) |
|
436 |
{ |
|
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
|
437 |
switch (GetWaterTileType(ti->tile)) { |
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
|
438 |
case WATER_CLEAR: |
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
|
439 |
DrawGroundSprite(SPR_FLAT_WATER_TILE); |
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
|
440 |
if (ti->z != 0) DrawCanalWater(ti->tile); |
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
|
441 |
break; |
0 | 442 |
|
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
|
443 |
case WATER_COAST: |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3491
diff
changeset
|
444 |
assert(!IsSteepSlope(ti->tileh)); |
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
|
445 |
DrawGroundSprite(_water_shore_sprites[ti->tileh]); |
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
|
446 |
break; |
0 | 447 |
|
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
|
448 |
case WATER_LOCK: { |
3425
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3423
diff
changeset
|
449 |
const WaterDrawTileStruct *t = _shiplift_display_seq[GetSection(ti->tile)]; |
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
|
450 |
DrawWaterStuff(ti, t, 0, ti->z > t[3].delta_y ? 24 : 0); |
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
|
451 |
} 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
|
452 |
|
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
|
453 |
case WATER_DEPOT: |
3425
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3423
diff
changeset
|
454 |
DrawWaterStuff(ti, _shipdepot_display_seq[GetSection(ti->tile)], PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)), 0); |
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
|
455 |
break; |
0 | 456 |
} |
457 |
} |
|
458 |
||
459 |
void DrawShipDepotSprite(int x, int y, int image) |
|
460 |
{ |
|
1399
4503bd2bfb82
(svn r1903) Replace some casts and macro magic with proper typing, similar to r1902
tron
parents:
1363
diff
changeset
|
461 |
const WaterDrawTileStruct *wdts = _shipdepot_display_seq[image]; |
0 | 462 |
|
1399
4503bd2bfb82
(svn r1903) Replace some casts and macro magic with proper typing, similar to r1902
tron
parents:
1363
diff
changeset
|
463 |
DrawSprite(wdts++->image, x, y); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
464 |
|
1399
4503bd2bfb82
(svn r1903) Replace some casts and macro magic with proper typing, similar to r1902
tron
parents:
1363
diff
changeset
|
465 |
for (; wdts->delta_x != 0x80; wdts++) { |
0 | 466 |
Point pt = RemapCoords(wdts->delta_x, wdts->delta_y, wdts->delta_z); |
467 |
DrawSprite(wdts->image + PLAYER_SPRITE_COLOR(_local_player), x + pt.x, y + pt.y); |
|
468 |
} |
|
469 |
} |
|
470 |
||
471 |
||
2537 | 472 |
static uint GetSlopeZ_Water(const TileInfo* ti) |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
473 |
{ |
2537 | 474 |
return GetPartialZ(ti->x & 0xF, ti->y & 0xF, ti->tileh) + ti->z; |
0 | 475 |
} |
476 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3491
diff
changeset
|
477 |
static Slope GetSlopeTileh_Water(TileIndex tile, Slope tileh) |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
478 |
{ |
3418
a592d40a4d04
(svn r4242) Pass TileIndex and slope to GetSlopeTileh_*() instead of TileInfo
tron
parents:
3402
diff
changeset
|
479 |
return tileh; |
39 | 480 |
} |
481 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
482 |
static void GetAcceptedCargo_Water(TileIndex tile, AcceptedCargo ac) |
0 | 483 |
{ |
484 |
/* not used */ |
|
485 |
} |
|
486 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
487 |
static void GetTileDesc_Water(TileIndex tile, TileDesc *td) |
0 | 488 |
{ |
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
|
489 |
switch (GetWaterTileType(tile)) { |
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
|
490 |
case WATER_CLEAR: |
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
|
491 |
if (TilePixelHeight(tile) == 0) { |
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
|
492 |
td->str = STR_3804_WATER; |
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
|
493 |
} else { |
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
|
494 |
td->str = STR_LANDINFO_CANAL; |
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
|
495 |
} |
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
|
496 |
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
|
497 |
case WATER_COAST: td->str = STR_3805_COAST_OR_RIVERBANK; 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
|
498 |
case WATER_LOCK : td->str = STR_LANDINFO_LOCK; 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
|
499 |
case WATER_DEPOT: td->str = STR_3806_SHIP_DEPOT; 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
|
500 |
default: assert(0); break; |
2951 | 501 |
} |
0 | 502 |
|
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
|
503 |
td->owner = GetTileOwner(tile); |
0 | 504 |
} |
505 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
506 |
static void AnimateTile_Water(TileIndex tile) |
0 | 507 |
{ |
508 |
/* not used */ |
|
509 |
} |
|
510 |
||
1075 | 511 |
static void TileLoopWaterHelper(TileIndex tile, const TileIndexDiffC *offs) |
0 | 512 |
{ |
1075 | 513 |
TileIndex target = TILE_ADD(tile, ToTileIndexDiff(offs[0])); |
0 | 514 |
|
515 |
// type of this tile mustn't be water already. |
|
2639 | 516 |
if (IsTileType(target, MP_WATER)) return; |
0 | 517 |
|
1075 | 518 |
if (TileHeight(TILE_ADD(tile, ToTileIndexDiff(offs[1]))) != 0 || |
2639 | 519 |
TileHeight(TILE_ADD(tile, ToTileIndexDiff(offs[2]))) != 0) { |
1075 | 520 |
return; |
2639 | 521 |
} |
1075 | 522 |
|
523 |
if (TileHeight(TILE_ADD(tile, ToTileIndexDiff(offs[3]))) != 0 || |
|
524 |
TileHeight(TILE_ADD(tile, ToTileIndexDiff(offs[4]))) != 0) { |
|
0 | 525 |
// make coast.. |
1214
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1209
diff
changeset
|
526 |
switch (GetTileType(target)) { |
1076
ee035f4a90e9
(svn r1577) Fix: [1103301] Railroad tracks on slopes weren't flooded
tron
parents:
1075
diff
changeset
|
527 |
case MP_RAILWAY: { |
3267
591027d10884
(svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents:
3234
diff
changeset
|
528 |
TrackBits tracks; |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3491
diff
changeset
|
529 |
Slope slope; |
3267
591027d10884
(svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents:
3234
diff
changeset
|
530 |
|
3275 | 531 |
if (!IsPlainRailTile(target)) break; |
3267
591027d10884
(svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents:
3234
diff
changeset
|
532 |
|
591027d10884
(svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents:
3234
diff
changeset
|
533 |
tracks = GetTrackBits(target); |
591027d10884
(svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents:
3234
diff
changeset
|
534 |
slope = GetTileSlope(target, NULL); |
1076
ee035f4a90e9
(svn r1577) Fix: [1103301] Railroad tracks on slopes weren't flooded
tron
parents:
1075
diff
changeset
|
535 |
if (!( |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3491
diff
changeset
|
536 |
(slope == SLOPE_W && tracks == TRACK_BIT_RIGHT) || |
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3491
diff
changeset
|
537 |
(slope == SLOPE_S && tracks == TRACK_BIT_UPPER) || |
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3491
diff
changeset
|
538 |
(slope == SLOPE_E && tracks == TRACK_BIT_LEFT) || |
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3491
diff
changeset
|
539 |
(slope == SLOPE_N && tracks == TRACK_BIT_LOWER) |
3267
591027d10884
(svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents:
3234
diff
changeset
|
540 |
)) { |
1076
ee035f4a90e9
(svn r1577) Fix: [1103301] Railroad tracks on slopes weren't flooded
tron
parents:
1075
diff
changeset
|
541 |
break; |
3267
591027d10884
(svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents:
3234
diff
changeset
|
542 |
} |
1076
ee035f4a90e9
(svn r1577) Fix: [1103301] Railroad tracks on slopes weren't flooded
tron
parents:
1075
diff
changeset
|
543 |
} |
ee035f4a90e9
(svn r1577) Fix: [1103301] Railroad tracks on slopes weren't flooded
tron
parents:
1075
diff
changeset
|
544 |
/* FALLTHROUGH */ |
ee035f4a90e9
(svn r1577) Fix: [1103301] Railroad tracks on slopes weren't flooded
tron
parents:
1075
diff
changeset
|
545 |
|
1075 | 546 |
case MP_CLEAR: |
547 |
case MP_TREES: |
|
548 |
_current_player = OWNER_WATER; |
|
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
|
549 |
if (!CmdFailed(DoCommand(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) { |
3111
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
3017
diff
changeset
|
550 |
MakeShore(target); |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
3017
diff
changeset
|
551 |
MarkTileDirtyByTile(target); |
1075 | 552 |
} |
553 |
break; |
|
554 |
||
3977
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
555 |
case MP_TUNNELBRIDGE: |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
556 |
if (IsBridge(target) && IsBridgeMiddle(target) && IsClearUnderBridge(target)) { |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
557 |
SetWaterUnderBridge(target); |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
558 |
MarkTileDirtyByTile(target); |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
559 |
} |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
560 |
break; |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
561 |
|
1075 | 562 |
default: |
563 |
break; |
|
0 | 564 |
} |
565 |
} else { |
|
3977
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
566 |
if (IsBridgeTile(target) && IsBridgeMiddle(target)) { |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
567 |
if (IsWaterUnderBridge(target) || |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
568 |
(IsTransportUnderBridge(target) && GetTransportTypeUnderBridge(target) == TRANSPORT_WATER)) { // XXX does this happen at all? |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
569 |
return; |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
570 |
} |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
571 |
SetWaterUnderBridge(target); |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
572 |
MarkTileDirtyByTile(target); |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
573 |
return; |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
574 |
} |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
575 |
|
0 | 576 |
_current_player = OWNER_WATER; |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
577 |
{ |
1605
c4630be67467
(svn r2109) -Fix: use FindVehicleOnTileZ(tile, 0) over FindVehicleBetween(tile, tile, 0)
truelight
parents:
1399
diff
changeset
|
578 |
Vehicle *v = FindVehicleOnTileZ(target, 0); |
1075 | 579 |
if (v != NULL) FloodVehicle(v); |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
580 |
} |
1075 | 581 |
|
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
|
582 |
if (!CmdFailed(DoCommand(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) { |
3111
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
3017
diff
changeset
|
583 |
MakeWater(target); |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
3017
diff
changeset
|
584 |
MarkTileDirtyByTile(target); |
1075 | 585 |
} |
0 | 586 |
} |
587 |
} |
|
588 |
||
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
589 |
static void FloodVehicle(Vehicle *v) |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
590 |
{ |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
591 |
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
|
592 |
uint16 pass = 0; |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
593 |
|
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
594 |
if (v->type == VEH_Road) { // flood bus/truck |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
595 |
pass = 1; // driver |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
596 |
if (v->cargo_type == CT_PASSENGERS) |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
597 |
pass += v->cargo_count; |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
598 |
|
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
599 |
v->vehstatus |= VS_CRASHED; |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
600 |
v->u.road.crashed_ctr = 2000; // max 2220, disappear pretty fast |
588 | 601 |
RebuildVehicleLists(); |
2549 | 602 |
} else if (v->type == VEH_Train) { |
603 |
Vehicle* u; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
604 |
|
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
605 |
v = GetFirstVehicleInChain(v); |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
606 |
u = v; |
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
2657
diff
changeset
|
607 |
if (IsFrontEngine(v)) pass = 4; // driver |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
608 |
|
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
609 |
// crash all wagons, and count passangers |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
610 |
BEGIN_ENUM_WAGONS(v) |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
611 |
if (v->cargo_type == CT_PASSENGERS) pass += v->cargo_count; |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
612 |
v->vehstatus |= VS_CRASHED; |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
613 |
END_ENUM_WAGONS(v) |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
614 |
|
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
615 |
v = u; |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
616 |
v->u.rail.crash_anim_pos = 4000; // max 4440, disappear pretty fast |
588 | 617 |
RebuildVehicleLists(); |
2549 | 618 |
} else { |
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
619 |
return; |
2549 | 620 |
} |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
621 |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
726
diff
changeset
|
622 |
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
623 |
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
624 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
625 |
SetDParam(0, pass); |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
626 |
AddNewsItem(STR_B006_FLOOD_VEHICLE_DESTROYED, |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
627 |
NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ACCIDENT, 0), |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
628 |
v->index, |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
629 |
0); |
2549 | 630 |
CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE); |
631 |
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
|
632 |
} |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
633 |
} |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
634 |
|
0 | 635 |
// called from tunnelbridge_cmd |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
636 |
void TileLoop_Water(TileIndex tile) |
0 | 637 |
{ |
909
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
900
diff
changeset
|
638 |
static const TileIndexDiffC _tile_loop_offs_array[][5] = { |
0 | 639 |
// tile to mod shore? shore? |
909
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
900
diff
changeset
|
640 |
{{-1, 0}, {0, 0}, {0, 1}, {-1, 0}, {-1, 1}}, |
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
900
diff
changeset
|
641 |
{{ 0, 1}, {0, 1}, {1, 1}, { 0, 2}, { 1, 2}}, |
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
900
diff
changeset
|
642 |
{{ 1, 0}, {1, 0}, {1, 1}, { 2, 0}, { 2, 1}}, |
81bc9ef93f50
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
900
diff
changeset
|
643 |
{{ 0, -1}, {0, 0}, {1, 0}, { 0, -1}, { 1, -1}} |
0 | 644 |
}; |
645 |
||
926
bd4312619522
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents:
909
diff
changeset
|
646 |
if (IS_INT_INSIDE(TileX(tile), 1, MapSizeX() - 3 + 1) && |
bd4312619522
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents:
909
diff
changeset
|
647 |
IS_INT_INSIDE(TileY(tile), 1, MapSizeY() - 3 + 1)) { |
2989 | 648 |
uint i; |
649 |
||
2639 | 650 |
for (i = 0; i != lengthof(_tile_loop_offs_array); i++) { |
0 | 651 |
TileLoopWaterHelper(tile, _tile_loop_offs_array[i]); |
2639 | 652 |
} |
0 | 653 |
} |
314 | 654 |
// _current_player can be changed by TileLoopWaterHelper.. reset it back |
655 |
// here |
|
656 |
_current_player = OWNER_NONE; |
|
43
3b93861c5478
(svn r44) Fix: Coast line near edge of map and near oilrigs (Dribbel)
dominik
parents:
39
diff
changeset
|
657 |
|
3b93861c5478
(svn r44) Fix: Coast line near edge of map and near oilrigs (Dribbel)
dominik
parents:
39
diff
changeset
|
658 |
// edges |
2951 | 659 |
if (TileX(tile) == 0 && IS_INT_INSIDE(TileY(tile), 1, MapSizeY() - 3 + 1)) { //NE |
43
3b93861c5478
(svn r44) Fix: Coast line near edge of map and near oilrigs (Dribbel)
dominik
parents:
39
diff
changeset
|
660 |
TileLoopWaterHelper(tile, _tile_loop_offs_array[2]); |
2951 | 661 |
} |
43
3b93861c5478
(svn r44) Fix: Coast line near edge of map and near oilrigs (Dribbel)
dominik
parents:
39
diff
changeset
|
662 |
|
2639 | 663 |
if (TileX(tile) == MapSizeX() - 2 && IS_INT_INSIDE(TileY(tile), 1, MapSizeY() - 3 + 1)) { //SW |
43
3b93861c5478
(svn r44) Fix: Coast line near edge of map and near oilrigs (Dribbel)
dominik
parents:
39
diff
changeset
|
664 |
TileLoopWaterHelper(tile, _tile_loop_offs_array[0]); |
2639 | 665 |
} |
43
3b93861c5478
(svn r44) Fix: Coast line near edge of map and near oilrigs (Dribbel)
dominik
parents:
39
diff
changeset
|
666 |
|
2639 | 667 |
if (TileY(tile) == 0 && IS_INT_INSIDE(TileX(tile), 1, MapSizeX() - 3 + 1)) { //NW |
43
3b93861c5478
(svn r44) Fix: Coast line near edge of map and near oilrigs (Dribbel)
dominik
parents:
39
diff
changeset
|
668 |
TileLoopWaterHelper(tile, _tile_loop_offs_array[1]); |
2639 | 669 |
} |
43
3b93861c5478
(svn r44) Fix: Coast line near edge of map and near oilrigs (Dribbel)
dominik
parents:
39
diff
changeset
|
670 |
|
2639 | 671 |
if (TileY(tile) == MapSizeY() - 2 && IS_INT_INSIDE(TileX(tile), 1, MapSizeX() - 3 + 1)) { //SE |
43
3b93861c5478
(svn r44) Fix: Coast line near edge of map and near oilrigs (Dribbel)
dominik
parents:
39
diff
changeset
|
672 |
TileLoopWaterHelper(tile, _tile_loop_offs_array[3]); |
2639 | 673 |
} |
0 | 674 |
} |
675 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
676 |
static uint32 GetTileTrackStatus_Water(TileIndex tile, TransportType mode) |
0 | 677 |
{ |
3423
03e0e97abf41
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3422
diff
changeset
|
678 |
static const byte coast_tracks[] = {0, 32, 4, 0, 16, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0}; |
03e0e97abf41
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3422
diff
changeset
|
679 |
static const byte water_tracks_by_axis[] = {1, 2}; |
3900
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
680 |
uint32 ts; |
2951 | 681 |
if (mode != TRANSPORT_WATER) return 0; |
0 | 682 |
|
3423
03e0e97abf41
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3422
diff
changeset
|
683 |
switch (GetWaterTileType(tile)) { |
3900
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
684 |
case WATER_CLEAR: ts = 0x3F; break;/* We can go everywhere */ |
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
685 |
case WATER_COAST: ts = coast_tracks[GetTileSlope(tile, NULL) & 0xF]; break; |
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
686 |
case WATER_LOCK: ts = water_tracks_by_axis[DiagDirToAxis(GetLockDirection(tile))]; break; |
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
687 |
case WATER_DEPOT: ts = water_tracks_by_axis[GetShipDepotAxis(tile)]; break; |
3423
03e0e97abf41
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3422
diff
changeset
|
688 |
default: return 0; |
0 | 689 |
} |
3900
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
690 |
if (TileX(tile) == 0) { |
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
691 |
// NE border: remove tracks that connects NE tile edge |
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
692 |
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
|
693 |
} |
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
694 |
if (TileY(tile) == 0) { |
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
695 |
// NW border: remove tracks that connects NW tile edge |
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
696 |
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
|
697 |
} |
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
698 |
return ts * 0x101; |
0 | 699 |
} |
700 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
701 |
extern void ShowShipDepotWindow(TileIndex tile); |
0 | 702 |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
703 |
static void ClickTile_Water(TileIndex tile) |
0 | 704 |
{ |
3423
03e0e97abf41
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3422
diff
changeset
|
705 |
if (GetWaterTileType(tile) == WATER_DEPOT) { |
03e0e97abf41
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3422
diff
changeset
|
706 |
TileIndex tile2 = GetOtherShipDepotTile(tile); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
707 |
|
3423
03e0e97abf41
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3422
diff
changeset
|
708 |
ShowShipDepotWindow(tile < tile2 ? tile : tile2); |
0 | 709 |
} |
710 |
} |
|
711 |
||
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
|
712 |
static void ChangeTileOwner_Water(TileIndex tile, PlayerID old_player, PlayerID new_player) |
0 | 713 |
{ |
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
|
714 |
if (!IsTileOwner(tile, old_player)) return; |
0 | 715 |
|
2502 | 716 |
if (new_player != OWNER_SPECTATOR) { |
1902 | 717 |
SetTileOwner(tile, new_player); |
0 | 718 |
} else { |
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
|
719 |
DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); |
0 | 720 |
} |
721 |
} |
|
722 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
723 |
static uint32 VehicleEnter_Water(Vehicle *v, TileIndex tile, int x, int y) |
0 | 724 |
{ |
725 |
return 0; |
|
726 |
} |
|
727 |
||
728 |
||
729 |
const TileTypeProcs _tile_type_water_procs = { |
|
730 |
DrawTile_Water, /* draw_tile_proc */ |
|
731 |
GetSlopeZ_Water, /* get_slope_z_proc */ |
|
732 |
ClearTile_Water, /* clear_tile_proc */ |
|
733 |
GetAcceptedCargo_Water, /* get_accepted_cargo_proc */ |
|
734 |
GetTileDesc_Water, /* get_tile_desc_proc */ |
|
735 |
GetTileTrackStatus_Water, /* get_tile_track_status_proc */ |
|
736 |
ClickTile_Water, /* click_tile_proc */ |
|
737 |
AnimateTile_Water, /* animate_tile_proc */ |
|
738 |
TileLoop_Water, /* tile_loop_clear */ |
|
739 |
ChangeTileOwner_Water, /* change_tile_owner_clear */ |
|
740 |
NULL, /* get_produced_cargo_proc */ |
|
741 |
VehicleEnter_Water, /* vehicle_enter_tile_proc */ |
|
39 | 742 |
GetSlopeTileh_Water, /* get_slope_tileh_proc */ |
0 | 743 |
}; |