author | rubidium |
Wed, 07 May 2008 21:45:27 +0000 | |
changeset 10457 | ea18877d8eba |
parent 10429 | 1b99254f9607 |
child 10546 | 07ab34af246e |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
10429
1b99254f9607
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
10316
diff
changeset
|
3 |
/** @file water_cmd.cpp Handling of water tiles. */ |
6928
44797333bcbf
(svn r9568) -Documentation: doxygen and comment changes: Root of src is finally done. Now, time to start clearing as much as possible
belugas
parents:
6923
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" |
8615
6b91ca653bad
(svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
8612
diff
changeset
|
11 |
#include "tile_cmd.h" |
6949
72d11a1e1e60
(svn r9609) -Codechange: Move some function prototypes out of functions.h and into landscape.h, and add a few where they didn't exist.
maedhros
parents:
6928
diff
changeset
|
12 |
#include "landscape.h" |
8720
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8707
diff
changeset
|
13 |
#include "viewport_func.h" |
8612
6414fc21c2f3
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
8610
diff
changeset
|
14 |
#include "command_func.h" |
0 | 15 |
#include "town.h" |
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
9180
diff
changeset
|
16 |
#include "news_func.h" |
10222
b6919c94cc77
(svn r12754) -Codechange: split depot.h into depot_map.h, depot_func.h and depot_base.h and remove quite a lot of unneeded (before this) includes of depot.h.
rubidium
parents:
9302
diff
changeset
|
17 |
#include "depot_base.h" |
b6919c94cc77
(svn r12754) -Codechange: split depot.h into depot_map.h, depot_func.h and depot_base.h and remove quite a lot of unneeded (before this) includes of depot.h.
rubidium
parents:
9302
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" |
7353
716c6dd9322a
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
7179
diff
changeset
|
21 |
#include "roadveh.h" |
8604
8afdd9877afd
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents:
8601
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" |
8003
bd88e365c18a
(svn r11022) -Fix: the canal border determination did not take oil rigs into consideration.
rubidium
parents:
7993
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" |
7079
35743c461482
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6987
diff
changeset
|
26 |
#include "newgrf_canal.h" |
8345
6caa3fdb972c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
8293
diff
changeset
|
27 |
#include "transparency.h" |
8610
17cc343a23dd
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8604
diff
changeset
|
28 |
#include "strings_func.h" |
8627
448ebf3a8291
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8615
diff
changeset
|
29 |
#include "functions.h" |
448ebf3a8291
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8615
diff
changeset
|
30 |
#include "window_func.h" |
8640
1e93b81e96d2
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents:
8635
diff
changeset
|
31 |
#include "vehicle_func.h" |
8653
a83f7a536919
(svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium
parents:
8640
diff
changeset
|
32 |
#include "sound_func.h" |
8707
55835d8fbfcd
(svn r11774) -Change: do not include variables.h in a header when it is not needed.
rubidium
parents:
8660
diff
changeset
|
33 |
#include "variables.h" |
8750
fdd6054e7bae
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8733
diff
changeset
|
34 |
#include "player_func.h" |
8766
c86cfa3a7580
(svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents:
8760
diff
changeset
|
35 |
#include "settings_type.h" |
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
36 |
#include "clear_map.h" |
8955 | 37 |
#include "tree_map.h" |
9281
d8cd9ac52a68
(svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
9259
diff
changeset
|
38 |
#include "station_base.h" |
d8cd9ac52a68
(svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
9259
diff
changeset
|
39 |
#include "airport.h" |
9283
624272490f5a
(svn r12495) -Codechange: reduce the dependency on newgrf_station.h (especially because newgrf_station.h includes a lot of stuff).
rubidium
parents:
9281
diff
changeset
|
40 |
#include "newgrf_cargo.h" |
10272
2014f0bdc800
(svn r12804) -Codechange: move the effect vehicle handling out of vehicle.cpp
rubidium
parents:
10222
diff
changeset
|
41 |
#include "effectvehicle_func.h" |
10316
6878402fa6e5
(svn r12857) -Fix [FS#1948]: remove the last uses of AutoPtr in the station code.
rubidium
parents:
10314
diff
changeset
|
42 |
#include "oldpool_func.h" |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
43 |
|
8760
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
44 |
#include "table/sprites.h" |
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
45 |
#include "table/strings.h" |
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2186
diff
changeset
|
46 |
|
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
47 |
/** |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
48 |
* Describes the behaviour of a tile during flooding. |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
49 |
*/ |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
50 |
enum FloodingBehaviour { |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
51 |
FLOOD_NONE, ///< The tile does not flood neighboured tiles. |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
52 |
FLOOD_ACTIVE, ///< The tile floods neighboured tiles. |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
53 |
FLOOD_PASSIVE, ///< The tile does not actively flood neighboured tiles, but it prevents them from drying up. |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
54 |
FLOOD_DRYUP, ///< The tile drys up if it is not constantly flooded from neighboured tiles. |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
55 |
}; |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
56 |
|
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
57 |
/** |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
58 |
* Describes from which directions a specific slope can be flooded (if the tile is floodable at all). |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
59 |
*/ |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
60 |
static const uint8 _flood_from_dirs[] = { |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
61 |
(1 << DIR_NW) | (1 << DIR_SW) | (1 << DIR_SE) | (1 << DIR_NE), // SLOPE_FLAT |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
62 |
(1 << DIR_NE) | (1 << DIR_SE), // SLOPE_W |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
63 |
(1 << DIR_NW) | (1 << DIR_NE), // SLOPE_S |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
64 |
(1 << DIR_NE), // SLOPE_SW |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
65 |
(1 << DIR_NW) | (1 << DIR_SW), // SLOPE_E |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
66 |
0, // SLOPE_EW |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
67 |
(1 << DIR_NW), // SLOPE_SE |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
68 |
(1 << DIR_N ) | (1 << DIR_NW) | (1 << DIR_NE), // SLOPE_WSE, SLOPE_STEEP_S |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
69 |
(1 << DIR_SW) | (1 << DIR_SE), // SLOPE_N |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
70 |
(1 << DIR_SE), // SLOPE_NW |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
71 |
0, // SLOPE_NS |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
72 |
(1 << DIR_E ) | (1 << DIR_NE) | (1 << DIR_SE), // SLOPE_NWS, SLOPE_STEEP_W |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
73 |
(1 << DIR_SW), // SLOPE_NE |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
74 |
(1 << DIR_S ) | (1 << DIR_SW) | (1 << DIR_SE), // SLOPE_ENW, SLOPE_STEEP_N |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
75 |
(1 << DIR_W ) | (1 << DIR_SW) | (1 << DIR_NW), // SLOPE_SEN, SLOPE_STEEP_E |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
76 |
}; |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
77 |
|
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
78 |
/** |
8939
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
79 |
* Marks tile dirty if it is a canal or river tile. |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
80 |
* Called to avoid glitches when flooding tiles next to canal tile. |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
81 |
* |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
82 |
* @param tile tile to check |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
83 |
*/ |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
84 |
static inline void MarkTileDirtyIfCanalOrRiver(TileIndex tile) |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
85 |
{ |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
86 |
if (IsTileType(tile, MP_WATER) && (IsCanal(tile) || IsRiver(tile))) MarkTileDirtyByTile(tile); |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
87 |
} |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
88 |
|
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
89 |
/** |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
90 |
* Marks the tiles around a tile as dirty, if they are canals or rivers. |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
91 |
* |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
92 |
* @param tile The center of the tile where all other tiles are marked as dirty |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
93 |
* @ingroup dirty |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
94 |
*/ |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
95 |
static void MarkCanalsAndRiversAroundDirty(TileIndex tile) |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
96 |
{ |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
97 |
for (Direction dir = DIR_BEGIN; dir < DIR_END; dir++) { |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
98 |
MarkTileDirtyIfCanalOrRiver(tile + TileOffsByDir(dir)); |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
99 |
} |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
100 |
} |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
101 |
|
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
102 |
/** |
8444
9317090e9c8c
(svn r11504) -Fix [FS#1467]: removing docks/ship depots could result in non-canal water where canals should have been build.
rubidium
parents:
8424
diff
changeset
|
103 |
* Makes a tile canal or water depending on the surroundings. |
8991
072c784ccb82
(svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch
parents:
8967
diff
changeset
|
104 |
* |
072c784ccb82
(svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch
parents:
8967
diff
changeset
|
105 |
* Must only be used for converting old savegames. Use WaterClass now. |
072c784ccb82
(svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch
parents:
8967
diff
changeset
|
106 |
* |
8444
9317090e9c8c
(svn r11504) -Fix [FS#1467]: removing docks/ship depots could result in non-canal water where canals should have been build.
rubidium
parents:
8424
diff
changeset
|
107 |
* This as for example docks and shipdepots do not store |
9317090e9c8c
(svn r11504) -Fix [FS#1467]: removing docks/ship depots could result in non-canal water where canals should have been build.
rubidium
parents:
8424
diff
changeset
|
108 |
* whether the tile used to be canal or 'normal' water. |
9317090e9c8c
(svn r11504) -Fix [FS#1467]: removing docks/ship depots could result in non-canal water where canals should have been build.
rubidium
parents:
8424
diff
changeset
|
109 |
* @param t the tile to change. |
9317090e9c8c
(svn r11504) -Fix [FS#1467]: removing docks/ship depots could result in non-canal water where canals should have been build.
rubidium
parents:
8424
diff
changeset
|
110 |
* @param o the owner of the new tile. |
9317090e9c8c
(svn r11504) -Fix [FS#1467]: removing docks/ship depots could result in non-canal water where canals should have been build.
rubidium
parents:
8424
diff
changeset
|
111 |
*/ |
8967
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
112 |
void SetWaterClassDependingOnSurroundings(TileIndex t) |
8444
9317090e9c8c
(svn r11504) -Fix [FS#1467]: removing docks/ship depots could result in non-canal water where canals should have been build.
rubidium
parents:
8424
diff
changeset
|
113 |
{ |
9317090e9c8c
(svn r11504) -Fix [FS#1467]: removing docks/ship depots could result in non-canal water where canals should have been build.
rubidium
parents:
8424
diff
changeset
|
114 |
assert(GetTileSlope(t, NULL) == SLOPE_FLAT); |
9317090e9c8c
(svn r11504) -Fix [FS#1467]: removing docks/ship depots could result in non-canal water where canals should have been build.
rubidium
parents:
8424
diff
changeset
|
115 |
|
8518
08fc9e9bbddd
(svn r11582) -Fix: tiles were not marked dirty in some cases when removing a lock
smatz
parents:
8510
diff
changeset
|
116 |
/* Mark tile dirty in all cases */ |
08fc9e9bbddd
(svn r11582) -Fix: tiles were not marked dirty in some cases when removing a lock
smatz
parents:
8510
diff
changeset
|
117 |
MarkTileDirtyByTile(t); |
08fc9e9bbddd
(svn r11582) -Fix: tiles were not marked dirty in some cases when removing a lock
smatz
parents:
8510
diff
changeset
|
118 |
|
9022
6a009a1106fd
(svn r12101) -Fix (r12100): there are void tiles at MapMaxX,Y - have to substract one to be on water border tiles
smatz
parents:
9021
diff
changeset
|
119 |
if (TileX(t) == 0 || TileY(t) == 0 || TileX(t) == MapMaxX() - 1 || TileY(t) == MapMaxY() - 1) { |
9021
6cacfba4ef5e
(svn r12100) -Fix (r12042): check for water class of surrounding tiles fails for buoys at map borders
smatz
parents:
9016
diff
changeset
|
120 |
/* tiles at map borders are always WATER_CLASS_SEA */ |
6cacfba4ef5e
(svn r12100) -Fix (r12042): check for water class of surrounding tiles fails for buoys at map borders
smatz
parents:
9016
diff
changeset
|
121 |
SetWaterClass(t, WATER_CLASS_SEA); |
6cacfba4ef5e
(svn r12100) -Fix (r12042): check for water class of surrounding tiles fails for buoys at map borders
smatz
parents:
9016
diff
changeset
|
122 |
return; |
6cacfba4ef5e
(svn r12100) -Fix (r12042): check for water class of surrounding tiles fails for buoys at map borders
smatz
parents:
9016
diff
changeset
|
123 |
} |
6cacfba4ef5e
(svn r12100) -Fix (r12042): check for water class of surrounding tiles fails for buoys at map borders
smatz
parents:
9016
diff
changeset
|
124 |
|
8444
9317090e9c8c
(svn r11504) -Fix [FS#1467]: removing docks/ship depots could result in non-canal water where canals should have been build.
rubidium
parents:
8424
diff
changeset
|
125 |
bool has_water = false; |
9317090e9c8c
(svn r11504) -Fix [FS#1467]: removing docks/ship depots could result in non-canal water where canals should have been build.
rubidium
parents:
8424
diff
changeset
|
126 |
bool has_canal = false; |
8967
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
127 |
bool has_river = false; |
8444
9317090e9c8c
(svn r11504) -Fix [FS#1467]: removing docks/ship depots could result in non-canal water where canals should have been build.
rubidium
parents:
8424
diff
changeset
|
128 |
|
9317090e9c8c
(svn r11504) -Fix [FS#1467]: removing docks/ship depots could result in non-canal water where canals should have been build.
rubidium
parents:
8424
diff
changeset
|
129 |
for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) { |
9317090e9c8c
(svn r11504) -Fix [FS#1467]: removing docks/ship depots could result in non-canal water where canals should have been build.
rubidium
parents:
8424
diff
changeset
|
130 |
TileIndex neighbour = TileAddByDiagDir(t, dir); |
8910
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
131 |
switch (GetTileType(neighbour)) { |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
132 |
case MP_WATER: |
8991
072c784ccb82
(svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch
parents:
8967
diff
changeset
|
133 |
/* clear water and shipdepots have already a WaterClass associated */ |
072c784ccb82
(svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch
parents:
8967
diff
changeset
|
134 |
if (IsCoast(neighbour)) { |
072c784ccb82
(svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch
parents:
8967
diff
changeset
|
135 |
has_water = true; |
072c784ccb82
(svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch
parents:
8967
diff
changeset
|
136 |
} else if (!IsLock(neighbour)) { |
072c784ccb82
(svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch
parents:
8967
diff
changeset
|
137 |
switch (GetWaterClass(neighbour)) { |
072c784ccb82
(svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch
parents:
8967
diff
changeset
|
138 |
case WATER_CLASS_SEA: has_water = true; break; |
072c784ccb82
(svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch
parents:
8967
diff
changeset
|
139 |
case WATER_CLASS_CANAL: has_canal = true; break; |
072c784ccb82
(svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch
parents:
8967
diff
changeset
|
140 |
case WATER_CLASS_RIVER: has_river = true; break; |
072c784ccb82
(svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch
parents:
8967
diff
changeset
|
141 |
default: NOT_REACHED(); |
072c784ccb82
(svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch
parents:
8967
diff
changeset
|
142 |
} |
072c784ccb82
(svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch
parents:
8967
diff
changeset
|
143 |
} |
8910
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
144 |
break; |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
145 |
|
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
146 |
case MP_RAILWAY: |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
147 |
/* Shore or flooded halftile */ |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
148 |
has_water |= (GetRailGroundType(neighbour) == RAIL_GROUND_WATER); |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
149 |
break; |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
150 |
|
8955 | 151 |
case MP_TREES: |
152 |
/* trees on shore */ |
|
153 |
has_water |= (GetTreeGround(neighbour) == TREE_GROUND_SHORE); |
|
154 |
break; |
|
155 |
||
8910
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
156 |
default: break; |
8444
9317090e9c8c
(svn r11504) -Fix [FS#1467]: removing docks/ship depots could result in non-canal water where canals should have been build.
rubidium
parents:
8424
diff
changeset
|
157 |
} |
9317090e9c8c
(svn r11504) -Fix [FS#1467]: removing docks/ship depots could result in non-canal water where canals should have been build.
rubidium
parents:
8424
diff
changeset
|
158 |
} |
8967
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
159 |
|
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
160 |
if (has_river && !has_canal) { |
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
161 |
SetWaterClass(t, WATER_CLASS_RIVER); |
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
162 |
} else if (has_canal || !has_water) { |
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
163 |
SetWaterClass(t, WATER_CLASS_CANAL); |
8444
9317090e9c8c
(svn r11504) -Fix [FS#1467]: removing docks/ship depots could result in non-canal water where canals should have been build.
rubidium
parents:
8424
diff
changeset
|
164 |
} else { |
8967
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
165 |
SetWaterClass(t, WATER_CLASS_SEA); |
8444
9317090e9c8c
(svn r11504) -Fix [FS#1467]: removing docks/ship depots could result in non-canal water where canals should have been build.
rubidium
parents:
8424
diff
changeset
|
166 |
} |
9317090e9c8c
(svn r11504) -Fix [FS#1467]: removing docks/ship depots could result in non-canal water where canals should have been build.
rubidium
parents:
8424
diff
changeset
|
167 |
} |
9317090e9c8c
(svn r11504) -Fix [FS#1467]: removing docks/ship depots could result in non-canal water where canals should have been build.
rubidium
parents:
8424
diff
changeset
|
168 |
|
9317090e9c8c
(svn r11504) -Fix [FS#1467]: removing docks/ship depots could result in non-canal water where canals should have been build.
rubidium
parents:
8424
diff
changeset
|
169 |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1752
diff
changeset
|
170 |
/** 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
|
171 |
* @param tile tile where ship depot is built |
6928
44797333bcbf
(svn r9568) -Documentation: doxygen and comment changes: Root of src is finally done. Now, time to start clearing as much as possible
belugas
parents:
6923
diff
changeset
|
172 |
* @param flags type of operation |
6460 | 173 |
* @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
|
174 |
* @param p2 unused |
0 | 175 |
*/ |
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7402
diff
changeset
|
176 |
CommandCost CmdBuildShipDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 177 |
{ |
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
|
178 |
TileIndex tile2; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
179 |
|
8726
5ae45b46506b
(svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium
parents:
8720
diff
changeset
|
180 |
CommandCost ret; |
0 | 181 |
|
6460 | 182 |
Axis axis = Extract<Axis, 0>(p1); |
183 |
||
184 |
tile2 = tile + (axis == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1)); |
|
0 | 185 |
|
8967
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
186 |
if (!IsWaterTile(tile) || !IsWaterTile(tile2)) { |
0 | 187 |
return_cmd_error(STR_3801_MUST_BE_BUILT_ON_WATER); |
8967
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
188 |
} |
0 | 189 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5210
diff
changeset
|
190 |
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
|
191 |
|
8967
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
192 |
if (GetTileSlope(tile, NULL) != SLOPE_FLAT || GetTileSlope(tile2, NULL) != SLOPE_FLAT) { |
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
193 |
/* Prevent depots on rapids */ |
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
194 |
return_cmd_error(STR_0239_SITE_UNSUITABLE); |
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
195 |
} |
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
196 |
|
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
197 |
WaterClass wc1 = GetWaterClass(tile); |
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
198 |
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
|
199 |
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
|
200 |
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
|
201 |
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
|
202 |
if (CmdFailed(ret)) return CMD_ERROR; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
203 |
|
10314
9cfcdd5b5ddb
(svn r12855) -Codechange: do not use autoptr's for testing whether certain objects can be build, but check it directly in the pool so we do not have to call destructors in the testing phase. Stations still use the autoptr though.
rubidium
parents:
10272
diff
changeset
|
204 |
if (!Depot::CanAllocateItem()) return CMD_ERROR; |
0 | 205 |
|
206 |
if (flags & DC_EXEC) { |
|
10314
9cfcdd5b5ddb
(svn r12855) -Codechange: do not use autoptr's for testing whether certain objects can be build, but check it directly in the pool so we do not have to call destructors in the testing phase. Stations still use the autoptr though.
rubidium
parents:
10272
diff
changeset
|
207 |
Depot *depot = new Depot(tile); |
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1214
diff
changeset
|
208 |
depot->town_index = ClosestTownFromTile(tile, (uint)-1)->index; |
0 | 209 |
|
8991
072c784ccb82
(svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch
parents:
8967
diff
changeset
|
210 |
MakeShipDepot(tile, _current_player, DEPOT_NORTH, axis, wc1); |
072c784ccb82
(svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch
parents:
8967
diff
changeset
|
211 |
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
|
212 |
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
|
213 |
MarkTileDirtyByTile(tile2); |
0 | 214 |
} |
215 |
||
8726
5ae45b46506b
(svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium
parents:
8720
diff
changeset
|
216 |
return CommandCost(EXPENSES_CONSTRUCTION, _price.build_ship_depot); |
0 | 217 |
} |
218 |
||
8967
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
219 |
void MakeWaterKeepingClass(TileIndex tile, Owner o) |
8525
9d0a7c52e3ed
(svn r11589) -Fix [FS#1514]: when ship depots got destroyed they always returned to water, even when it should've been canals.
rubidium
parents:
8518
diff
changeset
|
220 |
{ |
8967
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
221 |
assert(IsTileType(tile, MP_WATER) || (IsTileType(tile, MP_STATION) && (IsBuoy(tile) || IsDock(tile)))); |
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
222 |
|
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
223 |
switch (GetWaterClass(tile)) { |
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
224 |
case WATER_CLASS_SEA: MakeWater(tile); break; |
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
225 |
case WATER_CLASS_CANAL: MakeCanal(tile, o, Random()); break; |
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
226 |
case WATER_CLASS_RIVER: MakeRiver(tile, Random()); break; |
8525
9d0a7c52e3ed
(svn r11589) -Fix [FS#1514]: when ship depots got destroyed they always returned to water, even when it should've been canals.
rubidium
parents:
8518
diff
changeset
|
227 |
} |
9d0a7c52e3ed
(svn r11589) -Fix [FS#1514]: when ship depots got destroyed they always returned to water, even when it should've been canals.
rubidium
parents:
8518
diff
changeset
|
228 |
} |
9d0a7c52e3ed
(svn r11589) -Fix [FS#1514]: when ship depots got destroyed they always returned to water, even when it should've been canals.
rubidium
parents:
8518
diff
changeset
|
229 |
|
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7402
diff
changeset
|
230 |
static CommandCost RemoveShipDepot(TileIndex tile, uint32 flags) |
0 | 231 |
{ |
3373
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
232 |
if (!IsShipDepot(tile)) return CMD_ERROR; |
2951 | 233 |
if (!CheckTileOwnership(tile)) return CMD_ERROR; |
0 | 234 |
|
9016
2b722bde93ec
(svn r12095) -Fix [FS#1703]: when a company bankrupts, remove drive-through road stops, ship depots and buoys too. Update owners of water and road.
smatz
parents:
9015
diff
changeset
|
235 |
TileIndex tile2 = GetOtherShipDepotTile(tile); |
0 | 236 |
|
9016
2b722bde93ec
(svn r12095) -Fix [FS#1703]: when a company bankrupts, remove drive-through road stops, ship depots and buoys too. Update owners of water and road.
smatz
parents:
9015
diff
changeset
|
237 |
/* do not check for ship on tile when company goes bankrupt */ |
2b722bde93ec
(svn r12095) -Fix [FS#1703]: when a company bankrupts, remove drive-through road stops, ship depots and buoys too. Update owners of water and road.
smatz
parents:
9015
diff
changeset
|
238 |
if (!(flags & DC_BANKRUPT)) { |
2b722bde93ec
(svn r12095) -Fix [FS#1703]: when a company bankrupts, remove drive-through road stops, ship depots and buoys too. Update owners of water and road.
smatz
parents:
9015
diff
changeset
|
239 |
if (!EnsureNoVehicleOnGround(tile) || !EnsureNoVehicleOnGround(tile2)) return CMD_ERROR; |
2b722bde93ec
(svn r12095) -Fix [FS#1703]: when a company bankrupts, remove drive-through road stops, ship depots and buoys too. Update owners of water and road.
smatz
parents:
9015
diff
changeset
|
240 |
} |
0 | 241 |
|
242 |
if (flags & DC_EXEC) { |
|
3373
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
243 |
/* Kill the depot, which is registered at the northernmost tile. Use that one */ |
7885
4eb9b01e37ff
(svn r10758) -Codechange: make the depot struct use the pool item class as super class.
rubidium
parents:
7831
diff
changeset
|
244 |
delete GetDepotByTile(tile2 < tile ? tile2 : tile); |
0 | 245 |
|
8991
072c784ccb82
(svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch
parents:
8967
diff
changeset
|
246 |
MakeWaterKeepingClass(tile, GetTileOwner(tile)); |
072c784ccb82
(svn r12070) -Cleanup(r12042): Water-owner of shipdepots is no longer needed. Removed.
frosch
parents:
8967
diff
changeset
|
247 |
MakeWaterKeepingClass(tile2, GetTileOwner(tile2)); |
3111
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
3017
diff
changeset
|
248 |
MarkTileDirtyByTile(tile); |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
3017
diff
changeset
|
249 |
MarkTileDirtyByTile(tile2); |
0 | 250 |
} |
251 |
||
8726
5ae45b46506b
(svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium
parents:
8720
diff
changeset
|
252 |
return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_ship_depot); |
0 | 253 |
} |
254 |
||
6928
44797333bcbf
(svn r9568) -Documentation: doxygen and comment changes: Root of src is finally done. Now, time to start clearing as much as possible
belugas
parents:
6923
diff
changeset
|
255 |
/** build a shiplift */ |
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7402
diff
changeset
|
256 |
static CommandCost DoBuildShiplift(TileIndex tile, DiagDirection dir, uint32 flags) |
0 | 257 |
{ |
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7402
diff
changeset
|
258 |
CommandCost ret; |
0 | 259 |
int delta; |
260 |
||
6928
44797333bcbf
(svn r9568) -Documentation: doxygen and comment changes: Root of src is finally done. Now, time to start clearing as much as possible
belugas
parents:
6923
diff
changeset
|
261 |
/* 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
|
262 |
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
|
263 |
if (CmdFailed(ret)) return CMD_ERROR; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
264 |
|
4559
c853d2440065
(svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents:
4434
diff
changeset
|
265 |
delta = TileOffsByDiagDir(dir); |
6928
44797333bcbf
(svn r9568) -Documentation: doxygen and comment changes: Root of src is finally done. Now, time to start clearing as much as possible
belugas
parents:
6923
diff
changeset
|
266 |
/* lower tile */ |
8967
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
267 |
WaterClass wc_lower = IsWaterTile(tile - delta) ? GetWaterClass(tile - delta) : WATER_CLASS_CANAL; |
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
268 |
|
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
|
269 |
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
|
270 |
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
|
271 |
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
|
272 |
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
|
273 |
} |
0 | 274 |
|
6928
44797333bcbf
(svn r9568) -Documentation: doxygen and comment changes: Root of src is finally done. Now, time to start clearing as much as possible
belugas
parents:
6923
diff
changeset
|
275 |
/* upper tile */ |
8967
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
276 |
WaterClass wc_upper = IsWaterTile(tile + delta) ? GetWaterClass(tile + delta) : WATER_CLASS_CANAL; |
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
277 |
|
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
|
278 |
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
|
279 |
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
|
280 |
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
|
281 |
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
|
282 |
} |
0 | 283 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5210
diff
changeset
|
284 |
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
|
285 |
(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
|
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 |
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
|
288 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5210
diff
changeset
|
289 |
|
0 | 290 |
if (flags & DC_EXEC) { |
8967
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
291 |
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
|
292 |
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
|
293 |
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
|
294 |
MarkTileDirtyByTile(tile + delta); |
8939
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
295 |
MarkCanalsAndRiversAroundDirty(tile - delta); |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
296 |
MarkCanalsAndRiversAroundDirty(tile + delta); |
0 | 297 |
} |
298 |
||
8726
5ae45b46506b
(svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium
parents:
8720
diff
changeset
|
299 |
return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_water * 22 >> 3); |
0 | 300 |
} |
301 |
||
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7402
diff
changeset
|
302 |
static CommandCost RemoveShiplift(TileIndex tile, uint32 flags) |
0 | 303 |
{ |
4559
c853d2440065
(svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents:
4434
diff
changeset
|
304 |
TileIndexDiff delta = TileOffsByDiagDir(GetLockDirection(tile)); |
0 | 305 |
|
7766
b4a38a2be0d3
(svn r10593) -Fix [FS#1038]: one could not remove locks that were build in a (very) old version of OpenTTD.
rubidium
parents:
7762
diff
changeset
|
306 |
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
|
307 |
|
6928
44797333bcbf
(svn r9568) -Documentation: doxygen and comment changes: Root of src is finally done. Now, time to start clearing as much as possible
belugas
parents:
6923
diff
changeset
|
308 |
/* make sure no vehicle is on the tile. */ |
8254
5de2bbd26163
(svn r11303) -Fix: EnsureNoVehicle and EnsureNoVehicleOnGround were both used to check whether there was no vehicle on the ground, except that the former didn't take care of aircraft shadows. So now we only use EnsureNoVehicleOnGround.
rubidium
parents:
8235
diff
changeset
|
309 |
if (!EnsureNoVehicleOnGround(tile) || !EnsureNoVehicleOnGround(tile + delta) || !EnsureNoVehicleOnGround(tile - delta)) |
0 | 310 |
return CMD_ERROR; |
311 |
||
312 |
if (flags & DC_EXEC) { |
|
313 |
DoClearSquare(tile); |
|
8967
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
314 |
MakeWaterKeepingClass(tile + delta, GetTileOwner(tile)); |
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
315 |
MakeWaterKeepingClass(tile - delta, GetTileOwner(tile)); |
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
316 |
MarkTileDirtyByTile(tile - delta); |
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
317 |
MarkTileDirtyByTile(tile + delta); |
8939
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
318 |
MarkCanalsAndRiversAroundDirty(tile - delta); |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
319 |
MarkCanalsAndRiversAroundDirty(tile + delta); |
0 | 320 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
321 |
|
8726
5ae45b46506b
(svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium
parents:
8720
diff
changeset
|
322 |
return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_water * 2); |
0 | 323 |
} |
324 |
||
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
|
325 |
/** 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
|
326 |
* @param tile tile where to place the lock |
6928
44797333bcbf
(svn r9568) -Documentation: doxygen and comment changes: Root of src is finally done. Now, time to start clearing as much as possible
belugas
parents:
6923
diff
changeset
|
327 |
* @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
|
328 |
* @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
|
329 |
* @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
|
330 |
*/ |
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7402
diff
changeset
|
331 |
CommandCost CmdBuildLock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 332 |
{ |
8909
fa15e9afad2f
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8882
diff
changeset
|
333 |
DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile, NULL)); |
fa15e9afad2f
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8882
diff
changeset
|
334 |
if (dir == INVALID_DIAGDIR) return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
8882
f54bd3d64027
(svn r11956) -Fix [FS#1675]: Disallow building locks and docks on rapids.
peter1138
parents:
8876
diff
changeset
|
335 |
|
f54bd3d64027
(svn r11956) -Fix [FS#1675]: Disallow building locks and docks on rapids.
peter1138
parents:
8876
diff
changeset
|
336 |
/* Disallow building of locks on river rapids */ |
8967
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
337 |
if (IsWaterTile(tile)) return_cmd_error(STR_0239_SITE_UNSUITABLE); |
8882
f54bd3d64027
(svn r11956) -Fix [FS#1675]: Disallow building locks and docks on rapids.
peter1138
parents:
8876
diff
changeset
|
338 |
|
3157
40de8616c04c
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3111
diff
changeset
|
339 |
return DoBuildShiplift(tile, dir, flags); |
0 | 340 |
} |
341 |
||
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
|
342 |
/** 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
|
343 |
* @param tile end tile of stretch-dragging |
6928
44797333bcbf
(svn r9568) -Documentation: doxygen and comment changes: Root of src is finally done. Now, time to start clearing as much as possible
belugas
parents:
6923
diff
changeset
|
344 |
* @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
|
345 |
* @param p1 start tile of stretch-dragging |
8909
fa15e9afad2f
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8882
diff
changeset
|
346 |
* @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
|
347 |
*/ |
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7402
diff
changeset
|
348 |
CommandCost CmdBuildCanal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 349 |
{ |
8726
5ae45b46506b
(svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium
parents:
8720
diff
changeset
|
350 |
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
|
351 |
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
|
352 |
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
|
353 |
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
|
354 |
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
|
355 |
|
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
|
356 |
if (p1 >= MapSize()) return CMD_ERROR; |
8856
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
357 |
|
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
|
358 |
/* Outside of the editor you can only build canals, not oceans */ |
8857
df06e88e5dbd
(svn r11927) -Fix (r11926): unable to place canals in game
peter1138
parents:
8856
diff
changeset
|
359 |
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
|
360 |
|
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
|
361 |
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
|
362 |
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
|
363 |
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
|
364 |
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
|
365 |
|
6432 | 366 |
if (x < sx) Swap(x, sx); |
367 |
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
|
368 |
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
|
369 |
size_y = (y - sy) + 1; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
370 |
|
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
|
371 |
/* 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
|
372 |
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
|
373 |
|
1981 | 374 |
BEGIN_TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) { |
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7402
diff
changeset
|
375 |
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
|
376 |
|
8856
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
377 |
Slope slope = GetTileSlope(tile, NULL); |
8909
fa15e9afad2f
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8882
diff
changeset
|
378 |
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
|
379 |
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
|
380 |
} |
0 | 381 |
|
6928
44797333bcbf
(svn r9568) -Documentation: doxygen and comment changes: Root of src is finally done. Now, time to start clearing as much as possible
belugas
parents:
6923
diff
changeset
|
382 |
/* can't make water of water! */ |
8856
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
383 |
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
|
384 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5210
diff
changeset
|
385 |
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
|
386 |
if (CmdFailed(ret)) return ret; |
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7442
diff
changeset
|
387 |
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
|
388 |
|
3189
1af302c5abd0
(svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
3183
diff
changeset
|
389 |
if (flags & DC_EXEC) { |
8856
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
390 |
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
|
391 |
MakeWater(tile); |
8856
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
392 |
} else if (p2 == 2) { |
8864
0082e49e8351
(svn r11934) -Codechange: add persistent random data for river and canal tiles.
peter1138
parents:
8857
diff
changeset
|
393 |
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
|
394 |
} else { |
8864
0082e49e8351
(svn r11934) -Codechange: add persistent random data for river and canal tiles.
peter1138
parents:
8857
diff
changeset
|
395 |
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
|
396 |
} |
3189
1af302c5abd0
(svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
3183
diff
changeset
|
397 |
MarkTileDirtyByTile(tile); |
8939
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
398 |
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
|
399 |
} |
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
|
400 |
|
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7442
diff
changeset
|
401 |
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
|
402 |
} END_TILE_LOOP(tile, size_x, size_y, 0); |
0 | 403 |
|
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7442
diff
changeset
|
404 |
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
|
405 |
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
|
406 |
} 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
|
407 |
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
|
408 |
} |
0 | 409 |
} |
410 |
||
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7402
diff
changeset
|
411 |
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
|
412 |
{ |
3425
b972214fde4f
(svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents:
3423
diff
changeset
|
413 |
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
|
414 |
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
|
415 |
if (flags & DC_NO_WATER) return_cmd_error(STR_3807_CAN_T_BUILD_ON_WATER); |
0 | 416 |
|
6928
44797333bcbf
(svn r9568) -Documentation: doxygen and comment changes: Root of src is finally done. Now, time to start clearing as much as possible
belugas
parents:
6923
diff
changeset
|
417 |
/* Make sure it's not an edge tile. */ |
8450
dce58137301f
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents:
8444
diff
changeset
|
418 |
if (!IsInsideMM(TileX(tile), 1, MapMaxX() - 1) || |
dce58137301f
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents:
8444
diff
changeset
|
419 |
!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
|
420 |
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
|
421 |
} |
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
|
422 |
|
8005
9f7a95e84682
(svn r11024) -Fix [FS#1173]: give a more correct error when building some things on tile 0; "Can't build on water" or "Too close to the edge" instead of "Vehicle in the way". Patch by SmatZ.
rubidium
parents:
8003
diff
changeset
|
423 |
/* Make sure no vehicle is on the tile */ |
8254
5de2bbd26163
(svn r11303) -Fix: EnsureNoVehicle and EnsureNoVehicleOnGround were both used to check whether there was no vehicle on the ground, except that the former didn't take care of aircraft shadows. So now we only use EnsureNoVehicleOnGround.
rubidium
parents:
8235
diff
changeset
|
424 |
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; |
8005
9f7a95e84682
(svn r11024) -Fix [FS#1173]: give a more correct error when building some things on tile 0; "Can't build on water" or "Too close to the edge" instead of "Vehicle in the way". Patch by SmatZ.
rubidium
parents:
8003
diff
changeset
|
425 |
|
7766
b4a38a2be0d3
(svn r10593) -Fix [FS#1038]: one could not remove locks that were build in a (very) old version of OpenTTD.
rubidium
parents:
7762
diff
changeset
|
426 |
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
|
427 |
|
8939
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
428 |
if (flags & DC_EXEC) { |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
429 |
DoClearSquare(tile); |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
430 |
MarkCanalsAndRiversAroundDirty(tile); |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
431 |
} |
8726
5ae45b46506b
(svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium
parents:
8720
diff
changeset
|
432 |
return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_water); |
0 | 433 |
|
6507
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
6486
diff
changeset
|
434 |
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
|
435 |
Slope slope = GetTileSlope(tile, NULL); |
3439 | 436 |
|
6928
44797333bcbf
(svn r9568) -Documentation: doxygen and comment changes: Root of src is finally done. Now, time to start clearing as much as possible
belugas
parents:
6923
diff
changeset
|
437 |
/* Make sure no vehicle is on the tile */ |
8254
5de2bbd26163
(svn r11303) -Fix: EnsureNoVehicle and EnsureNoVehicleOnGround were both used to check whether there was no vehicle on the ground, except that the former didn't take care of aircraft shadows. So now we only use EnsureNoVehicleOnGround.
rubidium
parents:
8235
diff
changeset
|
438 |
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; |
3439 | 439 |
|
8939
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
440 |
if (flags & DC_EXEC) { |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
441 |
DoClearSquare(tile); |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
442 |
MarkCanalsAndRiversAroundDirty(tile); |
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
443 |
} |
8909
fa15e9afad2f
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8882
diff
changeset
|
444 |
if (IsSlopeWithOneCornerRaised(slope)) { |
8726
5ae45b46506b
(svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium
parents:
8720
diff
changeset
|
445 |
return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_water); |
3439 | 446 |
} else { |
8726
5ae45b46506b
(svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium
parents:
8720
diff
changeset
|
447 |
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
|
448 |
} |
3439 | 449 |
} |
450 |
||
6507
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
6486
diff
changeset
|
451 |
case WATER_TILE_LOCK: { |
3439 | 452 |
static const TileIndexDiffC _shiplift_tomiddle_offs[] = { |
453 |
{ 0, 0}, {0, 0}, { 0, 0}, {0, 0}, // middle |
|
454 |
{-1, 0}, {0, 1}, { 1, 0}, {0, -1}, // lower |
|
455 |
{ 1, 0}, {0, -1}, {-1, 0}, {0, 1}, // upper |
|
456 |
}; |
|
457 |
||
458 |
if (flags & DC_AUTO) return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED); |
|
459 |
if (_current_player == OWNER_WATER) return CMD_ERROR; |
|
6928
44797333bcbf
(svn r9568) -Documentation: doxygen and comment changes: Root of src is finally done. Now, time to start clearing as much as possible
belugas
parents:
6923
diff
changeset
|
460 |
/* move to the middle tile.. */ |
3439 | 461 |
return RemoveShiplift(tile + ToTileIndexDiff(_shiplift_tomiddle_offs[GetSection(tile)]), flags); |
462 |
} |
|
463 |
||
6507
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
6486
diff
changeset
|
464 |
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
|
465 |
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
|
466 |
return RemoveShipDepot(tile, flags); |
3439 | 467 |
|
468 |
default: |
|
469 |
NOT_REACHED(); |
|
0 | 470 |
} |
471 |
} |
|
472 |
||
8937
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
473 |
/** |
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
474 |
* return true if a tile is a water tile wrt. a certain direction. |
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
475 |
* |
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
476 |
* @param tile The tile of interest. |
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
477 |
* @param from The direction of interest. |
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
478 |
* @return true iff the tile is water in the view of 'from'. |
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
479 |
* |
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
480 |
*/ |
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
481 |
static bool IsWateredTile(TileIndex tile, Direction from) |
0 | 482 |
{ |
1214
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1209
diff
changeset
|
483 |
switch (GetTileType(tile)) { |
3977
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
484 |
case MP_WATER: |
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
|
485 |
if (!IsCoast(tile)) return true; |
8937
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
486 |
switch (GetTileSlope(tile, NULL)) { |
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
487 |
case SLOPE_W: return (from == DIR_SE) || (from == DIR_E) || (from == DIR_NE); |
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
488 |
case SLOPE_S: return (from == DIR_NE) || (from == DIR_N) || (from == DIR_NW); |
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
489 |
case SLOPE_E: return (from == DIR_NW) || (from == DIR_W) || (from == DIR_SW); |
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
490 |
case SLOPE_N: return (from == DIR_SW) || (from == DIR_S) || (from == DIR_SE); |
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
491 |
default: return false; |
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
492 |
} |
3977
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3940
diff
changeset
|
493 |
|
8910
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
494 |
case MP_RAILWAY: |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
495 |
if (GetRailGroundType(tile) == RAIL_GROUND_WATER) { |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
496 |
assert(IsPlainRailTile(tile)); |
8937
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
497 |
switch (GetTileSlope(tile, NULL)) { |
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
498 |
case SLOPE_W: return (from == DIR_SE) || (from == DIR_E) || (from == DIR_NE); |
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
499 |
case SLOPE_S: return (from == DIR_NE) || (from == DIR_N) || (from == DIR_NW); |
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
500 |
case SLOPE_E: return (from == DIR_NW) || (from == DIR_W) || (from == DIR_SW); |
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
501 |
case SLOPE_N: return (from == DIR_SW) || (from == DIR_S) || (from == DIR_SE); |
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
502 |
default: return false; |
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
503 |
} |
8910
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
504 |
} |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
505 |
return false; |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
506 |
|
8967
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
507 |
case MP_STATION: return IsOilRig(tile) || (IsDock(tile) && GetTileSlope(tile, NULL) == SLOPE_FLAT) || IsBuoy(tile); |
8003
bd88e365c18a
(svn r11022) -Fix: the canal border determination did not take oil rigs into consideration.
rubidium
parents:
7993
diff
changeset
|
508 |
case MP_INDUSTRY: return (GetIndustrySpec(GetIndustryType(tile))->behaviour & INDUSTRYBEH_BUILT_ONWATER) != 0; |
bd88e365c18a
(svn r11022) -Fix: the canal border determination did not take oil rigs into consideration.
rubidium
parents:
7993
diff
changeset
|
509 |
default: return false; |
1048 | 510 |
} |
0 | 511 |
} |
512 |
||
8856
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
513 |
static void DrawWaterEdges(SpriteID base, TileIndex tile) |
0 | 514 |
{ |
515 |
uint wa; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
516 |
|
6928
44797333bcbf
(svn r9568) -Documentation: doxygen and comment changes: Root of src is finally done. Now, time to start clearing as much as possible
belugas
parents:
6923
diff
changeset
|
517 |
/* determine the edges around with water. */ |
8937
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
518 |
wa = IsWateredTile(TILE_ADDXY(tile, -1, 0), DIR_SW) << 0; |
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
519 |
wa += IsWateredTile(TILE_ADDXY(tile, 0, 1), DIR_NW) << 1; |
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
520 |
wa += IsWateredTile(TILE_ADDXY(tile, 1, 0), DIR_NE) << 2; |
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
521 |
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
|
522 |
|
8856
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
523 |
if (!(wa & 1)) DrawGroundSprite(base, PAL_NONE); |
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
524 |
if (!(wa & 2)) DrawGroundSprite(base + 1, PAL_NONE); |
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
525 |
if (!(wa & 4)) DrawGroundSprite(base + 2, PAL_NONE); |
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
526 |
if (!(wa & 8)) DrawGroundSprite(base + 3, PAL_NONE); |
0 | 527 |
|
6928
44797333bcbf
(svn r9568) -Documentation: doxygen and comment changes: Root of src is finally done. Now, time to start clearing as much as possible
belugas
parents:
6923
diff
changeset
|
528 |
/* right corner */ |
2989 | 529 |
switch (wa & 0x03) { |
8856
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
530 |
case 0: DrawGroundSprite(base + 4, PAL_NONE); break; |
8937
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
531 |
case 3: if (!IsWateredTile(TILE_ADDXY(tile, -1, 1), DIR_W)) DrawGroundSprite(base + 8, PAL_NONE); break; |
2989 | 532 |
} |
0 | 533 |
|
6928
44797333bcbf
(svn r9568) -Documentation: doxygen and comment changes: Root of src is finally done. Now, time to start clearing as much as possible
belugas
parents:
6923
diff
changeset
|
534 |
/* bottom corner */ |
2989 | 535 |
switch (wa & 0x06) { |
8856
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
536 |
case 0: DrawGroundSprite(base + 5, PAL_NONE); break; |
8937
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
537 |
case 6: if (!IsWateredTile(TILE_ADDXY(tile, 1, 1), DIR_N)) DrawGroundSprite(base + 9, PAL_NONE); break; |
2989 | 538 |
} |
0 | 539 |
|
6928
44797333bcbf
(svn r9568) -Documentation: doxygen and comment changes: Root of src is finally done. Now, time to start clearing as much as possible
belugas
parents:
6923
diff
changeset
|
540 |
/* left corner */ |
2989 | 541 |
switch (wa & 0x0C) { |
8856
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
542 |
case 0: DrawGroundSprite(base + 6, PAL_NONE); break; |
8937
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
543 |
case 12: if (!IsWateredTile(TILE_ADDXY(tile, 1, -1), DIR_E)) DrawGroundSprite(base + 10, PAL_NONE); break; |
2989 | 544 |
} |
0 | 545 |
|
6928
44797333bcbf
(svn r9568) -Documentation: doxygen and comment changes: Root of src is finally done. Now, time to start clearing as much as possible
belugas
parents:
6923
diff
changeset
|
546 |
/* upper corner */ |
2989 | 547 |
switch (wa & 0x09) { |
8856
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
548 |
case 0: DrawGroundSprite(base + 7, PAL_NONE); break; |
8937
40f1d2e4c833
(svn r12011) -Fix [FS#1701]: Do not consider one-corner-raised-shores to be watered tiles from all sides.
frosch
parents:
8926
diff
changeset
|
549 |
case 9: if (!IsWateredTile(TILE_ADDXY(tile, -1, -1), DIR_S)) DrawGroundSprite(base + 11, PAL_NONE); break; |
2989 | 550 |
} |
0 | 551 |
} |
552 |
||
8967
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
553 |
/** Draw a plain sea water tile with no edges */ |
8992
4fa931bf2417
(svn r12071) -Feature(ette): Draw river- and canal-edges under docks and shipdepots.
frosch
parents:
8991
diff
changeset
|
554 |
static void DrawSeaWater(TileIndex tile) |
8967
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
555 |
{ |
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
556 |
DrawGroundSprite(SPR_FLAT_WATER_TILE, PAL_NONE); |
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
557 |
} |
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
558 |
|
8856
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
559 |
/** draw a canal styled water tile with dikes around */ |
8992
4fa931bf2417
(svn r12071) -Feature(ette): Draw river- and canal-edges under docks and shipdepots.
frosch
parents:
8991
diff
changeset
|
560 |
static void DrawCanalWater(TileIndex tile) |
8856
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
561 |
{ |
8992
4fa931bf2417
(svn r12071) -Feature(ette): Draw river- and canal-edges under docks and shipdepots.
frosch
parents:
8991
diff
changeset
|
562 |
DrawGroundSprite(SPR_FLAT_WATER_TILE, PAL_NONE); |
8967
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
563 |
|
8856
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
564 |
/* Test for custom graphics, else use the default */ |
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
565 |
SpriteID dikes_base = GetCanalSprite(CF_DIKES, tile); |
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
566 |
if (dikes_base == 0) dikes_base = SPR_CANAL_DIKES_BASE; |
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
567 |
|
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
568 |
DrawWaterEdges(dikes_base, tile); |
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
569 |
} |
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
570 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6507
diff
changeset
|
571 |
struct LocksDrawTileStruct { |
0 | 572 |
int8 delta_x, delta_y, delta_z; |
573 |
byte width, height, depth; |
|
574 |
SpriteID image; |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6507
diff
changeset
|
575 |
}; |
0 | 576 |
|
577 |
#include "table/water_land.h" |
|
578 |
||
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
|
579 |
static void DrawWaterStuff(const TileInfo *ti, const WaterDrawTileStruct *wdts, |
8992
4fa931bf2417
(svn r12071) -Feature(ette): Draw river- and canal-edges under docks and shipdepots.
frosch
parents:
8991
diff
changeset
|
580 |
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
|
581 |
) |
0 | 582 |
{ |
7079
35743c461482
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6987
diff
changeset
|
583 |
SpriteID image; |
35743c461482
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6987
diff
changeset
|
584 |
SpriteID water_base = GetCanalSprite(CF_WATERSLOPE, ti->tile); |
35743c461482
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6987
diff
changeset
|
585 |
SpriteID locks_base = GetCanalSprite(CF_LOCKS, ti->tile); |
35743c461482
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6987
diff
changeset
|
586 |
|
35743c461482
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6987
diff
changeset
|
587 |
/* If no custom graphics, use defaults */ |
8378
9f849e5763e2
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
8345
diff
changeset
|
588 |
if (water_base == 0) water_base = SPR_CANALS_BASE; |
7079
35743c461482
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6987
diff
changeset
|
589 |
if (locks_base == 0) { |
8378
9f849e5763e2
(svn r11433) -Fix: starting OpenTTD with DOS files made it look weird out of the box.
rubidium
parents:
8345
diff
changeset
|
590 |
locks_base = SPR_SHIPLIFT_BASE; |
7079
35743c461482
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6987
diff
changeset
|
591 |
} else { |
35743c461482
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6987
diff
changeset
|
592 |
/* If using custom graphics, ignore the variation on height */ |
35743c461482
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6987
diff
changeset
|
593 |
base = 0; |
35743c461482
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6987
diff
changeset
|
594 |
} |
35743c461482
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6987
diff
changeset
|
595 |
|
35743c461482
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6987
diff
changeset
|
596 |
image = wdts++->image; |
35743c461482
(svn r9797) -Feature: [NewGRF] Add action 1, 2 and 3 support for canals.
peter1138
parents:
6987
diff
changeset
|
597 |
if (image < 4) image += water_base; |
8992
4fa931bf2417
(svn r12071) -Feature(ette): Draw river- and canal-edges under docks and shipdepots.
frosch
parents:
8991
diff
changeset
|
598 |
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
|
599 |
|
9302
4aa3c4a44b16
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
9297
diff
changeset
|
600 |
/* End now if buildings are invisible */ |
4aa3c4a44b16
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
9297
diff
changeset
|
601 |
if (IsInvisibilitySet(TO_BUILDINGS)) return; |
4aa3c4a44b16
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
9297
diff
changeset
|
602 |
|
1399
4503bd2bfb82
(svn r1903) Replace some casts and macro magic with proper typing, similar to r1902
tron
parents:
1363
diff
changeset
|
603 |
for (; wdts->delta_x != 0x80; wdts++) { |
7829
88883899c9e6
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium
parents:
7766
diff
changeset
|
604 |
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
|
605 |
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
|
606 |
wdts->width, wdts->height, |
7829
88883899c9e6
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium
parents:
7766
diff
changeset
|
607 |
wdts->unk, ti->z + wdts->delta_z, |
8345
6caa3fdb972c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
8293
diff
changeset
|
608 |
IsTransparencySet(TO_BUILDINGS)); |
0 | 609 |
} |
610 |
} |
|
611 |
||
8992
4fa931bf2417
(svn r12071) -Feature(ette): Draw river- and canal-edges under docks and shipdepots.
frosch
parents:
8991
diff
changeset
|
612 |
static void DrawRiverWater(const TileInfo *ti) |
8856
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
613 |
{ |
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
614 |
SpriteID image = SPR_FLAT_WATER_TILE; |
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
615 |
SpriteID edges_base = GetCanalSprite(CF_RIVER_EDGE, ti->tile); |
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
616 |
|
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
617 |
if (ti->tileh != SLOPE_FLAT) { |
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
618 |
image = GetCanalSprite(CF_RIVER_SLOPE, ti->tile); |
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
619 |
if (image == 0) { |
8926
5bf75fec316f
(svn r12000) -Fix (r11926): If no river NewGRF is loaded, use sloped water from locks.
frosch
parents:
8910
diff
changeset
|
620 |
switch (ti->tileh) { |
5bf75fec316f
(svn r12000) -Fix (r11926): If no river NewGRF is loaded, use sloped water from locks.
frosch
parents:
8910
diff
changeset
|
621 |
case SLOPE_NW: image = SPR_WATER_SLOPE_Y_DOWN; break; |
5bf75fec316f
(svn r12000) -Fix (r11926): If no river NewGRF is loaded, use sloped water from locks.
frosch
parents:
8910
diff
changeset
|
622 |
case SLOPE_SW: image = SPR_WATER_SLOPE_X_UP; break; |
5bf75fec316f
(svn r12000) -Fix (r11926): If no river NewGRF is loaded, use sloped water from locks.
frosch
parents:
8910
diff
changeset
|
623 |
case SLOPE_SE: image = SPR_WATER_SLOPE_Y_UP; break; |
5bf75fec316f
(svn r12000) -Fix (r11926): If no river NewGRF is loaded, use sloped water from locks.
frosch
parents:
8910
diff
changeset
|
624 |
case SLOPE_NE: image = SPR_WATER_SLOPE_X_DOWN; break; |
5bf75fec316f
(svn r12000) -Fix (r11926): If no river NewGRF is loaded, use sloped water from locks.
frosch
parents:
8910
diff
changeset
|
625 |
default: image = SPR_FLAT_WATER_TILE; break; |
5bf75fec316f
(svn r12000) -Fix (r11926): If no river NewGRF is loaded, use sloped water from locks.
frosch
parents:
8910
diff
changeset
|
626 |
} |
8856
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
627 |
} else { |
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
628 |
switch (ti->tileh) { |
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
629 |
default: NOT_REACHED(); |
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
630 |
case SLOPE_SE: edges_base += 12; break; |
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
631 |
case SLOPE_NE: image += 1; edges_base += 24; break; |
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
632 |
case SLOPE_SW: image += 2; edges_base += 36; break; |
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
633 |
case SLOPE_NW: image += 3; edges_base += 48; break; |
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
634 |
} |
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
635 |
} |
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
636 |
} |
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
637 |
|
8992
4fa931bf2417
(svn r12071) -Feature(ette): Draw river- and canal-edges under docks and shipdepots.
frosch
parents:
8991
diff
changeset
|
638 |
DrawGroundSprite(image, PAL_NONE); |
8856
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
639 |
|
8926
5bf75fec316f
(svn r12000) -Fix (r11926): If no river NewGRF is loaded, use sloped water from locks.
frosch
parents:
8910
diff
changeset
|
640 |
/* Draw river edges if available. */ |
5bf75fec316f
(svn r12000) -Fix (r11926): If no river NewGRF is loaded, use sloped water from locks.
frosch
parents:
8910
diff
changeset
|
641 |
if (edges_base > 48) DrawWaterEdges(edges_base, ti->tile); |
8856
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
642 |
} |
7f8b5c11bea6
(svn r11926) -Feature: Rivers. Graphics must be provided by NewGRF else rivers are drawn as canals. Rivers can currently only be placed with-in the scenario editor.
peter1138
parents:
8846
diff
changeset
|
643 |
|
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
644 |
void DrawShoreTile(Slope tileh) |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
645 |
{ |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
646 |
/* Converts the enum Slope into an offset based on SPR_SHORE_BASE. |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
647 |
* This allows to calculate the proper sprite to display for this Slope */ |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
648 |
static const byte tileh_to_shoresprite[32] = { |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
649 |
0, 1, 2, 3, 4, 16, 6, 7, 8, 9, 17, 11, 12, 13, 14, 0, |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
650 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 10, 15, 0, |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
651 |
}; |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
652 |
|
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
653 |
assert(!IsHalftileSlope(tileh)); // Halftile slopes need to get handled earlier. |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
654 |
assert(tileh != SLOPE_FLAT); // Shore is never flat |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
655 |
|
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
656 |
assert((tileh != SLOPE_EW) && (tileh != SLOPE_NS)); // No suitable sprites for current flooding behaviour |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
657 |
|
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
658 |
DrawGroundSprite(SPR_SHORE_BASE + tileh_to_shoresprite[tileh], PAL_NONE); |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
659 |
} |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
660 |
|
8992
4fa931bf2417
(svn r12071) -Feature(ette): Draw river- and canal-edges under docks and shipdepots.
frosch
parents:
8991
diff
changeset
|
661 |
void DrawWaterClassGround(const TileInfo *ti) { |
4fa931bf2417
(svn r12071) -Feature(ette): Draw river- and canal-edges under docks and shipdepots.
frosch
parents:
8991
diff
changeset
|
662 |
switch (GetWaterClass(ti->tile)) { |
4fa931bf2417
(svn r12071) -Feature(ette): Draw river- and canal-edges under docks and shipdepots.
frosch
parents:
8991
diff
changeset
|
663 |
case WATER_CLASS_SEA: DrawSeaWater(ti->tile); break; |
4fa931bf2417
(svn r12071) -Feature(ette): Draw river- and canal-edges under docks and shipdepots.
frosch
parents:
8991
diff
changeset
|
664 |
case WATER_CLASS_CANAL: DrawCanalWater(ti->tile); break; |
4fa931bf2417
(svn r12071) -Feature(ette): Draw river- and canal-edges under docks and shipdepots.
frosch
parents:
8991
diff
changeset
|
665 |
case WATER_CLASS_RIVER: DrawRiverWater(ti); break; |
4fa931bf2417
(svn r12071) -Feature(ette): Draw river- and canal-edges under docks and shipdepots.
frosch
parents:
8991
diff
changeset
|
666 |
} |
4fa931bf2417
(svn r12071) -Feature(ette): Draw river- and canal-edges under docks and shipdepots.
frosch
parents:
8991
diff
changeset
|
667 |
} |
4fa931bf2417
(svn r12071) -Feature(ette): Draw river- and canal-edges under docks and shipdepots.
frosch
parents:
8991
diff
changeset
|
668 |
|
0 | 669 |
static void DrawTile_Water(TileInfo *ti) |
670 |
{ |
|
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
|
671 |
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
|
672 |
case WATER_TILE_CLEAR: |
8992
4fa931bf2417
(svn r12071) -Feature(ette): Draw river- and canal-edges under docks and shipdepots.
frosch
parents:
8991
diff
changeset
|
673 |
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
|
674 |
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
|
675 |
break; |
0 | 676 |
|
8660
498f2a298b04
(svn r11726) -Feature[newGRF]: Extend the Action 5, feature 0D usage. Patch by BigBB
belugas
parents:
8653
diff
changeset
|
677 |
case WATER_TILE_COAST: { |
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
678 |
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
|
679 |
DrawBridgeMiddle(ti); |
8660
498f2a298b04
(svn r11726) -Feature[newGRF]: Extend the Action 5, feature 0D usage. Patch by BigBB
belugas
parents:
8653
diff
changeset
|
680 |
} break; |
0 | 681 |
|
6507
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
6486
diff
changeset
|
682 |
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
|
683 |
const WaterDrawTileStruct *t = _shiplift_display_seq[GetSection(ti->tile)]; |
8992
4fa931bf2417
(svn r12071) -Feature(ette): Draw river- and canal-edges under docks and shipdepots.
frosch
parents:
8991
diff
changeset
|
684 |
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
|
685 |
} 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
|
686 |
|
6507
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
6486
diff
changeset
|
687 |
case WATER_TILE_DEPOT: |
8992
4fa931bf2417
(svn r12071) -Feature(ette): Draw river- and canal-edges under docks and shipdepots.
frosch
parents:
8991
diff
changeset
|
688 |
DrawWaterClassGround(ti); |
4fa931bf2417
(svn r12071) -Feature(ette): Draw river- and canal-edges under docks and shipdepots.
frosch
parents:
8991
diff
changeset
|
689 |
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
|
690 |
break; |
0 | 691 |
} |
692 |
} |
|
693 |
||
694 |
void DrawShipDepotSprite(int x, int y, int image) |
|
695 |
{ |
|
1399
4503bd2bfb82
(svn r1903) Replace some casts and macro magic with proper typing, similar to r1902
tron
parents:
1363
diff
changeset
|
696 |
const WaterDrawTileStruct *wdts = _shipdepot_display_seq[image]; |
0 | 697 |
|
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
698 |
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
|
699 |
|
1399
4503bd2bfb82
(svn r1903) Replace some casts and macro magic with proper typing, similar to r1902
tron
parents:
1363
diff
changeset
|
700 |
for (; wdts->delta_x != 0x80; wdts++) { |
0 | 701 |
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
|
702 |
DrawSprite(wdts->image, PLAYER_SPRITE_COLOR(_local_player), x + pt.x, y + pt.y); |
0 | 703 |
} |
704 |
} |
|
705 |
||
706 |
||
4231
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4171
diff
changeset
|
707 |
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
|
708 |
{ |
4231
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4171
diff
changeset
|
709 |
uint z; |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
710 |
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
|
711 |
|
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4171
diff
changeset
|
712 |
return z + GetPartialZ(x & 0xF, y & 0xF, tileh); |
0 | 713 |
} |
714 |
||
7831
5dded9b03500
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7829
diff
changeset
|
715 |
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
|
716 |
{ |
7831
5dded9b03500
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7829
diff
changeset
|
717 |
return FOUNDATION_NONE; |
39 | 718 |
} |
719 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
720 |
static void GetAcceptedCargo_Water(TileIndex tile, AcceptedCargo ac) |
0 | 721 |
{ |
722 |
/* not used */ |
|
723 |
} |
|
724 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
725 |
static void GetTileDesc_Water(TileIndex tile, TileDesc *td) |
0 | 726 |
{ |
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
|
727 |
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
|
728 |
case WATER_TILE_CLEAR: |
8235
fc75e5ad02b6
(svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium
parents:
8227
diff
changeset
|
729 |
if (!IsCanal(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
|
730 |
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
|
731 |
} 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
|
732 |
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
|
733 |
} |
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
|
734 |
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
|
735 |
case WATER_TILE_COAST: td->str = STR_3805_COAST_OR_RIVERBANK; break; |
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_LOCK : td->str = STR_LANDINFO_LOCK; break; |
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
6486
diff
changeset
|
737 |
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
|
738 |
default: assert(0); break; |
2951 | 739 |
} |
0 | 740 |
|
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
|
741 |
td->owner = GetTileOwner(tile); |
0 | 742 |
} |
743 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
744 |
static void AnimateTile_Water(TileIndex tile) |
0 | 745 |
{ |
746 |
/* not used */ |
|
747 |
} |
|
748 |
||
749 |
||
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
|
750 |
/** |
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
|
751 |
* 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
|
752 |
* 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
|
753 |
* @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
|
754 |
* @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
|
755 |
*/ |
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
|
756 |
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
|
757 |
{ |
7402
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
758 |
if (IsTileType(tile, MP_STATION) && IsAirport(tile)) { |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
759 |
const Station *st = GetStationByTile(tile); |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
760 |
const AirportFTAClass *airport = st->Airport(); |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
761 |
for (uint x = 0; x < airport->size_x; x++) { |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
762 |
for (uint y = 0; y < airport->size_y; y++) { |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
763 |
tile = TILE_ADDXY(st->airport_tile, x, y); |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
764 |
Vehicle *v = FindVehicleOnTileZ(tile, 1 + airport->delta_z); |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
765 |
if (v != NULL && (v->vehstatus & VS_CRASHED) == 0) return v; |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
766 |
} |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
767 |
} |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
768 |
|
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
769 |
/* No vehicle could be flooded on this airport anymore */ |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
770 |
return NULL; |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
771 |
} |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
772 |
|
8510
17bda703ae17
(svn r11574) -Fix: flood train stations when there are no trains on border tiles too (when non-uniform stations are OFF)
smatz
parents:
8473
diff
changeset
|
773 |
/* if non-uniform stations are disabled, flood some train in this train station (if there is any) */ |
17bda703ae17
(svn r11574) -Fix: flood train stations when there are no trains on border tiles too (when non-uniform stations are OFF)
smatz
parents:
8473
diff
changeset
|
774 |
if (!_patches.nonuniform_stations && IsTileType(tile, MP_STATION) && GetStationType(tile) == STATION_RAIL) { |
17bda703ae17
(svn r11574) -Fix: flood train stations when there are no trains on border tiles too (when non-uniform stations are OFF)
smatz
parents:
8473
diff
changeset
|
775 |
const Station *st = GetStationByTile(tile); |
17bda703ae17
(svn r11574) -Fix: flood train stations when there are no trains on border tiles too (when non-uniform stations are OFF)
smatz
parents:
8473
diff
changeset
|
776 |
|
17bda703ae17
(svn r11574) -Fix: flood train stations when there are no trains on border tiles too (when non-uniform stations are OFF)
smatz
parents:
8473
diff
changeset
|
777 |
BEGIN_TILE_LOOP(t, st->trainst_w, st->trainst_h, st->train_tile) |
17bda703ae17
(svn r11574) -Fix: flood train stations when there are no trains on border tiles too (when non-uniform stations are OFF)
smatz
parents:
8473
diff
changeset
|
778 |
if (st->TileBelongsToRailStation(t)) { |
17bda703ae17
(svn r11574) -Fix: flood train stations when there are no trains on border tiles too (when non-uniform stations are OFF)
smatz
parents:
8473
diff
changeset
|
779 |
Vehicle *v = FindVehicleOnTileZ(t, 0); |
17bda703ae17
(svn r11574) -Fix: flood train stations when there are no trains on border tiles too (when non-uniform stations are OFF)
smatz
parents:
8473
diff
changeset
|
780 |
if (v != NULL && (v->vehstatus & VS_CRASHED) == 0) return v; |
17bda703ae17
(svn r11574) -Fix: flood train stations when there are no trains on border tiles too (when non-uniform stations are OFF)
smatz
parents:
8473
diff
changeset
|
781 |
} |
17bda703ae17
(svn r11574) -Fix: flood train stations when there are no trains on border tiles too (when non-uniform stations are OFF)
smatz
parents:
8473
diff
changeset
|
782 |
END_TILE_LOOP(t, st->trainst_w, st->trainst_h, st->train_tile) |
17bda703ae17
(svn r11574) -Fix: flood train stations when there are no trains on border tiles too (when non-uniform stations are OFF)
smatz
parents:
8473
diff
changeset
|
783 |
|
17bda703ae17
(svn r11574) -Fix: flood train stations when there are no trains on border tiles too (when non-uniform stations are OFF)
smatz
parents:
8473
diff
changeset
|
784 |
return NULL; |
17bda703ae17
(svn r11574) -Fix: flood train stations when there are no trains on border tiles too (when non-uniform stations are OFF)
smatz
parents:
8473
diff
changeset
|
785 |
} |
17bda703ae17
(svn r11574) -Fix: flood train stations when there are no trains on border tiles too (when non-uniform stations are OFF)
smatz
parents:
8473
diff
changeset
|
786 |
|
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
|
787 |
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
|
788 |
|
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
|
789 |
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
|
790 |
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
|
791 |
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
|
792 |
|
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
|
793 |
/* 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
|
794 |
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
|
795 |
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
|
796 |
|
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
|
797 |
/* 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
|
798 |
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
|
799 |
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
|
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 |
/* 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
|
802 |
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
|
803 |
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
|
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 |
|
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
806 |
static void FloodVehicle(Vehicle *v) |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
807 |
{ |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
808 |
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
|
809 |
uint16 pass = 0; |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
810 |
|
7402
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
811 |
if (v->type == VEH_TRAIN || v->type == VEH_ROAD || v->type == VEH_AIRCRAFT) { |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
812 |
if (v->type == VEH_AIRCRAFT) { |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
813 |
/* Crashing aircraft are always at z_pos == 1, never on z_pos == 0, |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
814 |
* because that's always the shadow. Except for the heliport, because |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
815 |
* that station has a big z_offset for the aircraft. */ |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
816 |
if (!IsTileType(v->tile, MP_STATION) || !IsAirport(v->tile) || GetTileMaxZ(v->tile) != 0) return; |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
817 |
const Station *st = GetStationByTile(v->tile); |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
818 |
const AirportFTAClass *airport = st->Airport(); |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
819 |
|
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
820 |
if (v->z_pos != airport->delta_z + 1) return; |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
821 |
} |
4171 | 822 |
Vehicle *u; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
823 |
|
7993
76b0eb3e19c9
(svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents:
7990
diff
changeset
|
824 |
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
|
825 |
u = v; |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
826 |
|
7353
716c6dd9322a
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
7179
diff
changeset
|
827 |
/* crash all wagons, and count passengers */ |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
828 |
BEGIN_ENUM_WAGONS(v) |
7506
e52d89f5c7c1
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents:
7446
diff
changeset
|
829 |
if (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) pass += v->cargo.Count(); |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
830 |
v->vehstatus |= VS_CRASHED; |
8813
6d054db96ede
(svn r11882) -Codechange: introduce MarkSingleVehicleDirty() and simplify the code at some places
smatz
parents:
8802
diff
changeset
|
831 |
MarkSingleVehicleDirty(v); |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
832 |
END_ENUM_WAGONS(v) |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
833 |
|
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
834 |
v = u; |
7353
716c6dd9322a
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
7179
diff
changeset
|
835 |
|
7402
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
836 |
switch (v->type) { |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
837 |
default: NOT_REACHED(); |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
838 |
case VEH_TRAIN: |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
839 |
if (IsFrontEngine(v)) pass += 4; // driver |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
840 |
v->u.rail.crash_anim_pos = 4000; // max 4440, disappear pretty fast |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
841 |
break; |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
842 |
|
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
843 |
case VEH_ROAD: |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
844 |
if (IsRoadVehFront(v)) pass += 1; // driver |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
845 |
v->u.road.crashed_ctr = 2000; // max 2220, disappear pretty fast |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
846 |
break; |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
847 |
|
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
848 |
case VEH_AIRCRAFT: |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
849 |
pass += 2; // driver |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
850 |
v->u.air.crashed_counter = 9000; // max 10000, disappear pretty fast |
94575d2b8b02
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
rubidium
parents:
7353
diff
changeset
|
851 |
break; |
7353
716c6dd9322a
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
7179
diff
changeset
|
852 |
} |
716c6dd9322a
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
7179
diff
changeset
|
853 |
|
588 | 854 |
RebuildVehicleLists(); |
2549 | 855 |
} else { |
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
856 |
return; |
2549 | 857 |
} |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
858 |
|
8846
f3e877a92e2b
(svn r11916) -Codechange: use enums from VehicleViewWindowWidgets instead of constants
smatz
parents:
8828
diff
changeset
|
859 |
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
|
860 |
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
861 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
862 |
SetDParam(0, pass); |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
863 |
AddNewsItem(STR_B006_FLOOD_VEHICLE_DESTROYED, |
9259
088d3649dd4f
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents:
9180
diff
changeset
|
864 |
NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ACCIDENT, DNC_NONE, |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
865 |
v->index, |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
866 |
0); |
2549 | 867 |
CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE); |
868 |
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
|
869 |
} |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
870 |
} |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
43
diff
changeset
|
871 |
|
8227
9529f32a20fa
(svn r11266) -Documentation: Add a few comments. Parts of BigBB's work on shores
belugas
parents:
8041
diff
changeset
|
872 |
/** |
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
873 |
* Returns the behaviour of a tile during flooding. |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
874 |
* |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
875 |
* @return Behaviour of the tile |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
876 |
*/ |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
877 |
static FloodingBehaviour GetFloodingBehaviour(TileIndex tile) |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
878 |
{ |
8993
0794cc59940d
(svn r12072) -Fix: Make docks at sea flood neighboured tiles.
frosch
parents:
8992
diff
changeset
|
879 |
/* FLOOD_ACTIVE: 'single-corner-raised'-coast, sea, sea-shipdepots, sea-buoys, sea-docks (water part), rail with flooded halftile |
8955 | 880 |
* FLOOD_DRYUP: coast with more than one corner raised, coast with rail-track, coast with trees |
8993
0794cc59940d
(svn r12072) -Fix: Make docks at sea flood neighboured tiles.
frosch
parents:
8992
diff
changeset
|
881 |
* FLOOD_PASSIVE: oilrig, water-industries |
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
882 |
* FLOOD_NONE: canals, rivers, everything else |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
883 |
*/ |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
884 |
switch (GetTileType(tile)) { |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
885 |
case MP_WATER: |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
886 |
if (IsCoast(tile)) { |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
887 |
Slope tileh = GetTileSlope(tile, NULL); |
8909
fa15e9afad2f
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8882
diff
changeset
|
888 |
return (IsSlopeWithOneCornerRaised(tileh) ? FLOOD_ACTIVE : FLOOD_DRYUP); |
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
889 |
} else { |
8967
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
890 |
return (GetWaterClass(tile) == WATER_CLASS_SEA) ? FLOOD_ACTIVE : FLOOD_NONE; |
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
891 |
} |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
892 |
|
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
893 |
case MP_RAILWAY: |
8910
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
894 |
if (GetRailGroundType(tile) == RAIL_GROUND_WATER) { |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
895 |
return (IsSlopeWithOneCornerRaised(GetTileSlope(tile, NULL)) ? FLOOD_ACTIVE : FLOOD_DRYUP); |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
896 |
} |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
897 |
return FLOOD_NONE; |
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
898 |
|
8955 | 899 |
case MP_TREES: |
900 |
return (GetTreeGround(tile) == TREE_GROUND_SHORE ? FLOOD_DRYUP : FLOOD_NONE); |
|
901 |
||
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
902 |
case MP_STATION: |
8993
0794cc59940d
(svn r12072) -Fix: Make docks at sea flood neighboured tiles.
frosch
parents:
8992
diff
changeset
|
903 |
if (IsBuoy(tile) || (IsDock(tile) && GetTileSlope(tile, NULL) == SLOPE_FLAT)) { |
0794cc59940d
(svn r12072) -Fix: Make docks at sea flood neighboured tiles.
frosch
parents:
8992
diff
changeset
|
904 |
return (GetWaterClass(tile) == WATER_CLASS_SEA ? FLOOD_ACTIVE : FLOOD_NONE); |
0794cc59940d
(svn r12072) -Fix: Make docks at sea flood neighboured tiles.
frosch
parents:
8992
diff
changeset
|
905 |
} |
0794cc59940d
(svn r12072) -Fix: Make docks at sea flood neighboured tiles.
frosch
parents:
8992
diff
changeset
|
906 |
return (IsOilRig(tile) ? FLOOD_PASSIVE : FLOOD_NONE); |
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
907 |
|
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
908 |
case MP_INDUSTRY: |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
909 |
return ((GetIndustrySpec(GetIndustryType(tile))->behaviour & INDUSTRYBEH_BUILT_ONWATER) != 0 ? FLOOD_PASSIVE : FLOOD_NONE); |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
910 |
|
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
911 |
default: |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
912 |
return FLOOD_NONE; |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
913 |
} |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
914 |
} |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
915 |
|
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
916 |
/** |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
917 |
* Floods a tile. |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
918 |
*/ |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
919 |
static void DoFloodTile(TileIndex target) |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
920 |
{ |
9180
f39e3460f0ab
(svn r12350) -Fix [FS#1836](r11947): do not try ti flood water tile (performance increase)
glx
parents:
9112
diff
changeset
|
921 |
assert(!IsTileType(target, MP_WATER)); |
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
922 |
|
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
923 |
bool flooded = false; // Will be set to true if something is changed. |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
924 |
|
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
925 |
_current_player = OWNER_WATER; |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
926 |
|
8955 | 927 |
Slope tileh = GetTileSlope(target, NULL); |
928 |
if (tileh != SLOPE_FLAT) { |
|
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
929 |
/* make coast.. */ |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
930 |
switch (GetTileType(target)) { |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
931 |
case MP_RAILWAY: { |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
932 |
if (!IsPlainRailTile(target)) break; |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
933 |
|
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
934 |
flooded = FloodHalftile(target); |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
935 |
|
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
936 |
Vehicle *v = FindFloodableVehicleOnTile(target); |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
937 |
if (v != NULL) FloodVehicle(v); |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
938 |
|
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
939 |
break; |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
940 |
} |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
941 |
|
8955 | 942 |
case MP_TREES: |
943 |
if (!IsSlopeWithOneCornerRaised(tileh)) { |
|
944 |
SetTreeGroundDensity(target, TREE_GROUND_SHORE, 3); |
|
945 |
MarkTileDirtyByTile(target); |
|
946 |
flooded = true; |
|
947 |
break; |
|
948 |
} |
|
949 |
/* FALL THROUGH */ |
|
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
950 |
case MP_CLEAR: |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
951 |
if (CmdSucceeded(DoCommand(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) { |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
952 |
MakeShore(target); |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
953 |
MarkTileDirtyByTile(target); |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
954 |
flooded = true; |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
955 |
} |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
956 |
break; |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
957 |
|
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
958 |
default: |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
959 |
break; |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
960 |
} |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
961 |
} else { |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
962 |
/* Flood vehicles */ |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
963 |
Vehicle *v = FindFloodableVehicleOnTile(target); |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
964 |
if (v != NULL) FloodVehicle(v); |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
965 |
|
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
966 |
/* flood flat tile */ |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
967 |
if (CmdSucceeded(DoCommand(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) { |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
968 |
MakeWater(target); |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
969 |
MarkTileDirtyByTile(target); |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
970 |
flooded = true; |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
971 |
} |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
972 |
} |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
973 |
|
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
974 |
if (flooded) { |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
975 |
/* Mark surrounding canal tiles dirty too to avoid glitches */ |
8939
9d51d72e7e3d
(svn r12013) -Fix: When modifying watered tiles, mark neighboured canals and rivers dirty in more cases.
frosch
parents:
8937
diff
changeset
|
976 |
MarkCanalsAndRiversAroundDirty(target); |
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
977 |
|
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
978 |
/* update signals if needed */ |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
979 |
UpdateSignalsInBuffer(); |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
980 |
} |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
981 |
|
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
982 |
_current_player = OWNER_NONE; |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
983 |
} |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
984 |
|
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
985 |
/** |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
986 |
* Drys a tile up. |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
987 |
*/ |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
988 |
static void DoDryUp(TileIndex tile) |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
989 |
{ |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
990 |
_current_player = OWNER_WATER; |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
991 |
|
8910
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
992 |
switch (GetTileType(tile)) { |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
993 |
case MP_RAILWAY: |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
994 |
assert(IsPlainRailTile(tile)); |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
995 |
assert(GetRailGroundType(tile) == RAIL_GROUND_WATER); |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
996 |
|
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
997 |
RailGroundType new_ground; |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
998 |
switch (GetTrackBits(tile)) { |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
999 |
case TRACK_BIT_UPPER: new_ground = RAIL_GROUND_FENCE_HORIZ1; break; |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
1000 |
case TRACK_BIT_LOWER: new_ground = RAIL_GROUND_FENCE_HORIZ2; break; |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
1001 |
case TRACK_BIT_LEFT: new_ground = RAIL_GROUND_FENCE_VERT1; break; |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
1002 |
case TRACK_BIT_RIGHT: new_ground = RAIL_GROUND_FENCE_VERT2; break; |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
1003 |
default: NOT_REACHED(); |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
1004 |
} |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
1005 |
SetRailGroundType(tile, new_ground); |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
1006 |
MarkTileDirtyByTile(tile); |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
1007 |
break; |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
1008 |
|
8955 | 1009 |
case MP_TREES: |
1010 |
SetTreeGroundDensity(tile, TREE_GROUND_GRASS, 3); |
|
1011 |
MarkTileDirtyByTile(tile); |
|
1012 |
break; |
|
1013 |
||
8910
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
1014 |
case MP_WATER: |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
1015 |
assert(IsCoast(tile)); |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
1016 |
|
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
1017 |
if (CmdSucceeded(DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) { |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
1018 |
MakeClear(tile, CLEAR_GRASS, 3); |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
1019 |
MarkTileDirtyByTile(tile); |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
1020 |
} |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
1021 |
break; |
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
1022 |
|
b261b6cb9b21
(svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents:
8909
diff
changeset
|
1023 |
default: NOT_REACHED(); |
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1024 |
} |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1025 |
|
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1026 |
_current_player = OWNER_NONE; |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1027 |
} |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1028 |
|
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1029 |
/** |
8227
9529f32a20fa
(svn r11266) -Documentation: Add a few comments. Parts of BigBB's work on shores
belugas
parents:
8041
diff
changeset
|
1030 |
* Let a water tile floods its diagonal adjoining tiles |
8267
c600379bd333
(svn r11320) -Codechange: make lower halftiles at coast floodable. Patch by frosch.
rubidium
parents:
8254
diff
changeset
|
1031 |
* called from tunnelbridge_cmd, and by TileLoop_Industry() and TileLoop_Track() |
8227
9529f32a20fa
(svn r11266) -Documentation: Add a few comments. Parts of BigBB's work on shores
belugas
parents:
8041
diff
changeset
|
1032 |
* |
9529f32a20fa
(svn r11266) -Documentation: Add a few comments. Parts of BigBB's work on shores
belugas
parents:
8041
diff
changeset
|
1033 |
* @param tile the water/shore tile that floods |
9529f32a20fa
(svn r11266) -Documentation: Add a few comments. Parts of BigBB's work on shores
belugas
parents:
8041
diff
changeset
|
1034 |
*/ |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
1035 |
void TileLoop_Water(TileIndex tile) |
0 | 1036 |
{ |
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1037 |
switch (GetFloodingBehaviour(tile)) { |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1038 |
case FLOOD_ACTIVE: |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1039 |
for (Direction dir = DIR_BEGIN; dir < DIR_END; dir++) { |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1040 |
TileIndex dest = AddTileIndexDiffCWrap(tile, TileIndexDiffCByDir(dir)); |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1041 |
if (dest == INVALID_TILE) continue; |
9180
f39e3460f0ab
(svn r12350) -Fix [FS#1836](r11947): do not try ti flood water tile (performance increase)
glx
parents:
9112
diff
changeset
|
1042 |
/* do not try to flood water tiles - increases performance a lot */ |
f39e3460f0ab
(svn r12350) -Fix [FS#1836](r11947): do not try ti flood water tile (performance increase)
glx
parents:
9112
diff
changeset
|
1043 |
if (IsTileType(dest, MP_WATER)) continue; |
2989 | 1044 |
|
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1045 |
uint z_dest; |
9297
94a4efa5de6e
(svn r12541) -Codechange: Declare Slope enum as bit set, and remove some (then) unneeded casts.
frosch
parents:
9283
diff
changeset
|
1046 |
Slope slope_dest = GetFoundationSlope(dest, &z_dest) & ~SLOPE_HALFTILE_MASK & ~SLOPE_STEEP; |
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1047 |
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
|
1048 |
|
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1049 |
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
|
1050 |
|
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1051 |
DoFloodTile(dest); |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1052 |
} |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1053 |
break; |
43
3b93861c5478
(svn r44) Fix: Coast line near edge of map and near oilrigs (Dribbel)
dominik
parents:
39
diff
changeset
|
1054 |
|
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1055 |
case FLOOD_DRYUP: { |
9297
94a4efa5de6e
(svn r12541) -Codechange: Declare Slope enum as bit set, and remove some (then) unneeded casts.
frosch
parents:
9283
diff
changeset
|
1056 |
Slope slope_here = GetFoundationSlope(tile, NULL) & ~SLOPE_HALFTILE_MASK & ~SLOPE_STEEP; |
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1057 |
uint check_dirs = _flood_from_dirs[slope_here]; |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1058 |
uint dir; |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1059 |
FOR_EACH_SET_BIT(dir, check_dirs) { |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1060 |
TileIndex dest = AddTileIndexDiffCWrap(tile, TileIndexDiffCByDir((Direction)dir)); |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1061 |
if (dest == INVALID_TILE) continue; |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1062 |
|
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1063 |
FloodingBehaviour dest_behaviour = GetFloodingBehaviour(dest); |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1064 |
if ((dest_behaviour == FLOOD_ACTIVE) || (dest_behaviour == FLOOD_PASSIVE)) return; |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1065 |
} |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1066 |
DoDryUp(tile); |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1067 |
break; |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1068 |
} |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1069 |
|
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1070 |
default: return; |
2639 | 1071 |
} |
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1072 |
} |
43
3b93861c5478
(svn r44) Fix: Coast line near edge of map and near oilrigs (Dribbel)
dominik
parents:
39
diff
changeset
|
1073 |
|
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1074 |
void ConvertGroundTilesIntoWaterTiles() |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1075 |
{ |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1076 |
TileIndex tile; |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1077 |
uint z; |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1078 |
Slope slope; |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1079 |
|
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1080 |
for (tile = 0; tile < MapSize(); ++tile) { |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1081 |
slope = GetTileSlope(tile, &z); |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1082 |
if (IsTileType(tile, MP_CLEAR) && z == 0) { |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1083 |
/* Make both water for tiles at level 0 |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1084 |
* and make shore, as that looks much better |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1085 |
* during the generation. */ |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1086 |
switch (slope) { |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1087 |
case SLOPE_FLAT: |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1088 |
MakeWater(tile); |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1089 |
break; |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1090 |
|
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1091 |
case SLOPE_N: |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1092 |
case SLOPE_E: |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1093 |
case SLOPE_S: |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1094 |
case SLOPE_W: |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1095 |
MakeShore(tile); |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1096 |
break; |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1097 |
|
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1098 |
default: |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1099 |
uint check_dirs = _flood_from_dirs[slope & ~SLOPE_STEEP]; |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1100 |
uint dir; |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1101 |
FOR_EACH_SET_BIT(dir, check_dirs) { |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1102 |
TileIndex dest = TILE_ADD(tile, TileOffsByDir((Direction)dir)); |
9297
94a4efa5de6e
(svn r12541) -Codechange: Declare Slope enum as bit set, and remove some (then) unneeded casts.
frosch
parents:
9283
diff
changeset
|
1103 |
Slope slope_dest = GetTileSlope(dest, NULL) & ~SLOPE_STEEP; |
8909
fa15e9afad2f
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8882
diff
changeset
|
1104 |
if (slope_dest == SLOPE_FLAT || IsSlopeWithOneCornerRaised(slope_dest)) { |
8876
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1105 |
MakeShore(tile); |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1106 |
break; |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1107 |
} |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1108 |
} |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1109 |
break; |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1110 |
} |
a0b7938c6082
(svn r11947) -Feature: Make use of new sprites added by Action5 type 0D.
frosch
parents:
8864
diff
changeset
|
1111 |
} |
2639 | 1112 |
} |
0 | 1113 |
} |
1114 |
||
9112
ec6800eaa340
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch
parents:
9092
diff
changeset
|
1115 |
static TrackStatus GetTileTrackStatus_Water(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side) |
0 | 1116 |
{ |
3423
03e0e97abf41
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3422
diff
changeset
|
1117 |
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
|
1118 |
|
b775328748af
(svn r5606) Replace some magic numbers by proper TrackBits enums and macros
tron
parents:
4101
diff
changeset
|
1119 |
TrackBits ts; |
b775328748af
(svn r5606) Replace some magic numbers by proper TrackBits enums and macros
tron
parents:
4101
diff
changeset
|
1120 |
|
2951 | 1121 |
if (mode != TRANSPORT_WATER) return 0; |
0 | 1122 |
|
3423
03e0e97abf41
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3422
diff
changeset
|
1123 |
switch (GetWaterTileType(tile)) { |
8967
0b56f973bcf0
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138
parents:
8955
diff
changeset
|
1124 |
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
|
1125 |
case WATER_TILE_COAST: ts = (TrackBits)coast_tracks[GetTileSlope(tile, NULL) & 0xF]; break; |
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
6486
diff
changeset
|
1126 |
case WATER_TILE_LOCK: ts = AxisToTrackBits(DiagDirToAxis(GetLockDirection(tile))); break; |
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
6486
diff
changeset
|
1127 |
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
|
1128 |
default: return 0; |
0 | 1129 |
} |
3900
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
1130 |
if (TileX(tile) == 0) { |
6928
44797333bcbf
(svn r9568) -Documentation: doxygen and comment changes: Root of src is finally done. Now, time to start clearing as much as possible
belugas
parents:
6923
diff
changeset
|
1131 |
/* 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
|
1132 |
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
|
1133 |
} |
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
1134 |
if (TileY(tile) == 0) { |
6928
44797333bcbf
(svn r9568) -Documentation: doxygen and comment changes: Root of src is finally done. Now, time to start clearing as much as possible
belugas
parents:
6923
diff
changeset
|
1135 |
/* 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
|
1136 |
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
|
1137 |
} |
9112
ec6800eaa340
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch
parents:
9092
diff
changeset
|
1138 |
return CombineTrackStatus(TrackBitsToTrackdirBits(ts), TRACKDIR_BIT_NONE); |
0 | 1139 |
} |
1140 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1902
diff
changeset
|
1141 |
static void ClickTile_Water(TileIndex tile) |
0 | 1142 |
{ |
6507
26c45f253d31
(svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents:
6486
diff
changeset
|
1143 |
if (GetWaterTileType(tile) == WATER_TILE_DEPOT) { |
3423
03e0e97abf41
(svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents:
3422
diff
changeset
|
1144 |
TileIndex tile2 = GetOtherShipDepotTile(tile); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
168
diff
changeset
|
1145 |
|
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
|
1146 |
ShowDepotWindow(tile < tile2 ? tile : tile2, VEH_SHIP); |
0 | 1147 |
} |
1148 |
} |
|
1149 |
||
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
|
1150 |
static void ChangeTileOwner_Water(TileIndex tile, PlayerID old_player, PlayerID new_player) |
0 | 1151 |
{ |
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
|
1152 |
if (!IsTileOwner(tile, old_player)) return; |
0 | 1153 |
|
4848
56549aa3e234
(svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents:
4638
diff
changeset
|
1154 |
if (new_player != PLAYER_SPECTATOR) { |
1902 | 1155 |
SetTileOwner(tile, new_player); |
9016
2b722bde93ec
(svn r12095) -Fix [FS#1703]: when a company bankrupts, remove drive-through road stops, ship depots and buoys too. Update owners of water and road.
smatz
parents:
9015
diff
changeset
|
1156 |
return; |
0 | 1157 |
} |
9016
2b722bde93ec
(svn r12095) -Fix [FS#1703]: when a company bankrupts, remove drive-through road stops, ship depots and buoys too. Update owners of water and road.
smatz
parents:
9015
diff
changeset
|
1158 |
|
2b722bde93ec
(svn r12095) -Fix [FS#1703]: when a company bankrupts, remove drive-through road stops, ship depots and buoys too. Update owners of water and road.
smatz
parents:
9015
diff
changeset
|
1159 |
/* Remove depot */ |
2b722bde93ec
(svn r12095) -Fix [FS#1703]: when a company bankrupts, remove drive-through road stops, ship depots and buoys too. Update owners of water and road.
smatz
parents:
9015
diff
changeset
|
1160 |
if (IsShipDepot(tile)) DoCommand(tile, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR); |
2b722bde93ec
(svn r12095) -Fix [FS#1703]: when a company bankrupts, remove drive-through road stops, ship depots and buoys too. Update owners of water and road.
smatz
parents:
9015
diff
changeset
|
1161 |
|
2b722bde93ec
(svn r12095) -Fix [FS#1703]: when a company bankrupts, remove drive-through road stops, ship depots and buoys too. Update owners of water and road.
smatz
parents:
9015
diff
changeset
|
1162 |
/* Set owner of canals and locks ... and also canal under dock there was before. |
2b722bde93ec
(svn r12095) -Fix [FS#1703]: when a company bankrupts, remove drive-through road stops, ship depots and buoys too. Update owners of water and road.
smatz
parents:
9015
diff
changeset
|
1163 |
* Check if the new owner after removing depot isn't OWNER_WATER. */ |
2b722bde93ec
(svn r12095) -Fix [FS#1703]: when a company bankrupts, remove drive-through road stops, ship depots and buoys too. Update owners of water and road.
smatz
parents:
9015
diff
changeset
|
1164 |
if (IsTileOwner(tile, old_player)) SetTileOwner(tile, OWNER_NONE); |
0 | 1165 |
} |
1166 |
||
8615
6b91ca653bad
(svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
8612
diff
changeset
|
1167 |
static VehicleEnterTileStatus VehicleEnter_Water(Vehicle *v, TileIndex tile, int x, int y) |
0 | 1168 |
{ |
6317
c73bda71ac16
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents:
6205
diff
changeset
|
1169 |
return VETSB_CONTINUE; |
0 | 1170 |
} |
1171 |
||
7990
70039e33e893
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents:
7939
diff
changeset
|
1172 |
static CommandCost TerraformTile_Water(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new) |
70039e33e893
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents:
7939
diff
changeset
|
1173 |
{ |
70039e33e893
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents:
7939
diff
changeset
|
1174 |
/* Canals can't be terraformed */ |
8235
fc75e5ad02b6
(svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium
parents:
8227
diff
changeset
|
1175 |
if (IsWaterTile(tile) && IsCanal(tile)) return_cmd_error(STR_MUST_DEMOLISH_CANAL_FIRST); |
7990
70039e33e893
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents:
7939
diff
changeset
|
1176 |
|
70039e33e893
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents:
7939
diff
changeset
|
1177 |
return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
70039e33e893
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents:
7939
diff
changeset
|
1178 |
} |
70039e33e893
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents:
7939
diff
changeset
|
1179 |
|
0 | 1180 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1181 |
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
|
1182 |
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
|
1183 |
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
|
1184 |
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
|
1185 |
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
|
1186 |
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
|
1187 |
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
|
1188 |
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
|
1189 |
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
|
1190 |
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
|
1191 |
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
|
1192 |
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
|
1193 |
VehicleEnter_Water, /* vehicle_enter_tile_proc */ |
7831
5dded9b03500
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7829
diff
changeset
|
1194 |
GetFoundation_Water, /* get_foundation_proc */ |
7990
70039e33e893
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents:
7939
diff
changeset
|
1195 |
TerraformTile_Water, /* terraform_tile_proc */ |
0 | 1196 |
}; |