src/water_cmd.cpp
author peter1138
Thu, 05 Apr 2007 07:49:04 +0000
changeset 6427 7dc1012757d8
parent 6334 a8f01a805813
child 6432 226650eb2ef3
permissions -rw-r--r--
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     3
#include "stdafx.h"
1891
862800791170 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1796
diff changeset
     4
#include "openttd.h"
3189
bf047128dee7 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents: 3183
diff changeset
     5
#include "bridge_map.h"
6160
fa42299e967e (svn r8908) -Codechange: declaration of DrawBridgeMiddle does not belong in a map accessors header.
rubidium
parents: 6134
diff changeset
     6
#include "bridge.h"
6134
871305fd9ab7 (svn r8876) -Fix
tron
parents: 6106
diff changeset
     7
#include "cmd_helper.h"
3338
7cff208f0446 (svn r4120) Use the new station functions where appropriate
tron
parents: 3275
diff changeset
     8
#include "station_map.h"
1363
775a7ee52369 (svn r1867) Include tables/sprites.h only in files which need it
tron
parents: 1359
diff changeset
     9
#include "table/sprites.h"
507
04b5403aaf6b (svn r815) Include strings.h only in the files which need it.
tron
parents: 497
diff changeset
    10
#include "table/strings.h"
2163
b17b313113a0 (svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents: 2148
diff changeset
    11
#include "functions.h"
679
04ca2cd69420 (svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents: 588
diff changeset
    12
#include "map.h"
1209
2e00193652b2 (svn r1713) Split off several functions which query/set information about a single tile from map.h and put them into a seperate file tile.h
tron
parents: 1132
diff changeset
    13
#include "tile.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
#include "vehicle.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
#include "viewport.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
#include "command.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    17
#include "town.h"
149
5f7d4b21df01 (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents: 43
diff changeset
    18
#include "news.h"
337
cbe0c766c947 (svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents: 314
diff changeset
    19
#include "sound.h"
1313
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents: 1214
diff changeset
    20
#include "depot.h"
1752
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1632
diff changeset
    21
#include "vehicle_gui.h"
2676
59b65b4fb480 (svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents: 2657
diff changeset
    22
#include "train.h"
3111
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents: 3017
diff changeset
    23
#include "water_map.h"
5210
3415ef43c70a (svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents: 4848
diff changeset
    24
#include "newgrf.h"
149
5f7d4b21df01 (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents: 43
diff changeset
    25
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5210
diff changeset
    26
static const SpriteID _water_shore_sprites[] = {
2517
6e3832ddd0f6 (svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents: 2502
diff changeset
    27
	0,
6e3832ddd0f6 (svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents: 2502
diff changeset
    28
	SPR_SHORE_TILEH_1,
6e3832ddd0f6 (svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents: 2502
diff changeset
    29
	SPR_SHORE_TILEH_2,
6e3832ddd0f6 (svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents: 2502
diff changeset
    30
	SPR_SHORE_TILEH_3,
6e3832ddd0f6 (svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents: 2502
diff changeset
    31
	SPR_SHORE_TILEH_4,
6e3832ddd0f6 (svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents: 2502
diff changeset
    32
	0,
6e3832ddd0f6 (svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents: 2502
diff changeset
    33
	SPR_SHORE_TILEH_6,
6e3832ddd0f6 (svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents: 2502
diff changeset
    34
	0,
6e3832ddd0f6 (svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents: 2502
diff changeset
    35
	SPR_SHORE_TILEH_8,
6e3832ddd0f6 (svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents: 2502
diff changeset
    36
	SPR_SHORE_TILEH_9,
6e3832ddd0f6 (svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents: 2502
diff changeset
    37
	0,
6e3832ddd0f6 (svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents: 2502
diff changeset
    38
	0,
6e3832ddd0f6 (svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents: 2502
diff changeset
    39
	SPR_SHORE_TILEH_12,
6e3832ddd0f6 (svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents: 2502
diff changeset
    40
	0,
6e3832ddd0f6 (svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents: 2502
diff changeset
    41
	0
2261
d3554e5d3e86 (svn r2781) Fix some of the issues with variables in .h files.
ludde
parents: 2186
diff changeset
    42
};
d3554e5d3e86 (svn r2781) Fix some of the issues with variables in .h files.
ludde
parents: 2186
diff changeset
    43
d3554e5d3e86 (svn r2781) Fix some of the issues with variables in .h files.
ludde
parents: 2186
diff changeset
    44
5940
3bb99a7ad58f (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: 5905
diff changeset
    45
static Vehicle *FindFloodableVehicleOnTile(TileIndex tile);
149
5f7d4b21df01 (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents: 43
diff changeset
    46
static void FloodVehicle(Vehicle *v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    47
1784
d0698aac0c2e (svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents: 1752
diff changeset
    48
/** Build a ship depot.
3491
35d747bb5e82 (svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents: 3439
diff changeset
    49
 * @param tile tile where ship depot is built
6134
871305fd9ab7 (svn r8876) -Fix
tron
parents: 6106
diff changeset
    50
 * @param p1 bit 0 depot orientation (Axis)
1784
d0698aac0c2e (svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents: 1752
diff changeset
    51
 * @param p2 unused
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    52
 */
3491
35d747bb5e82 (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
    53
int32 CmdBuildShipDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    54
{
3491
35d747bb5e82 (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
    55
	TileIndex tile2;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 168
diff changeset
    56
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
	int32 cost, ret;
1313
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents: 1214
diff changeset
    58
	Depot *depot;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    59
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    61
1784
d0698aac0c2e (svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents: 1752
diff changeset
    62
	if (!EnsureNoVehicle(tile)) return CMD_ERROR;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    63
6134
871305fd9ab7 (svn r8876) -Fix
tron
parents: 6106
diff changeset
    64
	Axis axis = Extract<Axis, 0>(p1);
871305fd9ab7 (svn r8876) -Fix
tron
parents: 6106
diff changeset
    65
871305fd9ab7 (svn r8876) -Fix
tron
parents: 6106
diff changeset
    66
	tile2 = tile + (axis == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
1784
d0698aac0c2e (svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents: 1752
diff changeset
    67
	if (!EnsureNoVehicle(tile2)) return CMD_ERROR;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
	if (!IsClearWaterTile(tile) || !IsClearWaterTile(tile2))
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
		return_cmd_error(STR_3801_MUST_BE_BUILT_ON_WATER);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5210
diff changeset
    72
	if (IsBridgeAbove(tile) || IsBridgeAbove(tile2)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5210
diff changeset
    73
3491
35d747bb5e82 (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
    74
	ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
1784
d0698aac0c2e (svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents: 1752
diff changeset
    75
	if (CmdFailed(ret)) return CMD_ERROR;
3491
35d747bb5e82 (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
    76
	ret = DoCommand(tile2, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
1784
d0698aac0c2e (svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents: 1752
diff changeset
    77
	if (CmdFailed(ret)) return CMD_ERROR;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 168
diff changeset
    78
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    79
	// pretend that we're not making land from the water even though we actually are.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    80
	cost = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    81
1313
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents: 1214
diff changeset
    82
	depot = AllocateDepot();
1784
d0698aac0c2e (svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents: 1752
diff changeset
    83
	if (depot == NULL) return CMD_ERROR;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    85
	if (flags & DC_EXEC) {
1313
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents: 1214
diff changeset
    86
		depot->xy = tile;
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents: 1214
diff changeset
    87
		depot->town_index = ClosestTownFromTile(tile, (uint)-1)->index;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
6134
871305fd9ab7 (svn r8876) -Fix
tron
parents: 6106
diff changeset
    89
		MakeShipDepot(tile,  _current_player, DEPOT_NORTH, axis);
871305fd9ab7 (svn r8876) -Fix
tron
parents: 6106
diff changeset
    90
		MakeShipDepot(tile2, _current_player, DEPOT_SOUTH, axis);
3372
f6afa98d5219 (svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents: 3338
diff changeset
    91
		MarkTileDirtyByTile(tile);
f6afa98d5219 (svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents: 3338
diff changeset
    92
		MarkTileDirtyByTile(tile2);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
	return cost + _price.build_ship_depot;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1902
diff changeset
    98
static int32 RemoveShipDepot(TileIndex tile, uint32 flags)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
{
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1902
diff changeset
   100
	TileIndex tile2;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   101
3373
2838aadd3a28 (svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents: 3372
diff changeset
   102
	if (!IsShipDepot(tile)) return CMD_ERROR;
2951
2de6d3a59743 (svn r3510) Fiddle with whitespace and parentheses
tron
parents: 2934
diff changeset
   103
	if (!CheckTileOwnership(tile)) return CMD_ERROR;
2de6d3a59743 (svn r3510) Fiddle with whitespace and parentheses
tron
parents: 2934
diff changeset
   104
	if (!EnsureNoVehicle(tile)) return CMD_ERROR;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
3373
2838aadd3a28 (svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents: 3372
diff changeset
   106
	tile2 = GetOtherShipDepotTile(tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
2951
2de6d3a59743 (svn r3510) Fiddle with whitespace and parentheses
tron
parents: 2934
diff changeset
   108
	if (!EnsureNoVehicle(tile2)) return CMD_ERROR;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   109
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
	if (flags & DC_EXEC) {
3373
2838aadd3a28 (svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents: 3372
diff changeset
   111
		/* Kill the depot, which is registered at the northernmost tile. Use that one */
4388
c8a66d26e146 (svn r6141) -Codechange: introduced DepotID and used it as much as possible
truelight
parents: 4344
diff changeset
   112
		DeleteDepot(GetDepotByTile(tile2 < tile ? tile2 : tile));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
3111
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents: 3017
diff changeset
   114
		MakeWater(tile);
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents: 3017
diff changeset
   115
		MakeWater(tile2);
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents: 3017
diff changeset
   116
		MarkTileDirtyByTile(tile);
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents: 3017
diff changeset
   117
		MarkTileDirtyByTile(tile2);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   118
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
	return _price.remove_ship_depot;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   122
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   123
// build a shiplift
3157
3f35e2d9c8e3 (svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents: 3111
diff changeset
   124
static int32 DoBuildShiplift(TileIndex tile, DiagDirection dir, uint32 flags)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   125
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   126
	int32 ret;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   127
	int delta;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   128
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   129
	// middle tile
3491
35d747bb5e82 (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
   130
	ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
2737
fb1556b8f5e0 (svn r3282) - Codechange: Replace tests against CMD_ERROR with CmdFailed()
peter1138
parents: 2676
diff changeset
   131
	if (CmdFailed(ret)) return CMD_ERROR;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 168
diff changeset
   132
4559
aa0c13e39840 (svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents: 4434
diff changeset
   133
	delta = TileOffsByDiagDir(dir);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   134
	// lower tile
3491
35d747bb5e82 (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
   135
	ret = DoCommand(tile - delta, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
2737
fb1556b8f5e0 (svn r3282) - Codechange: Replace tests against CMD_ERROR with CmdFailed()
peter1138
parents: 2676
diff changeset
   136
	if (CmdFailed(ret)) return CMD_ERROR;
3636
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3491
diff changeset
   137
	if (GetTileSlope(tile - delta, NULL) != SLOPE_FLAT) {
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3491
diff changeset
   138
		return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3491
diff changeset
   139
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   140
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   141
	// upper tile
3491
35d747bb5e82 (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
   142
	ret = DoCommand(tile + delta, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
2737
fb1556b8f5e0 (svn r3282) - Codechange: Replace tests against CMD_ERROR with CmdFailed()
peter1138
parents: 2676
diff changeset
   143
	if (CmdFailed(ret)) return CMD_ERROR;
3636
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3491
diff changeset
   144
	if (GetTileSlope(tile + delta, NULL) != SLOPE_FLAT) {
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3491
diff changeset
   145
		return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3491
diff changeset
   146
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5210
diff changeset
   148
	if ((MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) ||
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5210
diff changeset
   149
	    (MayHaveBridgeAbove(tile - delta) && IsBridgeAbove(tile - delta)) ||
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5210
diff changeset
   150
	    (MayHaveBridgeAbove(tile + delta) && IsBridgeAbove(tile + delta))) {
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5210
diff changeset
   151
		return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5210
diff changeset
   152
	}
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5210
diff changeset
   153
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   154
	if (flags & DC_EXEC) {
3940
8965b9bfaabc (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
   155
		MakeLock(tile, _current_player, dir);
3372
f6afa98d5219 (svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents: 3338
diff changeset
   156
		MarkTileDirtyByTile(tile);
f6afa98d5219 (svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents: 3338
diff changeset
   157
		MarkTileDirtyByTile(tile - delta);
f6afa98d5219 (svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents: 3338
diff changeset
   158
		MarkTileDirtyByTile(tile + delta);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   159
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   160
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   161
	return _price.clear_water * 22 >> 3;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   162
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   163
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1902
diff changeset
   164
static int32 RemoveShiplift(TileIndex tile, uint32 flags)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   165
{
4559
aa0c13e39840 (svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents: 4434
diff changeset
   166
	TileIndexDiff delta = TileOffsByDiagDir(GetLockDirection(tile));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   167
3940
8965b9bfaabc (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
   168
	if (!CheckTileOwnership(tile)) return CMD_ERROR;
8965b9bfaabc (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
   169
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   170
	// make sure no vehicle is on the tile.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   171
	if (!EnsureNoVehicle(tile) || !EnsureNoVehicle(tile + delta) || !EnsureNoVehicle(tile - delta))
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   172
		return CMD_ERROR;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   173
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   174
	if (flags & DC_EXEC) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   175
		DoClearSquare(tile);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   176
		DoClearSquare(tile + delta);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   177
		DoClearSquare(tile - delta);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   178
	}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 168
diff changeset
   179
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   180
	return _price.clear_water * 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   182
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1902
diff changeset
   183
static void MarkTilesAroundDirty(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   185
	MarkTileDirtyByTile(TILE_ADDXY(tile, 0, 1));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   186
	MarkTileDirtyByTile(TILE_ADDXY(tile, 0, -1));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   187
	MarkTileDirtyByTile(TILE_ADDXY(tile, 1, 0));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   188
	MarkTileDirtyByTile(TILE_ADDXY(tile, -1, 0));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   189
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   190
1796
614d996f6be7 (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
   191
/** Builds a lock (ship-lift)
3491
35d747bb5e82 (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
   192
 * @param tile tile where to place the lock
1796
614d996f6be7 (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
   193
 * @param p1 unused
614d996f6be7 (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
   194
 * @param p2 unused
614d996f6be7 (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
   195
 */
3491
35d747bb5e82 (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
   196
int32 CmdBuildLock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   197
{
3157
3f35e2d9c8e3 (svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents: 3111
diff changeset
   198
	DiagDirection dir;
889
64d2f7d5f02b (svn r1375) -Fix: [1050990] Buying trains sometimes accounted for incorrectly. Was the result of the cost getting reset in a recursive call of docommand. That is fixed. In addition all cost-commands are typed explicitely. Please do not forget to do so or your costs will be credited to construction if you are unlucky.
darkvater
parents: 863
diff changeset
   199
64d2f7d5f02b (svn r1375) -Fix: [1050990] Buying trains sometimes accounted for incorrectly. Was the result of the cost getting reset in a recursive call of docommand. That is fixed. In addition all cost-commands are typed explicitely. Please do not forget to do so or your costs will be credited to construction if you are unlucky.
darkvater
parents: 863
diff changeset
   200
	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   201
3157
3f35e2d9c8e3 (svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents: 3111
diff changeset
   202
	switch (GetTileSlope(tile, NULL)) {
3636
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3491
diff changeset
   203
		case SLOPE_SW: dir = DIAGDIR_SW; break;
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3491
diff changeset
   204
		case SLOPE_SE: dir = DIAGDIR_SE; break;
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3491
diff changeset
   205
		case SLOPE_NW: dir = DIAGDIR_NW; break;
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3491
diff changeset
   206
		case SLOPE_NE: dir = DIAGDIR_NE; break;
3157
3f35e2d9c8e3 (svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents: 3111
diff changeset
   207
		default: return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
1796
614d996f6be7 (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
   208
	}
3157
3f35e2d9c8e3 (svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents: 3111
diff changeset
   209
	return DoBuildShiplift(tile, dir, flags);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   210
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   211
1796
614d996f6be7 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1784
diff changeset
   212
/** Build a piece of canal.
3491
35d747bb5e82 (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
   213
 * @param tile end tile of stretch-dragging
1796
614d996f6be7 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1784
diff changeset
   214
 * @param p1 start tile of stretch-dragging
6286
a67f2c376804 (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: 6259
diff changeset
   215
 * @param p2 ctrl pressed - toggles ocean / canals at sealevel (ocean only allowed in the scenario editor)
1796
614d996f6be7 (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
   216
 */
3491
35d747bb5e82 (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
   217
int32 CmdBuildCanal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   218
{
3177
74a90a745e49 (svn r3813) Simplify strange control flow
tron
parents: 3165
diff changeset
   219
	int32 cost;
1632
10c391e108b7 (svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents: 1605
diff changeset
   220
	int size_x, size_y;
3491
35d747bb5e82 (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
   221
	int x;
35d747bb5e82 (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
   222
	int y;
1796
614d996f6be7 (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
   223
	int sx, sy;
614d996f6be7 (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
   224
2934
3f29a7212713 (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
   225
	if (p1 >= MapSize()) return CMD_ERROR;
6286
a67f2c376804 (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: 6259
diff changeset
   226
	/* Outside of the editor you can only build canals, not oceans */
a67f2c376804 (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: 6259
diff changeset
   227
	if (HASBIT(p2, 0) && _game_mode != GM_EDITOR) return CMD_ERROR;
1796
614d996f6be7 (svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents: 1784
diff changeset
   228
3491
35d747bb5e82 (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
   229
	x = TileX(tile);
35d747bb5e82 (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
   230
	y = TileY(tile);
1796
614d996f6be7 (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
   231
	sx = TileX(p1);
614d996f6be7 (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
   232
	sy = TileY(p1);
1632
10c391e108b7 (svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents: 1605
diff changeset
   233
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   234
	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   235
6106
2898cd9417fd (svn r8841) -Fix
tron
parents: 5991
diff changeset
   236
	if (x < sx) Swap(x, sx);
2898cd9417fd (svn r8841) -Fix
tron
parents: 5991
diff changeset
   237
	if (y < sy) Swap(y, sy);
1632
10c391e108b7 (svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents: 1605
diff changeset
   238
	size_x = (x - sx) + 1;
10c391e108b7 (svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents: 1605
diff changeset
   239
	size_y = (y - sy) + 1;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 168
diff changeset
   240
1796
614d996f6be7 (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
   241
	/* Outside the editor you can only drag canals, and not areas */
614d996f6be7 (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
   242
	if (_game_mode != GM_EDITOR && (sx != x && sy != y)) return CMD_ERROR;
614d996f6be7 (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
   243
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   244
	cost = 0;
1981
3c9c682f1212 (svn r2487) Replace TILE_XY by TileXY/TileDiffXY
tron
parents: 1980
diff changeset
   245
	BEGIN_TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) {
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5210
diff changeset
   246
		int32 ret;
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5210
diff changeset
   247
3636
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3491
diff changeset
   248
		if (GetTileSlope(tile, NULL) != SLOPE_FLAT) {
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3491
diff changeset
   249
			return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3491
diff changeset
   250
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   251
3183
90c676e6a50d (svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents: 3177
diff changeset
   252
		// can't make water of water!
4087
d6a79200cb20 (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
   253
		if (IsTileType(tile, MP_WATER) && (!IsTileOwner(tile, OWNER_WATER) || HASBIT(p2, 0))) continue;
1632
10c391e108b7 (svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents: 1605
diff changeset
   254
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5210
diff changeset
   255
		ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5210
diff changeset
   256
		if (CmdFailed(ret)) return ret;
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5210
diff changeset
   257
		cost += ret;
3183
90c676e6a50d (svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents: 3177
diff changeset
   258
3189
bf047128dee7 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents: 3183
diff changeset
   259
		if (flags & DC_EXEC) {
5516
1e0db37c23d3 (svn r7817) -Fix (r7573): Bridge merge broke building canals at level 0.
Darkvater
parents: 5475
diff changeset
   260
			if (TileHeight(tile) == 0 && HASBIT(p2, 0)) {
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5210
diff changeset
   261
				MakeWater(tile);
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5210
diff changeset
   262
			} else {
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5210
diff changeset
   263
				MakeCanal(tile, _current_player);
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5210
diff changeset
   264
			}
3189
bf047128dee7 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents: 3183
diff changeset
   265
			MarkTileDirtyByTile(tile);
bf047128dee7 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents: 3183
diff changeset
   266
			MarkTilesAroundDirty(tile);
bf047128dee7 (svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents: 3183
diff changeset
   267
		}
3183
90c676e6a50d (svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents: 3177
diff changeset
   268
90c676e6a50d (svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents: 3177
diff changeset
   269
		cost += _price.clear_water;
1632
10c391e108b7 (svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
Darkvater
parents: 1605
diff changeset
   270
	} END_TILE_LOOP(tile, size_x, size_y, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   271
3183
90c676e6a50d (svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents: 3177
diff changeset
   272
	if (cost == 0) {
90c676e6a50d (svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents: 3177
diff changeset
   273
		return_cmd_error(STR_1007_ALREADY_BUILT);
90c676e6a50d (svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents: 3177
diff changeset
   274
	} else {
90c676e6a50d (svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents: 3177
diff changeset
   275
		return cost;
90c676e6a50d (svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents: 3177
diff changeset
   276
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   277
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   278
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1902
diff changeset
   279
static int32 ClearTile_Water(TileIndex tile, byte flags)
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1902
diff changeset
   280
{
3425
5411e9c8b6c8 (svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents: 3423
diff changeset
   281
	switch (GetWaterTileType(tile)) {
6181
2d0ac0598453 (svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents: 6160
diff changeset
   282
		case WATER_TILE_CLEAR:
3425
5411e9c8b6c8 (svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents: 3423
diff changeset
   283
			if (flags & DC_NO_WATER) return_cmd_error(STR_3807_CAN_T_BUILD_ON_WATER);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   284
3425
5411e9c8b6c8 (svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents: 3423
diff changeset
   285
			// Make sure no vehicle is on the tile
5411e9c8b6c8 (svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents: 3423
diff changeset
   286
			if (!EnsureNoVehicle(tile)) return CMD_ERROR;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   287
3425
5411e9c8b6c8 (svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents: 3423
diff changeset
   288
			// Make sure it's not an edge tile.
5411e9c8b6c8 (svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents: 3423
diff changeset
   289
			if (!IS_INT_INSIDE(TileX(tile), 1, MapMaxX() - 1) ||
5411e9c8b6c8 (svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents: 3423
diff changeset
   290
					!IS_INT_INSIDE(TileY(tile), 1, MapMaxY() - 1)) {
5411e9c8b6c8 (svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents: 3423
diff changeset
   291
				return_cmd_error(STR_0002_TOO_CLOSE_TO_EDGE_OF_MAP);
5411e9c8b6c8 (svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents: 3423
diff changeset
   292
			}
3017
a75caf4efa2d (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
   293
3940
8965b9bfaabc (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
   294
			if (GetTileOwner(tile) != OWNER_WATER && !CheckTileOwnership(tile)) return CMD_ERROR;
8965b9bfaabc (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
   295
3017
a75caf4efa2d (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
   296
			if (flags & DC_EXEC) DoClearSquare(tile);
3425
5411e9c8b6c8 (svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents: 3423
diff changeset
   297
			return _price.clear_water;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   298
6181
2d0ac0598453 (svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents: 6160
diff changeset
   299
		case WATER_TILE_COAST: {
3636
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3491
diff changeset
   300
			Slope slope = GetTileSlope(tile, NULL);
3439
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   301
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   302
			// Make sure no vehicle is on the tile
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   303
			if (!EnsureNoVehicle(tile)) return CMD_ERROR;
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   304
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   305
			// Make sure it's not an edge tile.
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   306
			if (!IS_INT_INSIDE(TileX(tile), 1, MapMaxX() - 1) ||
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   307
					!IS_INT_INSIDE(TileY(tile), 1, MapMaxY() - 1)) {
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   308
				return_cmd_error(STR_0002_TOO_CLOSE_TO_EDGE_OF_MAP);
3425
5411e9c8b6c8 (svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents: 3423
diff changeset
   309
			}
5411e9c8b6c8 (svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents: 3423
diff changeset
   310
3439
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   311
			if (flags & DC_EXEC) DoClearSquare(tile);
3636
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3491
diff changeset
   312
			if (slope == SLOPE_N || slope == SLOPE_E || slope == SLOPE_S || slope == SLOPE_W) {
3439
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   313
				return _price.clear_water;
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   314
			} else {
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   315
				return _price.purchase_land;
3425
5411e9c8b6c8 (svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents: 3423
diff changeset
   316
			}
3439
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   317
		}
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   318
6181
2d0ac0598453 (svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents: 6160
diff changeset
   319
		case WATER_TILE_LOCK: {
3439
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   320
			static const TileIndexDiffC _shiplift_tomiddle_offs[] = {
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   321
				{ 0,  0}, {0,  0}, { 0, 0}, {0,  0}, // middle
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   322
				{-1,  0}, {0,  1}, { 1, 0}, {0, -1}, // lower
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   323
				{ 1,  0}, {0, -1}, {-1, 0}, {0,  1}, // upper
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   324
			};
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   325
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   326
			if (flags & DC_AUTO) return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED);
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   327
			if (_current_player == OWNER_WATER) return CMD_ERROR;
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   328
			// move to the middle tile..
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   329
			return RemoveShiplift(tile + ToTileIndexDiff(_shiplift_tomiddle_offs[GetSection(tile)]), flags);
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   330
		}
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   331
6181
2d0ac0598453 (svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents: 6160
diff changeset
   332
		case WATER_TILE_DEPOT:
3425
5411e9c8b6c8 (svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents: 3423
diff changeset
   333
			if (flags & DC_AUTO) return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED);
5411e9c8b6c8 (svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents: 3423
diff changeset
   334
			return RemoveShipDepot(tile, flags);
3439
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   335
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   336
		default:
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   337
			NOT_REACHED();
60f16e7f2573 (svn r4269) We don't use GNU indentation style
tron
parents: 3436
diff changeset
   338
			return 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   339
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   340
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   341
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   342
// return true if a tile is a water tile.
1048
8611c5c02dcb (svn r1549) Clean up some functions:
tron
parents: 1041
diff changeset
   343
static bool IsWateredTile(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   344
{
1214
8262981ac274 (svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents: 1209
diff changeset
   345
	switch (GetTileType(tile)) {
3977
513433ebd092 (svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents: 3940
diff changeset
   346
		case MP_WATER:
4087
d6a79200cb20 (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
   347
			if (!IsCoast(tile)) return true;
d6a79200cb20 (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
   348
d6a79200cb20 (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
   349
			switch (GetTileSlope(tile, NULL)) {
d6a79200cb20 (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
   350
				case SLOPE_W:
d6a79200cb20 (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
   351
				case SLOPE_S:
d6a79200cb20 (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
   352
				case SLOPE_E:
d6a79200cb20 (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
   353
				case SLOPE_N:
d6a79200cb20 (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
   354
					return true;
d6a79200cb20 (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
   355
d6a79200cb20 (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
   356
				default:
d6a79200cb20 (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
   357
					return false;
d6a79200cb20 (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
   358
			}
3977
513433ebd092 (svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents: 3940
diff changeset
   359
5905
422a010c5286 (svn r8528) -Codechange: Rename IsBuoy_() to IsBuoy() now that the naming conflict no longer exists.
celestar
parents: 5749
diff changeset
   360
		case MP_STATION: return IsOilRig(tile) || IsDock(tile) || IsBuoy(tile);
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5210
diff changeset
   361
		default:         return false;
1048
8611c5c02dcb (svn r1549) Clean up some functions:
tron
parents: 1041
diff changeset
   362
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   363
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   364
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   365
// draw a canal styled water tile with dikes around
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1902
diff changeset
   366
void DrawCanalWater(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   367
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   368
	uint wa;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 168
diff changeset
   369
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   370
	// determine the edges around with water.
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   371
	wa = IsWateredTile(TILE_ADDXY(tile, -1, 0)) << 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   372
	wa += IsWateredTile(TILE_ADDXY(tile, 0, 1)) << 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   373
	wa += IsWateredTile(TILE_ADDXY(tile, 1, 0)) << 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   374
	wa += IsWateredTile(TILE_ADDXY(tile, 0, -1)) << 3;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 168
diff changeset
   375
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   376
	if (!(wa & 1)) DrawGroundSprite(SPR_CANALS_BASE + 57, PAL_NONE);
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   377
	if (!(wa & 2)) DrawGroundSprite(SPR_CANALS_BASE + 58, PAL_NONE);
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   378
	if (!(wa & 4)) DrawGroundSprite(SPR_CANALS_BASE + 59, PAL_NONE);
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   379
	if (!(wa & 8)) DrawGroundSprite(SPR_CANALS_BASE + 60, PAL_NONE);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   380
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   381
	// right corner
2989
916f9443345f (svn r3564) Several smaller changes:
tron
parents: 2951
diff changeset
   382
	switch (wa & 0x03) {
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   383
		case 0: DrawGroundSprite(SPR_CANALS_BASE + 57 + 4, PAL_NONE); break;
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   384
		case 3: if (!IsWateredTile(TILE_ADDXY(tile, -1, 1))) DrawGroundSprite(SPR_CANALS_BASE + 57 + 8, PAL_NONE); break;
2989
916f9443345f (svn r3564) Several smaller changes:
tron
parents: 2951
diff changeset
   385
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   386
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   387
	// bottom corner
2989
916f9443345f (svn r3564) Several smaller changes:
tron
parents: 2951
diff changeset
   388
	switch (wa & 0x06) {
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   389
		case 0: DrawGroundSprite(SPR_CANALS_BASE + 57 + 5, PAL_NONE); break;
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   390
		case 6: if (!IsWateredTile(TILE_ADDXY(tile, 1, 1))) DrawGroundSprite(SPR_CANALS_BASE + 57 + 9, PAL_NONE); break;
2989
916f9443345f (svn r3564) Several smaller changes:
tron
parents: 2951
diff changeset
   391
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   392
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   393
	// left corner
2989
916f9443345f (svn r3564) Several smaller changes:
tron
parents: 2951
diff changeset
   394
	switch (wa & 0x0C) {
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   395
		case  0: DrawGroundSprite(SPR_CANALS_BASE + 57 + 6, PAL_NONE); break;
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   396
		case 12: if (!IsWateredTile(TILE_ADDXY(tile, 1, -1))) DrawGroundSprite(SPR_CANALS_BASE + 57 + 10, PAL_NONE); break;
2989
916f9443345f (svn r3564) Several smaller changes:
tron
parents: 2951
diff changeset
   397
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   398
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   399
	// upper corner
2989
916f9443345f (svn r3564) Several smaller changes:
tron
parents: 2951
diff changeset
   400
	switch (wa & 0x09) {
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   401
		case 0: DrawGroundSprite(SPR_CANALS_BASE + 57 + 7, PAL_NONE); break;
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   402
		case 9: if (!IsWateredTile(TILE_ADDXY(tile, -1, -1))) DrawGroundSprite(SPR_CANALS_BASE + 57 + 11, PAL_NONE); break;
2989
916f9443345f (svn r3564) Several smaller changes:
tron
parents: 2951
diff changeset
   403
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   404
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   405
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6181
diff changeset
   406
struct LocksDrawTileStruct {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   407
	int8 delta_x, delta_y, delta_z;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   408
	byte width, height, depth;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   409
	SpriteID image;
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6181
diff changeset
   410
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   411
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   412
#include "table/water_land.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   413
2436
7d5df545bd5d (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2261
diff changeset
   414
static void DrawWaterStuff(const TileInfo *ti, const WaterDrawTileStruct *wdts,
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   415
	SpriteID palette, uint base
1399
61e7c68e9da6 (svn r1903) Replace some casts and macro magic with proper typing, similar to r1902
tron
parents: 1363
diff changeset
   416
)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   417
{
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   418
	DrawGroundSprite(wdts++->image, PAL_NONE);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 168
diff changeset
   419
1399
61e7c68e9da6 (svn r1903) Replace some casts and macro magic with proper typing, similar to r1902
tron
parents: 1363
diff changeset
   420
	for (; wdts->delta_x != 0x80; wdts++) {
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   421
		SpriteID image = wdts->image + base;
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   422
		SpriteID pal;
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   423
6427
7dc1012757d8 (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents: 6334
diff changeset
   424
		if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   425
			SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   426
			pal = PALETTE_TO_TRANSPARENT;
497
4d1c889526ee (svn r787) Invert the sense of the DO_TRANS_BUILDINGS flag to be consistent with its own name and all other DO_* flags.
tron
parents: 473
diff changeset
   427
		} else {
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   428
			pal = palette;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   429
		}
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   430
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   431
		AddSortableSpriteToDraw(image, pal,
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   432
			ti->x + wdts->delta_x, ti->y + wdts->delta_y,
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   433
			wdts->width, wdts->height,
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   434
			wdts->unk, ti->z + wdts->delta_z);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   435
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   436
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   437
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   438
static void DrawTile_Water(TileInfo *ti)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   439
{
3402
812f9dc4baff (svn r4212) -Codechange: Add and make use of an accessor that retrieves the type of a water tile. Add an enum describing the different water tiles
celestar
parents: 3373
diff changeset
   440
	switch (GetWaterTileType(ti->tile)) {
6181
2d0ac0598453 (svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents: 6160
diff changeset
   441
		case WATER_TILE_CLEAR:
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   442
			DrawGroundSprite(SPR_FLAT_WATER_TILE, PAL_NONE);
4087
d6a79200cb20 (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
   443
			if (ti->z != 0 || !IsTileOwner(ti->tile, OWNER_WATER)) DrawCanalWater(ti->tile);
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5210
diff changeset
   444
			DrawBridgeMiddle(ti);
3402
812f9dc4baff (svn r4212) -Codechange: Add and make use of an accessor that retrieves the type of a water tile. Add an enum describing the different water tiles
celestar
parents: 3373
diff changeset
   445
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   446
6181
2d0ac0598453 (svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents: 6160
diff changeset
   447
		case WATER_TILE_COAST:
3636
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3491
diff changeset
   448
			assert(!IsSteepSlope(ti->tileh));
5210
3415ef43c70a (svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents: 4848
diff changeset
   449
			if (_coast_base != 0) {
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   450
				DrawGroundSprite(_coast_base + ti->tileh, PAL_NONE);
5210
3415ef43c70a (svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents: 4848
diff changeset
   451
			} else {
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   452
				DrawGroundSprite(_water_shore_sprites[ti->tileh], PAL_NONE);
5210
3415ef43c70a (svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents: 4848
diff changeset
   453
			}
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5210
diff changeset
   454
			DrawBridgeMiddle(ti);
3402
812f9dc4baff (svn r4212) -Codechange: Add and make use of an accessor that retrieves the type of a water tile. Add an enum describing the different water tiles
celestar
parents: 3373
diff changeset
   455
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   456
6181
2d0ac0598453 (svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents: 6160
diff changeset
   457
		case WATER_TILE_LOCK: {
3425
5411e9c8b6c8 (svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents: 3423
diff changeset
   458
			const WaterDrawTileStruct *t = _shiplift_display_seq[GetSection(ti->tile)];
3402
812f9dc4baff (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
   459
			DrawWaterStuff(ti, t, 0, ti->z > t[3].delta_y ? 24 : 0);
812f9dc4baff (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
   460
		} break;
812f9dc4baff (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
   461
6181
2d0ac0598453 (svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents: 6160
diff changeset
   462
		case WATER_TILE_DEPOT:
3425
5411e9c8b6c8 (svn r4252) -Codechange: Make more use of map accessors. water_cmd is now map access free
celestar
parents: 3423
diff changeset
   463
			DrawWaterStuff(ti, _shipdepot_display_seq[GetSection(ti->tile)], PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)), 0);
3402
812f9dc4baff (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
   464
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   465
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   466
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   467
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   468
void DrawShipDepotSprite(int x, int y, int image)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   469
{
1399
61e7c68e9da6 (svn r1903) Replace some casts and macro magic with proper typing, similar to r1902
tron
parents: 1363
diff changeset
   470
	const WaterDrawTileStruct *wdts = _shipdepot_display_seq[image];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   471
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   472
	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
   473
1399
61e7c68e9da6 (svn r1903) Replace some casts and macro magic with proper typing, similar to r1902
tron
parents: 1363
diff changeset
   474
	for (; wdts->delta_x != 0x80; wdts++) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   475
		Point pt = RemapCoords(wdts->delta_x, wdts->delta_y, wdts->delta_z);
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   476
		DrawSprite(wdts->image, PLAYER_SPRITE_COLOR(_local_player), x + pt.x, y + pt.y);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   477
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   478
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   479
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   480
4231
2823b3643862 (svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents: 4171
diff changeset
   481
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
   482
{
4231
2823b3643862 (svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents: 4171
diff changeset
   483
	uint z;
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   484
	Slope tileh = GetTileSlope(tile, &z);
4231
2823b3643862 (svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents: 4171
diff changeset
   485
2823b3643862 (svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents: 4171
diff changeset
   486
	return z + GetPartialZ(x & 0xF, y & 0xF, tileh);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   487
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   488
3636
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3491
diff changeset
   489
static Slope GetSlopeTileh_Water(TileIndex tile, Slope tileh)
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 168
diff changeset
   490
{
3418
ec9003ebf933 (svn r4242) Pass TileIndex and slope to GetSlopeTileh_*() instead of TileInfo
tron
parents: 3402
diff changeset
   491
	return tileh;
39
d177340ed556 (svn r40) Final slope graphics fix
dominik
parents: 0
diff changeset
   492
}
d177340ed556 (svn r40) Final slope graphics fix
dominik
parents: 0
diff changeset
   493
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1902
diff changeset
   494
static void GetAcceptedCargo_Water(TileIndex tile, AcceptedCargo ac)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   495
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   496
	/* not used */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   497
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   498
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1902
diff changeset
   499
static void GetTileDesc_Water(TileIndex tile, TileDesc *td)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   500
{
3402
812f9dc4baff (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
   501
	switch (GetWaterTileType(tile)) {
6181
2d0ac0598453 (svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents: 6160
diff changeset
   502
		case WATER_TILE_CLEAR:
4087
d6a79200cb20 (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
   503
			if (TilePixelHeight(tile) == 0 || IsTileOwner(tile, OWNER_WATER)) {
3402
812f9dc4baff (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
   504
				td->str = STR_3804_WATER;
812f9dc4baff (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
   505
			} else {
812f9dc4baff (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
   506
				td->str = STR_LANDINFO_CANAL;
812f9dc4baff (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
   507
			}
812f9dc4baff (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
   508
			break;
6181
2d0ac0598453 (svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents: 6160
diff changeset
   509
		case WATER_TILE_COAST: td->str = STR_3805_COAST_OR_RIVERBANK; break;
2d0ac0598453 (svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents: 6160
diff changeset
   510
		case WATER_TILE_LOCK : td->str = STR_LANDINFO_LOCK; break;
2d0ac0598453 (svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents: 6160
diff changeset
   511
		case WATER_TILE_DEPOT: td->str = STR_3806_SHIP_DEPOT; break;
3402
812f9dc4baff (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
   512
		default: assert(0); break;
2951
2de6d3a59743 (svn r3510) Fiddle with whitespace and parentheses
tron
parents: 2934
diff changeset
   513
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   514
1901
03bf9bf99319 (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
   515
	td->owner = GetTileOwner(tile);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   516
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   517
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1902
diff changeset
   518
static void AnimateTile_Water(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   519
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   520
	/* not used */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   521
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   522
1075
4b8af0e57a79 (svn r1576) Clean TileLoopWaterHelper() a bit up
tron
parents: 1048
diff changeset
   523
static void TileLoopWaterHelper(TileIndex tile, const TileIndexDiffC *offs)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   524
{
1075
4b8af0e57a79 (svn r1576) Clean TileLoopWaterHelper() a bit up
tron
parents: 1048
diff changeset
   525
	TileIndex target = TILE_ADD(tile, ToTileIndexDiff(offs[0]));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   526
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   527
	// type of this tile mustn't be water already.
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2549
diff changeset
   528
	if (IsTileType(target, MP_WATER)) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   529
1075
4b8af0e57a79 (svn r1576) Clean TileLoopWaterHelper() a bit up
tron
parents: 1048
diff changeset
   530
	if (TileHeight(TILE_ADD(tile, ToTileIndexDiff(offs[1]))) != 0 ||
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2549
diff changeset
   531
			TileHeight(TILE_ADD(tile, ToTileIndexDiff(offs[2]))) != 0) {
1075
4b8af0e57a79 (svn r1576) Clean TileLoopWaterHelper() a bit up
tron
parents: 1048
diff changeset
   532
		return;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2549
diff changeset
   533
	}
1075
4b8af0e57a79 (svn r1576) Clean TileLoopWaterHelper() a bit up
tron
parents: 1048
diff changeset
   534
4b8af0e57a79 (svn r1576) Clean TileLoopWaterHelper() a bit up
tron
parents: 1048
diff changeset
   535
	if (TileHeight(TILE_ADD(tile, ToTileIndexDiff(offs[3]))) != 0 ||
4b8af0e57a79 (svn r1576) Clean TileLoopWaterHelper() a bit up
tron
parents: 1048
diff changeset
   536
			TileHeight(TILE_ADD(tile, ToTileIndexDiff(offs[4]))) != 0) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   537
		// make coast..
1214
8262981ac274 (svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents: 1209
diff changeset
   538
		switch (GetTileType(target)) {
1076
03a5f2b0a5c2 (svn r1577) Fix: [1103301] Railroad tracks on slopes weren't flooded
tron
parents: 1075
diff changeset
   539
			case MP_RAILWAY: {
3267
feff95208a9f (svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents: 3234
diff changeset
   540
				TrackBits tracks;
3636
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3491
diff changeset
   541
				Slope slope;
3267
feff95208a9f (svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents: 3234
diff changeset
   542
3275
23e21691c3c0 (svn r3987) Fix another bug in r3979 *grumble*
tron
parents: 3268
diff changeset
   543
				if (!IsPlainRailTile(target)) break;
3267
feff95208a9f (svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents: 3234
diff changeset
   544
feff95208a9f (svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents: 3234
diff changeset
   545
				tracks = GetTrackBits(target);
feff95208a9f (svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents: 3234
diff changeset
   546
				slope = GetTileSlope(target, NULL);
1076
03a5f2b0a5c2 (svn r1577) Fix: [1103301] Railroad tracks on slopes weren't flooded
tron
parents: 1075
diff changeset
   547
				if (!(
3636
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3491
diff changeset
   548
							(slope == SLOPE_W && tracks == TRACK_BIT_RIGHT) ||
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3491
diff changeset
   549
							(slope == SLOPE_S && tracks == TRACK_BIT_UPPER) ||
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3491
diff changeset
   550
							(slope == SLOPE_E && tracks == TRACK_BIT_LEFT)  ||
a36cc46e754d (svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents: 3491
diff changeset
   551
							(slope == SLOPE_N && tracks == TRACK_BIT_LOWER)
3267
feff95208a9f (svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents: 3234
diff changeset
   552
						)) {
1076
03a5f2b0a5c2 (svn r1577) Fix: [1103301] Railroad tracks on slopes weren't flooded
tron
parents: 1075
diff changeset
   553
					break;
3267
feff95208a9f (svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents: 3234
diff changeset
   554
				}
1076
03a5f2b0a5c2 (svn r1577) Fix: [1103301] Railroad tracks on slopes weren't flooded
tron
parents: 1075
diff changeset
   555
			}
03a5f2b0a5c2 (svn r1577) Fix: [1103301] Railroad tracks on slopes weren't flooded
tron
parents: 1075
diff changeset
   556
			/* FALLTHROUGH */
03a5f2b0a5c2 (svn r1577) Fix: [1103301] Railroad tracks on slopes weren't flooded
tron
parents: 1075
diff changeset
   557
1075
4b8af0e57a79 (svn r1576) Clean TileLoopWaterHelper() a bit up
tron
parents: 1048
diff changeset
   558
			case MP_CLEAR:
4b8af0e57a79 (svn r1576) Clean TileLoopWaterHelper() a bit up
tron
parents: 1048
diff changeset
   559
			case MP_TREES:
4b8af0e57a79 (svn r1576) Clean TileLoopWaterHelper() a bit up
tron
parents: 1048
diff changeset
   560
				_current_player = OWNER_WATER;
3491
35d747bb5e82 (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
   561
				if (!CmdFailed(DoCommand(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) {
3111
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents: 3017
diff changeset
   562
					MakeShore(target);
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents: 3017
diff changeset
   563
					MarkTileDirtyByTile(target);
1075
4b8af0e57a79 (svn r1576) Clean TileLoopWaterHelper() a bit up
tron
parents: 1048
diff changeset
   564
				}
4b8af0e57a79 (svn r1576) Clean TileLoopWaterHelper() a bit up
tron
parents: 1048
diff changeset
   565
				break;
4b8af0e57a79 (svn r1576) Clean TileLoopWaterHelper() a bit up
tron
parents: 1048
diff changeset
   566
4b8af0e57a79 (svn r1576) Clean TileLoopWaterHelper() a bit up
tron
parents: 1048
diff changeset
   567
			default:
4b8af0e57a79 (svn r1576) Clean TileLoopWaterHelper() a bit up
tron
parents: 1048
diff changeset
   568
				break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   569
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   570
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   571
		_current_player = OWNER_WATER;
5940
3bb99a7ad58f (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: 5905
diff changeset
   572
3bb99a7ad58f (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: 5905
diff changeset
   573
		Vehicle *v = FindFloodableVehicleOnTile(target);
3bb99a7ad58f (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: 5905
diff changeset
   574
		if (v != NULL) FloodVehicle(v);
1075
4b8af0e57a79 (svn r1576) Clean TileLoopWaterHelper() a bit up
tron
parents: 1048
diff changeset
   575
3491
35d747bb5e82 (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
   576
		if (!CmdFailed(DoCommand(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) {
3111
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents: 3017
diff changeset
   577
			MakeWater(target);
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents: 3017
diff changeset
   578
			MarkTileDirtyByTile(target);
1075
4b8af0e57a79 (svn r1576) Clean TileLoopWaterHelper() a bit up
tron
parents: 1048
diff changeset
   579
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   580
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   581
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   582
5940
3bb99a7ad58f (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: 5905
diff changeset
   583
/**
3bb99a7ad58f (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: 5905
diff changeset
   584
 * Finds a vehicle to flood.
3bb99a7ad58f (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: 5905
diff changeset
   585
 * It does not find vehicles that are already crashed on bridges, i.e. flooded.
3bb99a7ad58f (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: 5905
diff changeset
   586
 * @param tile the tile where to find a vehicle to flood
3bb99a7ad58f (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: 5905
diff changeset
   587
 * @return a vehicle too flood or NULL when there is no vehicle too flood.
3bb99a7ad58f (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: 5905
diff changeset
   588
 */
3bb99a7ad58f (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: 5905
diff changeset
   589
static Vehicle *FindFloodableVehicleOnTile(TileIndex tile)
3bb99a7ad58f (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: 5905
diff changeset
   590
{
3bb99a7ad58f (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: 5905
diff changeset
   591
	if (!IsBridgeTile(tile)) return FindVehicleOnTileZ(tile, 0);
3bb99a7ad58f (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: 5905
diff changeset
   592
3bb99a7ad58f (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: 5905
diff changeset
   593
	TileIndex end = GetOtherBridgeEnd(tile);
3bb99a7ad58f (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: 5905
diff changeset
   594
	byte z = GetBridgeHeight(tile);
3bb99a7ad58f (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: 5905
diff changeset
   595
	Vehicle *v;
3bb99a7ad58f (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: 5905
diff changeset
   596
3bb99a7ad58f (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: 5905
diff changeset
   597
	/* check the start tile first since as this is closest to the water */
3bb99a7ad58f (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: 5905
diff changeset
   598
	v = FindVehicleOnTileZ(tile, z);
3bb99a7ad58f (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: 5905
diff changeset
   599
	if (v != NULL && (v->vehstatus & VS_CRASHED) == 0) return v;
3bb99a7ad58f (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: 5905
diff changeset
   600
3bb99a7ad58f (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: 5905
diff changeset
   601
	/* check a vehicle in between both bridge heads */
3bb99a7ad58f (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: 5905
diff changeset
   602
	v = FindVehicleBetween(tile, end, z, true);
3bb99a7ad58f (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: 5905
diff changeset
   603
	if (v != NULL) return v;
3bb99a7ad58f (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: 5905
diff changeset
   604
3bb99a7ad58f (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: 5905
diff changeset
   605
	/* check the end tile last to give fleeing vehicles a chance to escape */
3bb99a7ad58f (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: 5905
diff changeset
   606
	v = FindVehicleOnTileZ(end, z);
3bb99a7ad58f (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: 5905
diff changeset
   607
	return (v != NULL && (v->vehstatus & VS_CRASHED) == 0) ? v : NULL;
3bb99a7ad58f (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: 5905
diff changeset
   608
}
3bb99a7ad58f (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: 5905
diff changeset
   609
149
5f7d4b21df01 (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents: 43
diff changeset
   610
static void FloodVehicle(Vehicle *v)
5f7d4b21df01 (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents: 43
diff changeset
   611
{
5f7d4b21df01 (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents: 43
diff changeset
   612
	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
   613
		uint16 pass = 0;
149
5f7d4b21df01 (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents: 43
diff changeset
   614
6259
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6248
diff changeset
   615
		if (v->type == VEH_ROAD) { // flood bus/truck
4434
a08cb4b5c179 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4388
diff changeset
   616
			pass = 1; // driver
6334
a8f01a805813 (svn r9322) -Codechange: Use cargo class to count crash/flood victims
peter1138
parents: 6286
diff changeset
   617
			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
   618
5f7d4b21df01 (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents: 43
diff changeset
   619
			v->vehstatus |= VS_CRASHED;
4434
a08cb4b5c179 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4388
diff changeset
   620
			v->u.road.crashed_ctr = 2000; // max 2220, disappear pretty fast
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 541
diff changeset
   621
			RebuildVehicleLists();
6259
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6248
diff changeset
   622
		} else if (v->type == VEH_TRAIN) {
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4169
diff changeset
   623
			Vehicle *u;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 168
diff changeset
   624
149
5f7d4b21df01 (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents: 43
diff changeset
   625
			v = GetFirstVehicleInChain(v);
5f7d4b21df01 (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents: 43
diff changeset
   626
			u = v;
2676
59b65b4fb480 (svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents: 2657
diff changeset
   627
			if (IsFrontEngine(v)) pass = 4; // driver
149
5f7d4b21df01 (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents: 43
diff changeset
   628
5f7d4b21df01 (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents: 43
diff changeset
   629
			// crash all wagons, and count passangers
5f7d4b21df01 (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents: 43
diff changeset
   630
			BEGIN_ENUM_WAGONS(v)
6334
a8f01a805813 (svn r9322) -Codechange: Use cargo class to count crash/flood victims
peter1138
parents: 6286
diff changeset
   631
				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
   632
				v->vehstatus |= VS_CRASHED;
5940
3bb99a7ad58f (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: 5905
diff changeset
   633
				MarkAllViewportsDirty(v->left_coord, v->top_coord, v->right_coord + 1, v->bottom_coord + 1);
149
5f7d4b21df01 (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents: 43
diff changeset
   634
			END_ENUM_WAGONS(v)
5f7d4b21df01 (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents: 43
diff changeset
   635
5f7d4b21df01 (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents: 43
diff changeset
   636
			v = u;
5f7d4b21df01 (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents: 43
diff changeset
   637
			v->u.rail.crash_anim_pos = 4000; // max 4440, disappear pretty fast
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 541
diff changeset
   638
			RebuildVehicleLists();
2549
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   639
		} else {
168
79f9ed5b23e6 (svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents: 164
diff changeset
   640
			return;
2549
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   641
		}
149
5f7d4b21df01 (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents: 43
diff changeset
   642
755
80091de50044 (svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents: 726
diff changeset
   643
		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
149
5f7d4b21df01 (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents: 43
diff changeset
   644
		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 168
diff changeset
   645
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 507
diff changeset
   646
		SetDParam(0, pass);
149
5f7d4b21df01 (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents: 43
diff changeset
   647
		AddNewsItem(STR_B006_FLOOD_VEHICLE_DESTROYED,
5f7d4b21df01 (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents: 43
diff changeset
   648
			NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ACCIDENT, 0),
5f7d4b21df01 (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents: 43
diff changeset
   649
			v->index,
5f7d4b21df01 (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents: 43
diff changeset
   650
			0);
2549
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   651
		CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE);
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   652
		SndPlayVehicleFx(SND_12_EXPLOSION, v);
714
503e96f37d46 (svn r1166) Fix: [ 1040119 ] Flooded wagons in depots don't keep constantly exploding any more
dominik
parents: 679
diff changeset
   653
	}
149
5f7d4b21df01 (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents: 43
diff changeset
   654
}
5f7d4b21df01 (svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents: 43
diff changeset
   655
4090
9d89793063fd (svn r5406) - Regression [r5403]: Fix assertion in TileLoop_Water() caused by oil rigs also using it...
peter1138
parents: 4087
diff changeset
   656
// called from tunnelbridge_cmd, and by TileLoop_Industry()
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1902
diff changeset
   657
void TileLoop_Water(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   658
{
909
65cdb609b7a6 (svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents: 900
diff changeset
   659
	static const TileIndexDiffC _tile_loop_offs_array[][5] = {
4344
7e123fec5b0b (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
   660
		// tile to mod              shore?    shore?
909
65cdb609b7a6 (svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents: 900
diff changeset
   661
		{{-1,  0}, {0, 0}, {0, 1}, {-1,  0}, {-1,  1}},
65cdb609b7a6 (svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents: 900
diff changeset
   662
		{{ 0,  1}, {0, 1}, {1, 1}, { 0,  2}, { 1,  2}},
65cdb609b7a6 (svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents: 900
diff changeset
   663
		{{ 1,  0}, {1, 0}, {1, 1}, { 2,  0}, { 2,  1}},
65cdb609b7a6 (svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents: 900
diff changeset
   664
		{{ 0, -1}, {0, 0}, {1, 0}, { 0, -1}, { 1, -1}}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   665
	};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   666
5954
7ca0068d5cdb (svn r8620) -Fix: buoys on canal tiles do not flood anymore (Maedhros).
rubidium
parents: 5940
diff changeset
   667
	/* Ensure sea-level canals and buoys on canal borders do not flood */
7ca0068d5cdb (svn r8620) -Fix: buoys on canal tiles do not flood anymore (Maedhros).
rubidium
parents: 5940
diff changeset
   668
	if ((IsTileType(tile, MP_WATER) || IsBuoyTile(tile)) && !IsTileOwner(tile, OWNER_WATER)) return;
4087
d6a79200cb20 (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
   669
926
a6d140a6a4de (svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents: 909
diff changeset
   670
	if (IS_INT_INSIDE(TileX(tile), 1, MapSizeX() - 3 + 1) &&
a6d140a6a4de (svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents: 909
diff changeset
   671
			IS_INT_INSIDE(TileY(tile), 1, MapSizeY() - 3 + 1)) {
2989
916f9443345f (svn r3564) Several smaller changes:
tron
parents: 2951
diff changeset
   672
		uint i;
916f9443345f (svn r3564) Several smaller changes:
tron
parents: 2951
diff changeset
   673
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2549
diff changeset
   674
		for (i = 0; i != lengthof(_tile_loop_offs_array); i++) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   675
			TileLoopWaterHelper(tile, _tile_loop_offs_array[i]);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2549
diff changeset
   676
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   677
	}
314
75fe42199623 (svn r320) -Fix: some last _current_player fixes
truelight
parents: 222
diff changeset
   678
	// _current_player can be changed by TileLoopWaterHelper.. reset it back
75fe42199623 (svn r320) -Fix: some last _current_player fixes
truelight
parents: 222
diff changeset
   679
	//   here
75fe42199623 (svn r320) -Fix: some last _current_player fixes
truelight
parents: 222
diff changeset
   680
	_current_player = OWNER_NONE;
43
3b93861c5478 (svn r44) Fix: Coast line near edge of map and near oilrigs (Dribbel)
dominik
parents: 39
diff changeset
   681
3b93861c5478 (svn r44) Fix: Coast line near edge of map and near oilrigs (Dribbel)
dominik
parents: 39
diff changeset
   682
	// edges
2951
2de6d3a59743 (svn r3510) Fiddle with whitespace and parentheses
tron
parents: 2934
diff changeset
   683
	if (TileX(tile) == 0 && IS_INT_INSIDE(TileY(tile), 1, MapSizeY() - 3 + 1)) { //NE
43
3b93861c5478 (svn r44) Fix: Coast line near edge of map and near oilrigs (Dribbel)
dominik
parents: 39
diff changeset
   684
		TileLoopWaterHelper(tile, _tile_loop_offs_array[2]);
2951
2de6d3a59743 (svn r3510) Fiddle with whitespace and parentheses
tron
parents: 2934
diff changeset
   685
	}
43
3b93861c5478 (svn r44) Fix: Coast line near edge of map and near oilrigs (Dribbel)
dominik
parents: 39
diff changeset
   686
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2549
diff changeset
   687
	if (TileX(tile) == MapSizeX() - 2 && IS_INT_INSIDE(TileY(tile), 1, MapSizeY() - 3 + 1)) { //SW
43
3b93861c5478 (svn r44) Fix: Coast line near edge of map and near oilrigs (Dribbel)
dominik
parents: 39
diff changeset
   688
		TileLoopWaterHelper(tile, _tile_loop_offs_array[0]);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2549
diff changeset
   689
	}
43
3b93861c5478 (svn r44) Fix: Coast line near edge of map and near oilrigs (Dribbel)
dominik
parents: 39
diff changeset
   690
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2549
diff changeset
   691
	if (TileY(tile) == 0 && IS_INT_INSIDE(TileX(tile), 1, MapSizeX() - 3 + 1)) { //NW
43
3b93861c5478 (svn r44) Fix: Coast line near edge of map and near oilrigs (Dribbel)
dominik
parents: 39
diff changeset
   692
		TileLoopWaterHelper(tile, _tile_loop_offs_array[1]);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2549
diff changeset
   693
	}
43
3b93861c5478 (svn r44) Fix: Coast line near edge of map and near oilrigs (Dribbel)
dominik
parents: 39
diff changeset
   694
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2549
diff changeset
   695
	if (TileY(tile) == MapSizeY() - 2 && IS_INT_INSIDE(TileX(tile), 1, MapSizeX() - 3 + 1)) { //SE
43
3b93861c5478 (svn r44) Fix: Coast line near edge of map and near oilrigs (Dribbel)
dominik
parents: 39
diff changeset
   696
		TileLoopWaterHelper(tile, _tile_loop_offs_array[3]);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2549
diff changeset
   697
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   698
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   699
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1902
diff changeset
   700
static uint32 GetTileTrackStatus_Water(TileIndex tile, TransportType mode)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   701
{
3423
dab85d82708b (svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents: 3422
diff changeset
   702
	static const byte coast_tracks[] = {0, 32, 4, 0, 16, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0};
4169
0d77cd42f6e6 (svn r5606) Replace some magic numbers by proper TrackBits enums and macros
tron
parents: 4101
diff changeset
   703
0d77cd42f6e6 (svn r5606) Replace some magic numbers by proper TrackBits enums and macros
tron
parents: 4101
diff changeset
   704
	TrackBits ts;
0d77cd42f6e6 (svn r5606) Replace some magic numbers by proper TrackBits enums and macros
tron
parents: 4101
diff changeset
   705
2951
2de6d3a59743 (svn r3510) Fiddle with whitespace and parentheses
tron
parents: 2934
diff changeset
   706
	if (mode != TRANSPORT_WATER) return 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   707
3423
dab85d82708b (svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents: 3422
diff changeset
   708
	switch (GetWaterTileType(tile)) {
6181
2d0ac0598453 (svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents: 6160
diff changeset
   709
		case WATER_TILE_CLEAR: ts = TRACK_BIT_ALL; break;
2d0ac0598453 (svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents: 6160
diff changeset
   710
		case WATER_TILE_COAST: ts = (TrackBits)coast_tracks[GetTileSlope(tile, NULL) & 0xF]; break;
2d0ac0598453 (svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents: 6160
diff changeset
   711
		case WATER_TILE_LOCK:  ts = AxisToTrackBits(DiagDirToAxis(GetLockDirection(tile))); break;
2d0ac0598453 (svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents: 6160
diff changeset
   712
		case WATER_TILE_DEPOT: ts = AxisToTrackBits(GetShipDepotAxis(tile)); break;
3423
dab85d82708b (svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents: 3422
diff changeset
   713
		default: return 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   714
	}
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3884
diff changeset
   715
	if (TileX(tile) == 0) {
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3884
diff changeset
   716
		// NE border: remove tracks that connects NE tile edge
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3884
diff changeset
   717
		ts &= ~(TRACK_BIT_X | TRACK_BIT_UPPER | TRACK_BIT_RIGHT);
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3884
diff changeset
   718
	}
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3884
diff changeset
   719
	if (TileY(tile) == 0) {
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3884
diff changeset
   720
		// NW border: remove tracks that connects NW tile edge
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3884
diff changeset
   721
		ts &= ~(TRACK_BIT_Y | TRACK_BIT_LEFT | TRACK_BIT_UPPER);
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3884
diff changeset
   722
	}
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3884
diff changeset
   723
	return ts * 0x101;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   724
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   725
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1902
diff changeset
   726
static void ClickTile_Water(TileIndex tile)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   727
{
6181
2d0ac0598453 (svn r8953) -Codechange: make the names of enums of WaterTileType consistent with respect to RailTileType and RoadTileType.
rubidium
parents: 6160
diff changeset
   728
	if (GetWaterTileType(tile) == WATER_TILE_DEPOT) {
3423
dab85d82708b (svn r4250) -Codechange: Further use of map accessors for water tiles
celestar
parents: 3422
diff changeset
   729
		TileIndex tile2 = GetOtherShipDepotTile(tile);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 168
diff changeset
   730
6259
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6248
diff changeset
   731
		ShowDepotWindow(tile < tile2 ? tile : tile2, VEH_SHIP);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   732
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   733
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   734
2436
7d5df545bd5d (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2261
diff changeset
   735
static void ChangeTileOwner_Water(TileIndex tile, PlayerID old_player, PlayerID new_player)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   736
{
1901
03bf9bf99319 (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
   737
	if (!IsTileOwner(tile, old_player)) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   738
4848
45f848b46222 (svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents: 4638
diff changeset
   739
	if (new_player != PLAYER_SPECTATOR) {
1902
86b7fb11f938 (svn r2408) Introduce SetTileOwner() and use it
tron
parents: 1901
diff changeset
   740
		SetTileOwner(tile, new_player);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   741
	} else {
3491
35d747bb5e82 (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
   742
		DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   743
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   744
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   745
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1902
diff changeset
   746
static uint32 VehicleEnter_Water(Vehicle *v, TileIndex tile, int x, int y)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   747
{
5991
ec2eebfe86de (svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents: 5954
diff changeset
   748
	return VETSB_CONTINUE;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   749
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   750
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   751
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   752
extern const TileTypeProcs _tile_type_water_procs = {
4344
7e123fec5b0b (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
   753
	DrawTile_Water,           /* draw_tile_proc */
7e123fec5b0b (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
   754
	GetSlopeZ_Water,          /* get_slope_z_proc */
7e123fec5b0b (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
   755
	ClearTile_Water,          /* clear_tile_proc */
7e123fec5b0b (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
   756
	GetAcceptedCargo_Water,   /* get_accepted_cargo_proc */
7e123fec5b0b (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
   757
	GetTileDesc_Water,        /* get_tile_desc_proc */
7e123fec5b0b (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
   758
	GetTileTrackStatus_Water, /* get_tile_track_status_proc */
7e123fec5b0b (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
   759
	ClickTile_Water,          /* click_tile_proc */
7e123fec5b0b (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
   760
	AnimateTile_Water,        /* animate_tile_proc */
7e123fec5b0b (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
   761
	TileLoop_Water,           /* tile_loop_clear */
7e123fec5b0b (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
   762
	ChangeTileOwner_Water,    /* change_tile_owner_clear */
7e123fec5b0b (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
   763
	NULL,                     /* get_produced_cargo_proc */
7e123fec5b0b (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
   764
	VehicleEnter_Water,       /* vehicle_enter_tile_proc */
7e123fec5b0b (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
   765
	GetSlopeTileh_Water,      /* get_slope_tileh_proc */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   766
};