author | Darkvater |
Mon, 03 Apr 2006 18:11:42 +0000 | |
changeset 3435 | f299c6f48763 |
parent 3434 | 21094a78dcdb |
child 3491 | 4c8427796c64 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1785
diff
changeset
|
4 |
#include "openttd.h" |
3189
1af302c5abd0
(svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
3176
diff
changeset
|
5 |
#include "bridge_map.h" |
3101
e2fdb8802c2f
(svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
3100
diff
changeset
|
6 |
#include "rail_map.h" |
3144
426b825578f9
(svn r3763) Adapt to the new 'map accessors go in foo_map.h'-scheme
tron
parents:
3104
diff
changeset
|
7 |
#include "road_map.h" |
2008
c9d6585c96c8
(svn r2516) - Feature: [pbs] Implement path-based-signalling. This allows multiple trains within the same signal block, provided their paths dont intersect. For this the block must have all exit and entry signals be pbs signals. Place these by ctrl-clicking 4 times on a normal signal.
hackykid
parents:
1986
diff
changeset
|
8 |
#include "table/sprites.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
497
diff
changeset
|
9 |
#include "table/strings.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2148
diff
changeset
|
10 |
#include "functions.h" |
679
e959706a3e4d
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
541
diff
changeset
|
11 |
#include "map.h" |
1209
a1ac96655b79
(svn r1713) Split off several functions which query/set information about a single tile from map.h and put them into a seperate file tile.h
tron
parents:
1095
diff
changeset
|
12 |
#include "tile.h" |
3319
7d04847e4689
(svn r4085) Add GetTown{Index,ByTile}() to get the town index resp. the town from a tile
tron
parents:
3286
diff
changeset
|
13 |
#include "town_map.h" |
0 | 14 |
#include "vehicle.h" |
15 |
#include "viewport.h" |
|
16 |
#include "command.h" |
|
17 |
#include "player.h" |
|
18 |
#include "town.h" |
|
19 |
#include "gfx.h" |
|
337
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
241
diff
changeset
|
20 |
#include "sound.h" |
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1281
diff
changeset
|
21 |
#include "depot.h" |
0 | 22 |
|
23 |
void RoadVehEnterDepot(Vehicle *v); |
|
24 |
||
25 |
||
3381
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
26 |
static uint CountRoadBits(RoadBits r) |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
27 |
{ |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
28 |
uint count = 0; |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
29 |
|
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
30 |
if (r & ROAD_NW) ++count; |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
31 |
if (r & ROAD_SW) ++count; |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
32 |
if (r & ROAD_SE) ++count; |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
33 |
if (r & ROAD_NE) ++count; |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
34 |
return count; |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
35 |
} |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
36 |
|
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
37 |
|
3149
2b54fc654019
(svn r3770) Remove the _road_special_gettrackstatus hack. Egladil and me deem it unnecessary
tron
parents:
3146
diff
changeset
|
38 |
static bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, bool* edge_road) |
0 | 39 |
{ |
3149
2b54fc654019
(svn r3770) Remove the _road_special_gettrackstatus hack. Egladil and me deem it unnecessary
tron
parents:
3146
diff
changeset
|
40 |
RoadBits present; |
2b54fc654019
(svn r3770) Remove the _road_special_gettrackstatus hack. Egladil and me deem it unnecessary
tron
parents:
3146
diff
changeset
|
41 |
RoadBits n; |
0 | 42 |
byte owner; |
43 |
*edge_road = true; |
|
44 |
||
3017
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
45 |
if (_game_mode == GM_EDITOR) return true; |
0 | 46 |
|
47 |
// Only do the special processing for actual players. |
|
3017
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
48 |
if (_current_player >= MAX_PLAYERS) return true; |
0 | 49 |
|
1927
4126e0e3e884
(svn r2433) - CodeChange: unmagicify all road/train crossings with IsLevelCrossing() function (peter1138)
Darkvater
parents:
1902
diff
changeset
|
50 |
if (IsTileType(tile, MP_STREET) && IsLevelCrossing(tile)) { |
3274 | 51 |
owner = GetCrossingRoadOwner(tile); |
0 | 52 |
} else { |
1901
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
53 |
owner = GetTileOwner(tile); |
0 | 54 |
} |
55 |
// Only do the special processing if the road is owned |
|
56 |
// by a town |
|
57 |
if (owner != OWNER_TOWN) { |
|
58 |
return owner == OWNER_NONE || CheckOwnership(owner); |
|
59 |
} |
|
60 |
||
3017
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
61 |
if (_cheats.magic_bulldozer.value) return true; |
0 | 62 |
|
63 |
// Get a bitmask of which neighbouring roads has a tile |
|
64 |
n = 0; |
|
3149
2b54fc654019
(svn r3770) Remove the _road_special_gettrackstatus hack. Egladil and me deem it unnecessary
tron
parents:
3146
diff
changeset
|
65 |
present = GetAnyRoadBits(tile); |
2b54fc654019
(svn r3770) Remove the _road_special_gettrackstatus hack. Egladil and me deem it unnecessary
tron
parents:
3146
diff
changeset
|
66 |
if (present & ROAD_NE && GetAnyRoadBits(TILE_ADDXY(tile,-1, 0)) & ROAD_SW) n |= ROAD_NE; |
2b54fc654019
(svn r3770) Remove the _road_special_gettrackstatus hack. Egladil and me deem it unnecessary
tron
parents:
3146
diff
changeset
|
67 |
if (present & ROAD_SE && GetAnyRoadBits(TILE_ADDXY(tile, 0, 1)) & ROAD_NW) n |= ROAD_SE; |
2b54fc654019
(svn r3770) Remove the _road_special_gettrackstatus hack. Egladil and me deem it unnecessary
tron
parents:
3146
diff
changeset
|
68 |
if (present & ROAD_SW && GetAnyRoadBits(TILE_ADDXY(tile, 1, 0)) & ROAD_NE) n |= ROAD_SW; |
2b54fc654019
(svn r3770) Remove the _road_special_gettrackstatus hack. Egladil and me deem it unnecessary
tron
parents:
3146
diff
changeset
|
69 |
if (present & ROAD_NW && GetAnyRoadBits(TILE_ADDXY(tile, 0,-1)) & ROAD_SE) n |= ROAD_NW; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
70 |
|
0 | 71 |
// If 0 or 1 bits are set in n, or if no bits that match the bits to remove, |
72 |
// then allow it |
|
3149
2b54fc654019
(svn r3770) Remove the _road_special_gettrackstatus hack. Egladil and me deem it unnecessary
tron
parents:
3146
diff
changeset
|
73 |
if ((n & (n - 1)) != 0 && (n & remove) != 0) { |
0 | 74 |
Town *t; |
75 |
*edge_road = false; |
|
76 |
// you can remove all kind of roads with extra dynamite |
|
3017
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
77 |
if (_patches.extra_dynamite) return true; |
0 | 78 |
|
1638
aae181b00846
(svn r2142) - Fix: Game no longer crashes when you want to remove a piece of road under a bridge that belongs to the town. TODO: railcrossings store owner somewhere else, put it into _map_owner[]!
Darkvater
parents:
1398
diff
changeset
|
79 |
t = ClosestTownFromTile(tile, _patches.dist_local_authority); |
aae181b00846
(svn r2142) - Fix: Game no longer crashes when you want to remove a piece of road under a bridge that belongs to the town. TODO: railcrossings store owner somewhere else, put it into _map_owner[]!
Darkvater
parents:
1398
diff
changeset
|
80 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
81 |
SetDParam(0, t->index); |
0 | 82 |
_error_message = STR_2009_LOCAL_AUTHORITY_REFUSES; |
83 |
return false; |
|
84 |
} |
|
85 |
||
86 |
return true; |
|
87 |
} |
|
88 |
||
89 |
||
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
90 |
/** Delete a piece of road. |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
91 |
* @param x,y tile coordinates for road construction |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
92 |
* @param p1 road piece flags |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
93 |
* @param p2 unused |
0 | 94 |
*/ |
95 |
int32 CmdRemoveRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
96 |
{ |
|
1638
aae181b00846
(svn r2142) - Fix: Game no longer crashes when you want to remove a piece of road under a bridge that belongs to the town. TODO: railcrossings store owner somewhere else, put it into _map_owner[]!
Darkvater
parents:
1398
diff
changeset
|
97 |
// cost for removing inner/edge -roads |
aae181b00846
(svn r2142) - Fix: Game no longer crashes when you want to remove a piece of road under a bridge that belongs to the town. TODO: railcrossings store owner somewhere else, put it into _map_owner[]!
Darkvater
parents:
1398
diff
changeset
|
98 |
static const uint16 road_remove_cost[2] = {50, 18}; |
aae181b00846
(svn r2142) - Fix: Game no longer crashes when you want to remove a piece of road under a bridge that belongs to the town. TODO: railcrossings store owner somewhere else, put it into _map_owner[]!
Darkvater
parents:
1398
diff
changeset
|
99 |
|
aae181b00846
(svn r2142) - Fix: Game no longer crashes when you want to remove a piece of road under a bridge that belongs to the town. TODO: railcrossings store owner somewhere else, put it into _map_owner[]!
Darkvater
parents:
1398
diff
changeset
|
100 |
TileIndex tile; |
2074
f23dcde246da
(svn r2584) - Fix: Game no longer asserts when you use the remove-road tool on a town building or industry.
Darkvater
parents:
2049
diff
changeset
|
101 |
PlayerID owner; |
0 | 102 |
Town *t; |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
103 |
/* true if the roadpiece was always removeable, |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
104 |
* false if it was a center piece. Affects town ratings drop */ |
0 | 105 |
bool edge_road; |
3069
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
106 |
RoadBits pieces; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
107 |
|
0 | 108 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
109 |
||
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
110 |
/* Road pieces are max 4 bitset values (NE, NW, SE, SW) */ |
3069
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
111 |
if (p1 >> 4) return CMD_ERROR; |
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
112 |
pieces = p1; |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
113 |
|
3277
f48206e08ff0
(svn r3990) Remove another call to FindLandscapeHeight()
tron
parents:
3274
diff
changeset
|
114 |
tile = TileVirtXY(x, y); |
1638
aae181b00846
(svn r2142) - Fix: Game no longer crashes when you want to remove a piece of road under a bridge that belongs to the town. TODO: railcrossings store owner somewhere else, put it into _map_owner[]!
Darkvater
parents:
1398
diff
changeset
|
115 |
|
2074
f23dcde246da
(svn r2584) - Fix: Game no longer asserts when you use the remove-road tool on a town building or industry.
Darkvater
parents:
2049
diff
changeset
|
116 |
if (!IsTileType(tile, MP_STREET) && !IsTileType(tile, MP_TUNNELBRIDGE)) return CMD_ERROR; |
f23dcde246da
(svn r2584) - Fix: Game no longer asserts when you use the remove-road tool on a town building or industry.
Darkvater
parents:
2049
diff
changeset
|
117 |
|
3274 | 118 |
owner = IsLevelCrossing(tile) ? GetCrossingRoadOwner(tile) : GetTileOwner(tile); |
1638
aae181b00846
(svn r2142) - Fix: Game no longer crashes when you want to remove a piece of road under a bridge that belongs to the town. TODO: railcrossings store owner somewhere else, put it into _map_owner[]!
Darkvater
parents:
1398
diff
changeset
|
119 |
|
aae181b00846
(svn r2142) - Fix: Game no longer crashes when you want to remove a piece of road under a bridge that belongs to the town. TODO: railcrossings store owner somewhere else, put it into _map_owner[]!
Darkvater
parents:
1398
diff
changeset
|
120 |
if (owner == OWNER_TOWN && _game_mode != GM_EDITOR) { |
aae181b00846
(svn r2142) - Fix: Game no longer crashes when you want to remove a piece of road under a bridge that belongs to the town. TODO: railcrossings store owner somewhere else, put it into _map_owner[]!
Darkvater
parents:
1398
diff
changeset
|
121 |
if (IsTileType(tile, MP_TUNNELBRIDGE)) { // index of town is not saved for bridge (no space) |
aae181b00846
(svn r2142) - Fix: Game no longer crashes when you want to remove a piece of road under a bridge that belongs to the town. TODO: railcrossings store owner somewhere else, put it into _map_owner[]!
Darkvater
parents:
1398
diff
changeset
|
122 |
t = ClosestTownFromTile(tile, _patches.dist_local_authority); |
3017
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
123 |
} else { |
3319
7d04847e4689
(svn r4085) Add GetTown{Index,ByTile}() to get the town index resp. the town from a tile
tron
parents:
3286
diff
changeset
|
124 |
t = GetTownByTile(tile); |
3017
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
125 |
} |
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
126 |
} else { |
1280
b6925875de49
(svn r1784) -Fix: removed ClosestTownFromTile where possible, or replaced it
truelight
parents:
1264
diff
changeset
|
127 |
t = NULL; |
3017
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
128 |
} |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
129 |
|
3149
2b54fc654019
(svn r3770) Remove the _road_special_gettrackstatus hack. Egladil and me deem it unnecessary
tron
parents:
3146
diff
changeset
|
130 |
if (!CheckAllowRemoveRoad(tile, pieces, &edge_road)) return CMD_ERROR; |
0 | 131 |
|
3277
f48206e08ff0
(svn r3990) Remove another call to FindLandscapeHeight()
tron
parents:
3274
diff
changeset
|
132 |
switch (GetTileType(tile)) { |
3060 | 133 |
case MP_TUNNELBRIDGE: |
134 |
if (!EnsureNoVehicleZ(tile, TilePixelHeight(tile))) return CMD_ERROR; |
|
0 | 135 |
|
3234
986c30171e92
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3189
diff
changeset
|
136 |
if (!IsBridge(tile) || |
986c30171e92
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3189
diff
changeset
|
137 |
!IsBridgeMiddle(tile) || |
986c30171e92
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3189
diff
changeset
|
138 |
!IsTransportUnderBridge(tile) || |
986c30171e92
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3189
diff
changeset
|
139 |
GetTransportTypeUnderBridge(tile) != TRANSPORT_ROAD || |
986c30171e92
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3189
diff
changeset
|
140 |
(pieces & ComplementRoadBits(GetRoadBitsUnderBridge(tile))) != 0) { |
3176 | 141 |
return CMD_ERROR; |
0 | 142 |
} |
143 |
||
144 |
if (flags & DC_EXEC) { |
|
1638
aae181b00846
(svn r2142) - Fix: Game no longer crashes when you want to remove a piece of road under a bridge that belongs to the town. TODO: railcrossings store owner somewhere else, put it into _map_owner[]!
Darkvater
parents:
1398
diff
changeset
|
145 |
ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM); |
3189
1af302c5abd0
(svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
3176
diff
changeset
|
146 |
SetClearUnderBridge(tile); |
3060 | 147 |
MarkTileDirtyByTile(tile); |
0 | 148 |
} |
3381
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
149 |
return _price.remove_road * 2; |
0 | 150 |
|
3060 | 151 |
case MP_STREET: |
3277
f48206e08ff0
(svn r3990) Remove another call to FindLandscapeHeight()
tron
parents:
3274
diff
changeset
|
152 |
if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
f48206e08ff0
(svn r3990) Remove another call to FindLandscapeHeight()
tron
parents:
3274
diff
changeset
|
153 |
|
3060 | 154 |
// check if you're allowed to remove the street owned by a town |
155 |
// removal allowance depends on difficulty setting |
|
156 |
if (!CheckforTownRating(flags, t, ROAD_REMOVE)) return CMD_ERROR; |
|
157 |
||
3277
f48206e08ff0
(svn r3990) Remove another call to FindLandscapeHeight()
tron
parents:
3274
diff
changeset
|
158 |
switch (GetRoadType(tile)) { |
3069
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
159 |
case ROAD_NORMAL: { |
3277
f48206e08ff0
(svn r3990) Remove another call to FindLandscapeHeight()
tron
parents:
3274
diff
changeset
|
160 |
RoadBits present = GetRoadBits(tile); |
3150
025fe8cd7104
(svn r3773) Shove some semantics down ottd's throat by replacing ints and magic numbers by enums and some related changes
tron
parents:
3149
diff
changeset
|
161 |
RoadBits c = pieces; |
3060 | 162 |
|
3277
f48206e08ff0
(svn r3990) Remove another call to FindLandscapeHeight()
tron
parents:
3274
diff
changeset
|
163 |
if (GetTileSlope(tile, NULL) != 0 && |
f48206e08ff0
(svn r3990) Remove another call to FindLandscapeHeight()
tron
parents:
3274
diff
changeset
|
164 |
(present == ROAD_Y || present == ROAD_X)) { |
3060 | 165 |
c |= (c & 0xC) >> 2; |
166 |
c |= (c & 0x3) << 2; |
|
167 |
} |
|
168 |
||
169 |
// limit the bits to delete to the existing bits. |
|
3150
025fe8cd7104
(svn r3773) Shove some semantics down ottd's throat by replacing ints and magic numbers by enums and some related changes
tron
parents:
3149
diff
changeset
|
170 |
c &= present; |
3176 | 171 |
if (c == 0) return CMD_ERROR; |
3060 | 172 |
|
173 |
if (flags & DC_EXEC) { |
|
174 |
ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM); |
|
175 |
||
3150
025fe8cd7104
(svn r3773) Shove some semantics down ottd's throat by replacing ints and magic numbers by enums and some related changes
tron
parents:
3149
diff
changeset
|
176 |
present ^= c; |
025fe8cd7104
(svn r3773) Shove some semantics down ottd's throat by replacing ints and magic numbers by enums and some related changes
tron
parents:
3149
diff
changeset
|
177 |
if (present == 0) { |
3060 | 178 |
DoClearSquare(tile); |
179 |
} else { |
|
3150
025fe8cd7104
(svn r3773) Shove some semantics down ottd's throat by replacing ints and magic numbers by enums and some related changes
tron
parents:
3149
diff
changeset
|
180 |
SetRoadBits(tile, present); |
3060 | 181 |
MarkTileDirtyByTile(tile); |
182 |
} |
|
183 |
} |
|
3381
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
184 |
return CountRoadBits(c) * _price.remove_road; |
3060 | 185 |
} |
186 |
||
3069
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
187 |
case ROAD_CROSSING: { |
3103
fb7f22d3bc9b
(svn r3698) Add GetCrossingRailBits() and ComplementRoadBits(). Simplify the code by using them
tron
parents:
3102
diff
changeset
|
188 |
if (pieces & ComplementRoadBits(GetCrossingRoadBits(tile))) { |
3176 | 189 |
return CMD_ERROR; |
3060 | 190 |
} |
191 |
||
192 |
if (flags & DC_EXEC) { |
|
193 |
ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM); |
|
194 |
||
3242
1cefa03f0d5e
(svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents:
3234
diff
changeset
|
195 |
MakeRailNormal(tile, GetTileOwner(tile), GetCrossingRailBits(tile), GetRailTypeCrossing(tile)); |
3101
e2fdb8802c2f
(svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
3100
diff
changeset
|
196 |
MarkTileDirtyByTile(tile); |
3060 | 197 |
} |
3381
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
198 |
return _price.remove_road * 2; |
3060 | 199 |
} |
200 |
||
3069
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
201 |
default: |
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
202 |
case ROAD_DEPOT: |
3176 | 203 |
return CMD_ERROR; |
0 | 204 |
} |
205 |
||
3176 | 206 |
default: return CMD_ERROR; |
0 | 207 |
} |
208 |
} |
|
209 |
||
210 |
||
3104
106ca8c3d959
(svn r3699) Replace some magic numbers for checking for a suitable slope for a level crossing by some less magic numbers
tron
parents:
3103
diff
changeset
|
211 |
static const RoadBits _valid_tileh_slopes_road[][15] = { |
0 | 212 |
// set of normal ones |
213 |
{ |
|
214 |
ROAD_ALL, 0, 0, |
|
3098
4c1320da876d
(svn r3687) Complete some bits I missed whenn adding accessor functions for road types and pieces
tron
parents:
3097
diff
changeset
|
215 |
ROAD_X, 0, 0, // 3, 4, 5 |
4c1320da876d
(svn r3687) Complete some bits I missed whenn adding accessor functions for road types and pieces
tron
parents:
3097
diff
changeset
|
216 |
ROAD_Y, 0, 0, |
4c1320da876d
(svn r3687) Complete some bits I missed whenn adding accessor functions for road types and pieces
tron
parents:
3097
diff
changeset
|
217 |
ROAD_Y, 0, 0, // 9, 10, 11 |
4c1320da876d
(svn r3687) Complete some bits I missed whenn adding accessor functions for road types and pieces
tron
parents:
3097
diff
changeset
|
218 |
ROAD_X, 0, 0 |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
219 |
}, |
0 | 220 |
// allowed road for an evenly raised platform |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
221 |
{ |
0 | 222 |
0, |
223 |
ROAD_SW | ROAD_NW, |
|
224 |
ROAD_SW | ROAD_SE, |
|
3098
4c1320da876d
(svn r3687) Complete some bits I missed whenn adding accessor functions for road types and pieces
tron
parents:
3097
diff
changeset
|
225 |
ROAD_Y | ROAD_SW, |
0 | 226 |
|
227 |
ROAD_SE | ROAD_NE, // 4 |
|
228 |
ROAD_ALL, |
|
3098
4c1320da876d
(svn r3687) Complete some bits I missed whenn adding accessor functions for road types and pieces
tron
parents:
3097
diff
changeset
|
229 |
ROAD_X | ROAD_SE, |
0 | 230 |
ROAD_ALL, |
231 |
||
232 |
ROAD_NW | ROAD_NE, // 8 |
|
3098
4c1320da876d
(svn r3687) Complete some bits I missed whenn adding accessor functions for road types and pieces
tron
parents:
3097
diff
changeset
|
233 |
ROAD_X | ROAD_NW, |
0 | 234 |
ROAD_ALL, |
235 |
ROAD_ALL, |
|
236 |
||
3098
4c1320da876d
(svn r3687) Complete some bits I missed whenn adding accessor functions for road types and pieces
tron
parents:
3097
diff
changeset
|
237 |
ROAD_Y | ROAD_NE, // 12 |
0 | 238 |
ROAD_ALL, |
239 |
ROAD_ALL |
|
13
3e7c1f74a996
(svn r14) Fix: railroad crossings on slopes are now possible
dominik
parents:
0
diff
changeset
|
240 |
}, |
0 | 241 |
}; |
242 |
||
243 |
||
3150
025fe8cd7104
(svn r3773) Shove some semantics down ottd's throat by replacing ints and magic numbers by enums and some related changes
tron
parents:
3149
diff
changeset
|
244 |
static uint32 CheckRoadSlope(int tileh, RoadBits* pieces, RoadBits existing) |
0 | 245 |
{ |
3381
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
246 |
RoadBits road_bits; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
247 |
|
3381
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
248 |
if (IsSteepTileh(tileh)) return CMD_ERROR; |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
249 |
road_bits = *pieces | existing; |
0 | 250 |
|
3381
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
251 |
// no special foundation |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
252 |
if ((~_valid_tileh_slopes_road[0][tileh] & road_bits) == 0) { |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
253 |
// force that all bits are set when we have slopes |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
254 |
if (tileh != 0) *pieces |= _valid_tileh_slopes_road[0][tileh]; |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
255 |
return 0; // no extra cost |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
256 |
} |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
257 |
|
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
258 |
// foundation is used. Whole tile is leveled up |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
259 |
if ((~_valid_tileh_slopes_road[1][tileh] & road_bits) == 0) { |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
260 |
return existing ? 0 : _price.terraform; |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
261 |
} |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
262 |
|
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
263 |
// partly leveled up tile, only if there's no road on that tile |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
264 |
if (existing == 0 && (tileh == 1 || tileh == 2 || tileh == 4 || tileh == 8)) { |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
265 |
// force full pieces. |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
266 |
*pieces |= (*pieces & 0xC) >> 2; |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
267 |
*pieces |= (*pieces & 0x3) << 2; |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
268 |
if (*pieces == ROAD_X || *pieces == ROAD_Y) return _price.terraform; |
0 | 269 |
} |
270 |
return CMD_ERROR; |
|
271 |
} |
|
272 |
||
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
273 |
/** Build a piece of road. |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
274 |
* @param x,y tile coordinates for road construction |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
275 |
* @param p1 road piece flags |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
276 |
* @param p2 the town that is building the road (0 if not applicable) |
0 | 277 |
*/ |
278 |
int32 CmdBuildRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
279 |
{ |
|
3381
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
280 |
int32 cost = 0; |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
281 |
int32 ret; |
3150
025fe8cd7104
(svn r3773) Shove some semantics down ottd's throat by replacing ints and magic numbers by enums and some related changes
tron
parents:
3149
diff
changeset
|
282 |
RoadBits existing = 0; |
025fe8cd7104
(svn r3773) Shove some semantics down ottd's throat by replacing ints and magic numbers by enums and some related changes
tron
parents:
3149
diff
changeset
|
283 |
RoadBits pieces; |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
284 |
TileIndex tile; |
3434
21094a78dcdb
(svn r4263) -Codechange: Road building no longer uses FindLandscapeHeight. Last occurence of FindLandscapeTile in the tile-specific functions gone. Thanks to Tron for doing lots of work in this direction
celestar
parents:
3430
diff
changeset
|
285 |
byte tileh; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
286 |
|
0 | 287 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
288 |
||
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
289 |
/* Road pieces are max 4 bitset values (NE, NW, SE, SW) and town can only be non-zero |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
290 |
* if a non-player is building the road */ |
3150
025fe8cd7104
(svn r3773) Shove some semantics down ottd's throat by replacing ints and magic numbers by enums and some related changes
tron
parents:
3149
diff
changeset
|
291 |
if ((p1 >> 4) || (_current_player < MAX_PLAYERS && p2 != 0) || !IsTownIndex(p2)) return CMD_ERROR; |
025fe8cd7104
(svn r3773) Shove some semantics down ottd's throat by replacing ints and magic numbers by enums and some related changes
tron
parents:
3149
diff
changeset
|
292 |
pieces = p1; |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
293 |
|
3434
21094a78dcdb
(svn r4263) -Codechange: Road building no longer uses FindLandscapeHeight. Last occurence of FindLandscapeTile in the tile-specific functions gone. Thanks to Tron for doing lots of work in this direction
celestar
parents:
3430
diff
changeset
|
294 |
tile = TileVirtXY(x, y); |
21094a78dcdb
(svn r4263) -Codechange: Road building no longer uses FindLandscapeHeight. Last occurence of FindLandscapeTile in the tile-specific functions gone. Thanks to Tron for doing lots of work in this direction
celestar
parents:
3430
diff
changeset
|
295 |
tileh = GetTileSlope(tile, NULL); |
0 | 296 |
|
3434
21094a78dcdb
(svn r4263) -Codechange: Road building no longer uses FindLandscapeHeight. Last occurence of FindLandscapeTile in the tile-specific functions gone. Thanks to Tron for doing lots of work in this direction
celestar
parents:
3430
diff
changeset
|
297 |
switch (GetTileType(tile)) { |
3060 | 298 |
case MP_STREET: |
3150
025fe8cd7104
(svn r3773) Shove some semantics down ottd's throat by replacing ints and magic numbers by enums and some related changes
tron
parents:
3149
diff
changeset
|
299 |
switch (GetRoadType(tile)) { |
3069
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
300 |
case ROAD_NORMAL: |
3150
025fe8cd7104
(svn r3773) Shove some semantics down ottd's throat by replacing ints and magic numbers by enums and some related changes
tron
parents:
3149
diff
changeset
|
301 |
existing = GetRoadBits(tile); |
025fe8cd7104
(svn r3773) Shove some semantics down ottd's throat by replacing ints and magic numbers by enums and some related changes
tron
parents:
3149
diff
changeset
|
302 |
if ((existing & pieces) == pieces) { |
3066
0d34dff23d98
(svn r3655) Simplify a boolean expression and turn 3 if-cascades into switches
tron
parents:
3061
diff
changeset
|
303 |
return_cmd_error(STR_1007_ALREADY_BUILT); |
0d34dff23d98
(svn r3655) Simplify a boolean expression and turn 3 if-cascades into switches
tron
parents:
3061
diff
changeset
|
304 |
} |
3381
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
305 |
if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
3066
0d34dff23d98
(svn r3655) Simplify a boolean expression and turn 3 if-cascades into switches
tron
parents:
3061
diff
changeset
|
306 |
break; |
0d34dff23d98
(svn r3655) Simplify a boolean expression and turn 3 if-cascades into switches
tron
parents:
3061
diff
changeset
|
307 |
|
3069
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
308 |
case ROAD_CROSSING: |
3150
025fe8cd7104
(svn r3773) Shove some semantics down ottd's throat by replacing ints and magic numbers by enums and some related changes
tron
parents:
3149
diff
changeset
|
309 |
if (pieces != GetCrossingRoadBits(tile)) { // XXX is this correct? |
3066
0d34dff23d98
(svn r3655) Simplify a boolean expression and turn 3 if-cascades into switches
tron
parents:
3061
diff
changeset
|
310 |
return_cmd_error(STR_1007_ALREADY_BUILT); |
0d34dff23d98
(svn r3655) Simplify a boolean expression and turn 3 if-cascades into switches
tron
parents:
3061
diff
changeset
|
311 |
} |
0d34dff23d98
(svn r3655) Simplify a boolean expression and turn 3 if-cascades into switches
tron
parents:
3061
diff
changeset
|
312 |
goto do_clear; |
0d34dff23d98
(svn r3655) Simplify a boolean expression and turn 3 if-cascades into switches
tron
parents:
3061
diff
changeset
|
313 |
|
3069
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
314 |
default: |
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
315 |
case ROAD_DEPOT: |
3066
0d34dff23d98
(svn r3655) Simplify a boolean expression and turn 3 if-cascades into switches
tron
parents:
3061
diff
changeset
|
316 |
goto do_clear; |
3060 | 317 |
} |
318 |
break; |
|
0 | 319 |
|
3060 | 320 |
case MP_RAILWAY: { |
3099
374e275300e3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3098
diff
changeset
|
321 |
Axis roaddir; |
13
3e7c1f74a996
(svn r14) Fix: railroad crossings on slopes are now possible
dominik
parents:
0
diff
changeset
|
322 |
|
3434
21094a78dcdb
(svn r4263) -Codechange: Road building no longer uses FindLandscapeHeight. Last occurence of FindLandscapeTile in the tile-specific functions gone. Thanks to Tron for doing lots of work in this direction
celestar
parents:
3430
diff
changeset
|
323 |
if (IsSteepTileh(tileh)) { // very steep tile |
3060 | 324 |
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
325 |
} |
|
326 |
||
3104
106ca8c3d959
(svn r3699) Replace some magic numbers for checking for a suitable slope for a level crossing by some less magic numbers
tron
parents:
3103
diff
changeset
|
327 |
#define M(x) (1 << (x)) |
106ca8c3d959
(svn r3699) Replace some magic numbers for checking for a suitable slope for a level crossing by some less magic numbers
tron
parents:
3103
diff
changeset
|
328 |
/* Level crossings may only be built on these slopes */ |
3434
21094a78dcdb
(svn r4263) -Codechange: Road building no longer uses FindLandscapeHeight. Last occurence of FindLandscapeTile in the tile-specific functions gone. Thanks to Tron for doing lots of work in this direction
celestar
parents:
3430
diff
changeset
|
329 |
if (!HASBIT(M(14) | M(13) | M(11) | M(10) | M(7) | M(5) | M(0), tileh)) { |
3060 | 330 |
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
331 |
} |
|
3104
106ca8c3d959
(svn r3699) Replace some magic numbers for checking for a suitable slope for a level crossing by some less magic numbers
tron
parents:
3103
diff
changeset
|
332 |
#undef M |
3060 | 333 |
|
3269
95e7bffcb3c5
(svn r3981) More work for the rail accessing functions and enums
tron
parents:
3267
diff
changeset
|
334 |
if (GetRailTileType(tile) != RAIL_TYPE_NORMAL) goto do_clear; |
95e7bffcb3c5
(svn r3981) More work for the rail accessing functions and enums
tron
parents:
3267
diff
changeset
|
335 |
switch (GetTrackBits(tile)) { |
95e7bffcb3c5
(svn r3981) More work for the rail accessing functions and enums
tron
parents:
3267
diff
changeset
|
336 |
case TRACK_BIT_X: |
95e7bffcb3c5
(svn r3981) More work for the rail accessing functions and enums
tron
parents:
3267
diff
changeset
|
337 |
if (pieces & ROAD_X) goto do_clear; |
95e7bffcb3c5
(svn r3981) More work for the rail accessing functions and enums
tron
parents:
3267
diff
changeset
|
338 |
roaddir = AXIS_Y; |
95e7bffcb3c5
(svn r3981) More work for the rail accessing functions and enums
tron
parents:
3267
diff
changeset
|
339 |
break; |
95e7bffcb3c5
(svn r3981) More work for the rail accessing functions and enums
tron
parents:
3267
diff
changeset
|
340 |
|
95e7bffcb3c5
(svn r3981) More work for the rail accessing functions and enums
tron
parents:
3267
diff
changeset
|
341 |
case TRACK_BIT_Y: |
95e7bffcb3c5
(svn r3981) More work for the rail accessing functions and enums
tron
parents:
3267
diff
changeset
|
342 |
if (pieces & ROAD_Y) goto do_clear; |
95e7bffcb3c5
(svn r3981) More work for the rail accessing functions and enums
tron
parents:
3267
diff
changeset
|
343 |
roaddir = AXIS_X; |
95e7bffcb3c5
(svn r3981) More work for the rail accessing functions and enums
tron
parents:
3267
diff
changeset
|
344 |
break; |
95e7bffcb3c5
(svn r3981) More work for the rail accessing functions and enums
tron
parents:
3267
diff
changeset
|
345 |
|
95e7bffcb3c5
(svn r3981) More work for the rail accessing functions and enums
tron
parents:
3267
diff
changeset
|
346 |
default: goto do_clear; |
3060 | 347 |
} |
348 |
||
3381
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
349 |
if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
350 |
|
3060 | 351 |
if (flags & DC_EXEC) { |
3242
1cefa03f0d5e
(svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents:
3234
diff
changeset
|
352 |
MakeRoadCrossing(tile, _current_player, GetTileOwner(tile), roaddir, GetRailType(tile), p2); |
3100
552cf19c49cb
(svn r3695) Add 2 MarkTileByTile() which I forgot in r3689 (noticed by Belugas)
tron
parents:
3099
diff
changeset
|
353 |
MarkTileDirtyByTile(tile); |
3060 | 354 |
} |
355 |
return _price.build_road * 2; |
|
3017
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
356 |
} |
0 | 357 |
|
3060 | 358 |
case MP_TUNNELBRIDGE: |
359 |
/* check for flat land */ |
|
3434
21094a78dcdb
(svn r4263) -Codechange: Road building no longer uses FindLandscapeHeight. Last occurence of FindLandscapeTile in the tile-specific functions gone. Thanks to Tron for doing lots of work in this direction
celestar
parents:
3430
diff
changeset
|
360 |
if (IsSteepTileh(tileh)) { // very steep tile |
3060 | 361 |
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
362 |
} |
|
0 | 363 |
|
3234
986c30171e92
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3189
diff
changeset
|
364 |
if (!IsBridge(tile) || !IsBridgeMiddle(tile)) goto do_clear; |
0 | 365 |
|
3060 | 366 |
/* only allow roads pertendicular to bridge */ |
3234
986c30171e92
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3189
diff
changeset
|
367 |
if ((pieces & (GetBridgeAxis(tile) == AXIS_X ? ROAD_X : ROAD_Y)) != 0) { |
986c30171e92
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3189
diff
changeset
|
368 |
goto do_clear; |
986c30171e92
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3189
diff
changeset
|
369 |
} |
3060 | 370 |
|
371 |
/* check if clear land under bridge */ |
|
3234
986c30171e92
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3189
diff
changeset
|
372 |
if (IsTransportUnderBridge(tile)) { |
986c30171e92
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3189
diff
changeset
|
373 |
switch (GetTransportTypeUnderBridge(tile)) { |
986c30171e92
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3189
diff
changeset
|
374 |
case TRANSPORT_ROAD: return_cmd_error(STR_1007_ALREADY_BUILT); |
986c30171e92
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3189
diff
changeset
|
375 |
default: return_cmd_error(STR_1008_MUST_REMOVE_RAILROAD_TRACK); |
986c30171e92
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3189
diff
changeset
|
376 |
} |
986c30171e92
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3189
diff
changeset
|
377 |
} else { |
986c30171e92
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3189
diff
changeset
|
378 |
if (IsWaterUnderBridge(tile)) { |
986c30171e92
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3189
diff
changeset
|
379 |
return_cmd_error(STR_3807_CAN_T_BUILD_ON_WATER); |
986c30171e92
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3189
diff
changeset
|
380 |
} |
3060 | 381 |
} |
382 |
||
383 |
if (flags & DC_EXEC) { |
|
3189
1af302c5abd0
(svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
3176
diff
changeset
|
384 |
SetRoadUnderBridge(tile, _current_player); |
1af302c5abd0
(svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
3176
diff
changeset
|
385 |
MarkTileDirtyByTile(tile); |
3060 | 386 |
} |
3381
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
387 |
return _price.build_road * 2; |
3060 | 388 |
|
389 |
default: |
|
0 | 390 |
do_clear:; |
3381
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
391 |
ret = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
392 |
if (CmdFailed(ret)) return ret; |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
393 |
cost += ret; |
0 | 394 |
} |
395 |
||
3434
21094a78dcdb
(svn r4263) -Codechange: Road building no longer uses FindLandscapeHeight. Last occurence of FindLandscapeTile in the tile-specific functions gone. Thanks to Tron for doing lots of work in this direction
celestar
parents:
3430
diff
changeset
|
396 |
ret = CheckRoadSlope(tileh, &pieces, existing); |
3381
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
397 |
if (CmdFailed(ret)) return_cmd_error(STR_1800_LAND_SLOPED_IN_WRONG_DIRECTION); |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
398 |
if (ret != 0 && (!_patches.build_on_slopes || _is_old_ai_player)) { |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
399 |
return CMD_ERROR; |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
400 |
} |
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
401 |
cost += ret; |
0 | 402 |
|
3434
21094a78dcdb
(svn r4263) -Codechange: Road building no longer uses FindLandscapeHeight. Last occurence of FindLandscapeTile in the tile-specific functions gone. Thanks to Tron for doing lots of work in this direction
celestar
parents:
3430
diff
changeset
|
403 |
if (IsTileType(tile, MP_STREET)) { |
3150
025fe8cd7104
(svn r3773) Shove some semantics down ottd's throat by replacing ints and magic numbers by enums and some related changes
tron
parents:
3149
diff
changeset
|
404 |
// Don't put the pieces that already exist |
025fe8cd7104
(svn r3773) Shove some semantics down ottd's throat by replacing ints and magic numbers by enums and some related changes
tron
parents:
3149
diff
changeset
|
405 |
pieces &= ComplementRoadBits(existing); |
0 | 406 |
} |
407 |
||
3381
ebdcc12845c7
(svn r4187) Simplify the code for building/removing a piece of road a bit
tron
parents:
3379
diff
changeset
|
408 |
cost += CountRoadBits(pieces) * _price.build_road; |
0 | 409 |
|
410 |
if (flags & DC_EXEC) { |
|
3434
21094a78dcdb
(svn r4263) -Codechange: Road building no longer uses FindLandscapeHeight. Last occurence of FindLandscapeTile in the tile-specific functions gone. Thanks to Tron for doing lots of work in this direction
celestar
parents:
3430
diff
changeset
|
411 |
if (IsTileType(tile, MP_STREET)) { |
3150
025fe8cd7104
(svn r3773) Shove some semantics down ottd's throat by replacing ints and magic numbers by enums and some related changes
tron
parents:
3149
diff
changeset
|
412 |
SetRoadBits(tile, existing | pieces); |
025fe8cd7104
(svn r3773) Shove some semantics down ottd's throat by replacing ints and magic numbers by enums and some related changes
tron
parents:
3149
diff
changeset
|
413 |
} else { |
3099
374e275300e3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3098
diff
changeset
|
414 |
MakeRoadNormal(tile, _current_player, pieces, p2); |
0 | 415 |
} |
416 |
||
417 |
MarkTileDirtyByTile(tile); |
|
418 |
} |
|
419 |
return cost; |
|
420 |
} |
|
421 |
||
3435
f299c6f48763
(svn r4265) - Fix: compile warning on VS2005 (parameter 2 different from declaration)
Darkvater
parents:
3434
diff
changeset
|
422 |
int32 DoConvertStreetRail(TileIndex tile, RailType totype, bool exec) |
0 | 423 |
{ |
424 |
// not a railroad crossing? |
|
1927
4126e0e3e884
(svn r2433) - CodeChange: unmagicify all road/train crossings with IsLevelCrossing() function (peter1138)
Darkvater
parents:
1902
diff
changeset
|
425 |
if (!IsLevelCrossing(tile)) return CMD_ERROR; |
0 | 426 |
|
427 |
// not owned by me? |
|
428 |
if (!CheckTileOwnership(tile) || !EnsureNoVehicle(tile)) return CMD_ERROR; |
|
429 |
||
3242
1cefa03f0d5e
(svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents:
3234
diff
changeset
|
430 |
if (GetRailTypeCrossing(tile) == totype) return CMD_ERROR; |
0 | 431 |
|
432 |
if (exec) { |
|
3242
1cefa03f0d5e
(svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents:
3234
diff
changeset
|
433 |
SetRailTypeCrossing(tile, totype); |
0 | 434 |
MarkTileDirtyByTile(tile); |
435 |
} |
|
436 |
||
437 |
return _price.build_rail >> 1; |
|
438 |
} |
|
439 |
||
440 |
||
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
441 |
/** Build a long piece of road. |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
442 |
* @param x,y end tile of drag |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
443 |
* @param p1 start tile of drag |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
444 |
* @param p2 various bitstuffed elements |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
445 |
* - p2 = (bit 0) - start tile starts in the 2nd half of tile (p2 & 1) |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
446 |
* - p2 = (bit 1) - end tile starts in the 2nd half of tile (p2 & 2) |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
447 |
* - p2 = (bit 2) - direction: 0 = along x-axis, 1 = along y-axis (p2 & 4) |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
448 |
*/ |
0 | 449 |
int32 CmdBuildLongRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
450 |
{ |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
451 |
TileIndex start_tile, end_tile, tile; |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
452 |
int32 cost, ret; |
0 | 453 |
|
889
7f8630bfea41
(svn r1375) -Fix: [1050990] Buying trains sometimes accounted for incorrectly. Was the result of the cost getting reset in a recursive call of docommand. That is fixed. In addition all cost-commands are typed explicitely. Please do not forget to do so or your costs will be credited to construction if you are unlucky.
darkvater
parents:
817
diff
changeset
|
454 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
7f8630bfea41
(svn r1375) -Fix: [1050990] Buying trains sometimes accounted for incorrectly. Was the result of the cost getting reset in a recursive call of docommand. That is fixed. In addition all cost-commands are typed explicitely. Please do not forget to do so or your costs will be credited to construction if you are unlucky.
darkvater
parents:
817
diff
changeset
|
455 |
|
2934
3b7eef9871f8
(svn r3490) -Fix: A bunch (10) of off-by-one errors when checking if a TileIndex points to a tile on the map
tron
parents:
2916
diff
changeset
|
456 |
if (p1 >= MapSize()) return CMD_ERROR; |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
457 |
|
0 | 458 |
start_tile = p1; |
1980
9ea0c89fbb58
(svn r2486) Turn TILE_FROM_XY into an inline function and rename it to TileVirtXY
tron
parents:
1979
diff
changeset
|
459 |
end_tile = TileVirtXY(x, y); |
0 | 460 |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
461 |
/* Only drag in X or Y direction dictated by the direction variable */ |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
462 |
if (!HASBIT(p2, 2) && TileY(start_tile) != TileY(end_tile)) return CMD_ERROR; // x-axis |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
463 |
if (HASBIT(p2, 2) && TileX(start_tile) != TileX(end_tile)) return CMD_ERROR; // y-axis |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
464 |
|
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
465 |
/* Swap start and ending tile, also the half-tile drag var (bit 0 and 1) */ |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
466 |
if (start_tile > end_tile || (start_tile == end_tile && HASBIT(p2, 0))) { |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
467 |
TileIndex t = start_tile; |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
468 |
start_tile = end_tile; |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
469 |
end_tile = t; |
0 | 470 |
p2 ^= IS_INT_INSIDE(p2&3, 1, 3) ? 3 : 0; |
471 |
} |
|
472 |
||
473 |
cost = 0; |
|
474 |
tile = start_tile; |
|
475 |
// Start tile is the small number. |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
476 |
for (;;) { |
3098
4c1320da876d
(svn r3687) Complete some bits I missed whenn adding accessor functions for road types and pieces
tron
parents:
3097
diff
changeset
|
477 |
RoadBits bits = HASBIT(p2, 2) ? ROAD_Y : ROAD_X; |
4c1320da876d
(svn r3687) Complete some bits I missed whenn adding accessor functions for road types and pieces
tron
parents:
3097
diff
changeset
|
478 |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
479 |
if (tile == end_tile && !HASBIT(p2, 1)) bits &= ROAD_NW | ROAD_NE; |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
480 |
if (tile == start_tile && HASBIT(p2, 0)) bits &= ROAD_SE | ROAD_SW; |
0 | 481 |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
482 |
ret = DoCommandByTile(tile, bits, 0, flags, CMD_BUILD_ROAD); |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
483 |
if (CmdFailed(ret)) { |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
484 |
if (_error_message != STR_1007_ALREADY_BUILT) return CMD_ERROR; |
2549 | 485 |
} else { |
0 | 486 |
cost += ret; |
2549 | 487 |
} |
0 | 488 |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
489 |
if (tile == end_tile) break; |
0 | 490 |
|
1981 | 491 |
tile += HASBIT(p2, 2) ? TileDiffXY(0, 1) : TileDiffXY(1, 0); |
0 | 492 |
} |
493 |
||
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
494 |
return (cost == 0) ? CMD_ERROR : cost; |
0 | 495 |
} |
496 |
||
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
497 |
/** Remove a long piece of road. |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
498 |
* @param x,y end tile of drag |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
499 |
* @param p1 start tile of drag |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
500 |
* @param p2 various bitstuffed elements |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
501 |
* - p2 = (bit 0) - start tile starts in the 2nd half of tile (p2 & 1) |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
502 |
* - p2 = (bit 1) - end tile starts in the 2nd half of tile (p2 & 2) |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
503 |
* - p2 = (bit 2) - direction: 0 = along x-axis, 1 = along y-axis (p2 & 4) |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
504 |
*/ |
0 | 505 |
int32 CmdRemoveLongRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
506 |
{ |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
507 |
TileIndex start_tile, end_tile, tile; |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
508 |
int32 cost, ret; |
0 | 509 |
|
889
7f8630bfea41
(svn r1375) -Fix: [1050990] Buying trains sometimes accounted for incorrectly. Was the result of the cost getting reset in a recursive call of docommand. That is fixed. In addition all cost-commands are typed explicitely. Please do not forget to do so or your costs will be credited to construction if you are unlucky.
darkvater
parents:
817
diff
changeset
|
510 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
7f8630bfea41
(svn r1375) -Fix: [1050990] Buying trains sometimes accounted for incorrectly. Was the result of the cost getting reset in a recursive call of docommand. That is fixed. In addition all cost-commands are typed explicitely. Please do not forget to do so or your costs will be credited to construction if you are unlucky.
darkvater
parents:
817
diff
changeset
|
511 |
|
2934
3b7eef9871f8
(svn r3490) -Fix: A bunch (10) of off-by-one errors when checking if a TileIndex points to a tile on the map
tron
parents:
2916
diff
changeset
|
512 |
if (p1 >= MapSize()) return CMD_ERROR; |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
513 |
|
0 | 514 |
start_tile = p1; |
1980
9ea0c89fbb58
(svn r2486) Turn TILE_FROM_XY into an inline function and rename it to TileVirtXY
tron
parents:
1979
diff
changeset
|
515 |
end_tile = TileVirtXY(x, y); |
0 | 516 |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
517 |
/* Only drag in X or Y direction dictated by the direction variable */ |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
518 |
if (!HASBIT(p2, 2) && TileY(start_tile) != TileY(end_tile)) return CMD_ERROR; // x-axis |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
519 |
if (HASBIT(p2, 2) && TileX(start_tile) != TileX(end_tile)) return CMD_ERROR; // y-axis |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
520 |
|
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
521 |
/* Swap start and ending tile, also the half-tile drag var (bit 0 and 1) */ |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
522 |
if (start_tile > end_tile || (start_tile == end_tile && HASBIT(p2, 0))) { |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
523 |
TileIndex t = start_tile; |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
524 |
start_tile = end_tile; |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
525 |
end_tile = t; |
3017
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
526 |
p2 ^= IS_INT_INSIDE(p2 & 3, 1, 3) ? 3 : 0; |
0 | 527 |
} |
528 |
||
529 |
cost = 0; |
|
530 |
tile = start_tile; |
|
531 |
// Start tile is the small number. |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
532 |
for (;;) { |
3098
4c1320da876d
(svn r3687) Complete some bits I missed whenn adding accessor functions for road types and pieces
tron
parents:
3097
diff
changeset
|
533 |
RoadBits bits = HASBIT(p2, 2) ? ROAD_Y : ROAD_X; |
4c1320da876d
(svn r3687) Complete some bits I missed whenn adding accessor functions for road types and pieces
tron
parents:
3097
diff
changeset
|
534 |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
535 |
if (tile == end_tile && !HASBIT(p2, 1)) bits &= ROAD_NW | ROAD_NE; |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
536 |
if (tile == start_tile && HASBIT(p2, 0)) bits &= ROAD_SE | ROAD_SW; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
537 |
|
0 | 538 |
// try to remove the halves. |
3098
4c1320da876d
(svn r3687) Complete some bits I missed whenn adding accessor functions for road types and pieces
tron
parents:
3097
diff
changeset
|
539 |
if (bits != 0) { |
0 | 540 |
ret = DoCommandByTile(tile, bits, 0, flags, CMD_REMOVE_ROAD); |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
541 |
if (!CmdFailed(ret)) cost += ret; |
0 | 542 |
} |
543 |
||
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
544 |
if (tile == end_tile) break; |
0 | 545 |
|
1981 | 546 |
tile += HASBIT(p2, 2) ? TileDiffXY(0, 1) : TileDiffXY(1, 0); |
0 | 547 |
} |
548 |
||
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
549 |
return (cost == 0) ? CMD_ERROR : cost; |
0 | 550 |
} |
551 |
||
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
552 |
/** Build a road depot. |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
553 |
* @param x,y tile coordinates where the depot will be built |
3333 | 554 |
* @param p1 entrance direction (DiagDirection) |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
555 |
* @param p2 unused |
2085
ae9e92ffe168
(svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents:
2074
diff
changeset
|
556 |
* |
ae9e92ffe168
(svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents:
2074
diff
changeset
|
557 |
* @todo When checking for the tile slope, |
ae9e92ffe168
(svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents:
2074
diff
changeset
|
558 |
* distingush between "Flat land required" and "land sloped in wrong direction" |
0 | 559 |
*/ |
560 |
int32 CmdBuildRoadDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
561 |
{ |
|
562 |
int32 cost; |
|
563 |
Depot *dep; |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
564 |
TileIndex tile; |
3055
25fd76668365
(svn r3644) Don't use FindLandscapeHeightByTile() when it's overkill - often it was just a complicated way of writing GetTileSlope(tile, NULL)
tron
parents:
3017
diff
changeset
|
565 |
uint tileh; |
0 | 566 |
|
567 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
|
568 |
||
1785
998f4b5eec29
(svn r2289) - Fix (regression): check p1 param of road-depot building instead of unused p2 (typo). Thanks peter1138.
Darkvater
parents:
1784
diff
changeset
|
569 |
if (p1 > 3) return CMD_ERROR; // check direction |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
570 |
|
3055
25fd76668365
(svn r3644) Don't use FindLandscapeHeightByTile() when it's overkill - often it was just a complicated way of writing GetTileSlope(tile, NULL)
tron
parents:
3017
diff
changeset
|
571 |
tile = TileVirtXY(x, y); |
0 | 572 |
|
2549 | 573 |
if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
0 | 574 |
|
3055
25fd76668365
(svn r3644) Don't use FindLandscapeHeightByTile() when it's overkill - often it was just a complicated way of writing GetTileSlope(tile, NULL)
tron
parents:
3017
diff
changeset
|
575 |
tileh = GetTileSlope(tile, NULL); |
25fd76668365
(svn r3644) Don't use FindLandscapeHeightByTile() when it's overkill - often it was just a complicated way of writing GetTileSlope(tile, NULL)
tron
parents:
3017
diff
changeset
|
576 |
if (tileh != 0 && ( |
2549 | 577 |
!_patches.build_on_slopes || |
3055
25fd76668365
(svn r3644) Don't use FindLandscapeHeightByTile() when it's overkill - often it was just a complicated way of writing GetTileSlope(tile, NULL)
tron
parents:
3017
diff
changeset
|
578 |
IsSteepTileh(tileh) || |
25fd76668365
(svn r3644) Don't use FindLandscapeHeightByTile() when it's overkill - often it was just a complicated way of writing GetTileSlope(tile, NULL)
tron
parents:
3017
diff
changeset
|
579 |
!CanBuildDepotByTileh(p1, tileh) |
2549 | 580 |
)) { |
581 |
return_cmd_error(STR_0007_FLAT_LAND_REQUIRED); |
|
0 | 582 |
} |
583 |
||
584 |
cost = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
585 |
if (CmdFailed(cost)) return CMD_ERROR; |
0 | 586 |
|
587 |
dep = AllocateDepot(); |
|
2549 | 588 |
if (dep == NULL) return CMD_ERROR; |
0 | 589 |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
590 |
if (flags & DC_EXEC) { |
2425
99e1e8430a28
(svn r2951) - Fix: [ 1259345 ] Changing engine in netgame opens train window for everyone
Darkvater
parents:
2422
diff
changeset
|
591 |
if (IsLocalPlayer()) _last_built_road_depot_tile = tile; |
0 | 592 |
|
593 |
dep->xy = tile; |
|
594 |
dep->town_index = ClosestTownFromTile(tile, (uint)-1)->index; |
|
595 |
||
3099
374e275300e3
(svn r3689) Add functions to turn a tile into either a normal road tile, a level crossing or a road depot
tron
parents:
3098
diff
changeset
|
596 |
MakeRoadDepot(tile, _current_player, p1); |
3100
552cf19c49cb
(svn r3695) Add 2 MarkTileByTile() which I forgot in r3689 (noticed by Belugas)
tron
parents:
3099
diff
changeset
|
597 |
MarkTileDirtyByTile(tile); |
0 | 598 |
} |
599 |
return cost + _price.build_road_depot; |
|
600 |
} |
|
601 |
||
1979
f4462d4e8e62
(svn r2485) Missed two uint -> TileIndex, thanks _Luca_
tron
parents:
1977
diff
changeset
|
602 |
static int32 RemoveRoadDepot(TileIndex tile, uint32 flags) |
0 | 603 |
{ |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
84
diff
changeset
|
604 |
if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) |
0 | 605 |
return CMD_ERROR; |
606 |
||
2639 | 607 |
if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
0 | 608 |
|
2639 | 609 |
if (flags & DC_EXEC) DoDeleteDepot(tile); |
0 | 610 |
|
611 |
return _price.remove_road_depot; |
|
612 |
} |
|
613 |
||
614 |
#define M(x) (1<<(x)) |
|
615 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1942
diff
changeset
|
616 |
static int32 ClearTile_Road(TileIndex tile, byte flags) |
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1942
diff
changeset
|
617 |
{ |
3069
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
618 |
switch (GetRoadType(tile)) { |
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
619 |
case ROAD_NORMAL: { |
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
620 |
RoadBits b = GetRoadBits(tile); |
0 | 621 |
|
3060 | 622 |
if (!((1 << b) & (M(1)|M(2)|M(4)|M(8))) && |
623 |
(!(flags & DC_AI_BUILDING) || !IsTileOwner(tile, OWNER_TOWN)) && |
|
624 |
flags & DC_AUTO) { |
|
0 | 625 |
return_cmd_error(STR_1801_MUST_REMOVE_ROAD_FIRST); |
3060 | 626 |
} |
627 |
return DoCommandByTile(tile, b, 0, flags, CMD_REMOVE_ROAD); |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
628 |
} |
0 | 629 |
|
3069
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
630 |
case ROAD_CROSSING: { |
3060 | 631 |
int32 ret; |
632 |
||
3069
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
633 |
if (flags & DC_AUTO) return_cmd_error(STR_1801_MUST_REMOVE_ROAD_FIRST); |
3060 | 634 |
|
3070
512f72481fd9
(svn r3659) Add function to get the road bits of a level crossing
tron
parents:
3069
diff
changeset
|
635 |
ret = DoCommandByTile(tile, GetCrossingRoadBits(tile), 0, flags, CMD_REMOVE_ROAD); |
3060 | 636 |
if (CmdFailed(ret)) return CMD_ERROR; |
637 |
||
638 |
if (flags & DC_EXEC) { |
|
639 |
DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
|
640 |
} |
|
641 |
return ret; |
|
642 |
} |
|
643 |
||
3069
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
644 |
default: |
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
645 |
case ROAD_DEPOT: |
3060 | 646 |
if (flags & DC_AUTO) { |
647 |
return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED); |
|
648 |
} |
|
649 |
return RemoveRoadDepot(tile, flags); |
|
0 | 650 |
} |
651 |
} |
|
652 |
||
653 |
||
654 |
typedef struct DrawRoadTileStruct { |
|
655 |
uint16 image; |
|
656 |
byte subcoord_x; |
|
657 |
byte subcoord_y; |
|
658 |
} DrawRoadTileStruct; |
|
659 |
||
660 |
typedef struct DrawRoadSeqStruct { |
|
661 |
uint32 image; |
|
662 |
byte subcoord_x; |
|
663 |
byte subcoord_y; |
|
664 |
byte width; |
|
665 |
byte height; |
|
666 |
} DrawRoadSeqStruct; |
|
667 |
||
668 |
#include "table/road_land.h" |
|
669 |
||
670 |
||
3098
4c1320da876d
(svn r3687) Complete some bits I missed whenn adding accessor functions for road types and pieces
tron
parents:
3097
diff
changeset
|
671 |
uint GetRoadFoundation(uint tileh, RoadBits bits) |
2548
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2544
diff
changeset
|
672 |
{ |
0 | 673 |
int i; |
674 |
// normal level sloped building |
|
3017
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
675 |
if ((~_valid_tileh_slopes_road[1][tileh] & bits) == 0) return tileh; |
0 | 676 |
|
677 |
// inclined sloped building |
|
3017
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
678 |
if (( |
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
679 |
(i = 0, tileh == 1) || |
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
680 |
(i += 2, tileh == 2) || |
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
681 |
(i += 2, tileh == 4) || |
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
682 |
(i += 2, tileh == 8) |
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
683 |
) && ( |
3098
4c1320da876d
(svn r3687) Complete some bits I missed whenn adding accessor functions for road types and pieces
tron
parents:
3097
diff
changeset
|
684 |
( bits == ROAD_X) || |
4c1320da876d
(svn r3687) Complete some bits I missed whenn adding accessor functions for road types and pieces
tron
parents:
3097
diff
changeset
|
685 |
(i++, bits == ROAD_Y) |
3017
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
686 |
)) { |
0 | 687 |
return i + 15; |
3017
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
688 |
} |
0 | 689 |
|
690 |
return 0; |
|
691 |
} |
|
692 |
||
693 |
const byte _road_sloped_sprites[14] = { |
|
694 |
0, 0, 2, 0, |
|
695 |
0, 1, 0, 0, |
|
696 |
3, 0, 0, 0, |
|
697 |
0, 0 |
|
698 |
}; |
|
699 |
||
2471
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
700 |
/** |
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
701 |
* Draw ground sprite and road pieces |
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
702 |
* @param ti TileInfo |
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
703 |
* @param road RoadBits to draw |
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
704 |
*/ |
3430
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
705 |
static void DrawRoadBits(TileInfo* ti, RoadBits road) |
2471
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
706 |
{ |
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
707 |
const DrawRoadTileStruct *drts; |
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
708 |
PalSpriteID image = 0; |
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
709 |
|
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
710 |
if (ti->tileh != 0) { |
3430
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
711 |
int foundation = GetRoadFoundation(ti->tileh, road); |
2471
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
712 |
|
2639 | 713 |
if (foundation != 0) DrawFoundation(ti, foundation); |
2471
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
714 |
|
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
715 |
// DrawFoundation() modifies ti. |
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
716 |
// Default sloped sprites.. |
2639 | 717 |
if (ti->tileh != 0) image = _road_sloped_sprites[ti->tileh - 1] + 0x53F; |
2471
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
718 |
} |
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
719 |
|
2639 | 720 |
if (image == 0) image = _road_tile_sprites_1[road]; |
2471
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
721 |
|
3430
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
722 |
if (GetGroundType(ti->tile) == RGT_BARREN) image |= PALETTE_TO_BARE_LAND; |
2471
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
723 |
|
3430
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
724 |
if (IsOnSnow(ti->tile)) { |
2471
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
725 |
image += 19; |
3430
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
726 |
} else if (HasPavement(ti->tile)) { |
2471
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
727 |
// Pavement tiles. |
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
728 |
image -= 19; |
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
729 |
} |
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
730 |
|
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
731 |
DrawGroundSprite(image); |
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
732 |
|
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
733 |
// Return if full detail is disabled, or we are zoomed fully out. |
2639 | 734 |
if (!(_display_opt & DO_FULL_DETAIL) || _cur_dpi->zoom == 2) return; |
2471
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
735 |
|
3430
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
736 |
if (HasRoadWorks(ti->tile)) { |
2471
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
737 |
// Road works |
3098
4c1320da876d
(svn r3687) Complete some bits I missed whenn adding accessor functions for road types and pieces
tron
parents:
3097
diff
changeset
|
738 |
DrawGroundSprite(road & ROAD_X ? SPR_EXCAVATION_X : SPR_EXCAVATION_Y); |
2471
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
739 |
return; |
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
740 |
} |
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
741 |
|
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
742 |
// Draw extra details. |
3430
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
743 |
for (drts = _road_display_table[GetGroundType(ti->tile)][road]; drts->image != 0; drts++) { |
2471
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
744 |
int x = ti->x | drts->subcoord_x; |
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
745 |
int y = ti->y | drts->subcoord_y; |
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
746 |
byte z = ti->z; |
2639 | 747 |
if (ti->tileh != 0) z = GetSlopeZ(x, y); |
3017
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
748 |
AddSortableSpriteToDraw(drts->image, x, y, 2, 2, 0x10, z); |
2471
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
749 |
} |
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
750 |
} |
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
751 |
|
0 | 752 |
static void DrawTile_Road(TileInfo *ti) |
753 |
{ |
|
2471
14109854e818
(svn r2997) -Codechange: Split road drawing code off from DrawTile_Road into a separate function to be used elsewhere.
peter1138
parents:
2469
diff
changeset
|
754 |
PalSpriteID image; |
0 | 755 |
|
3098
4c1320da876d
(svn r3687) Complete some bits I missed whenn adding accessor functions for road types and pieces
tron
parents:
3097
diff
changeset
|
756 |
switch (GetRoadType(ti->tile)) { |
4c1320da876d
(svn r3687) Complete some bits I missed whenn adding accessor functions for road types and pieces
tron
parents:
3097
diff
changeset
|
757 |
case ROAD_NORMAL: |
3430
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
758 |
DrawRoadBits(ti, GetRoadBits(ti->tile)); |
3060 | 759 |
break; |
0 | 760 |
|
3098
4c1320da876d
(svn r3687) Complete some bits I missed whenn adding accessor functions for road types and pieces
tron
parents:
3097
diff
changeset
|
761 |
case ROAD_CROSSING: { |
3097
6cb1b1c2ae6d
(svn r3686) Dispel some strange magic regarding level crossings and foundations:
tron
parents:
3091
diff
changeset
|
762 |
if (ti->tileh != 0) DrawFoundation(ti, ti->tileh); |
0 | 763 |
|
3242
1cefa03f0d5e
(svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents:
3234
diff
changeset
|
764 |
image = GetRailTypeInfo(GetRailTypeCrossing(ti->tile))->base_sprites.crossing; |
3060 | 765 |
|
3272
7e556f209503
(svn r3984) Add a function to get the road axis of a level crossing
tron
parents:
3269
diff
changeset
|
766 |
if (GetCrossingRoadAxis(ti->tile) == AXIS_X) image++; |
3060 | 767 |
|
3322
fa5d46929db9
(svn r4088) -Codechange: Introduce {Unb,B}arCrossing and IsCrossingBarred to put and get the status of a level crossing
celestar
parents:
3319
diff
changeset
|
768 |
if (IsCrossingBarred(ti->tile)) image += 2; |
3060 | 769 |
|
3430
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
770 |
if (IsOnSnow(ti->tile)) { |
3060 | 771 |
image += 8; |
772 |
} else { |
|
3430
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
773 |
if (GetGroundType(ti->tile) == RGT_BARREN) image |= PALETTE_TO_BARE_LAND; |
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
774 |
if (HasPavement(ti->tile)) image += 4; |
3060 | 775 |
} |
776 |
||
777 |
DrawGroundSprite(image); |
|
3367 | 778 |
if (GetRailTypeCrossing(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenary(ti); |
3060 | 779 |
break; |
0 | 780 |
} |
781 |
||
3098
4c1320da876d
(svn r3687) Complete some bits I missed whenn adding accessor functions for road types and pieces
tron
parents:
3097
diff
changeset
|
782 |
default: |
4c1320da876d
(svn r3687) Complete some bits I missed whenn adding accessor functions for road types and pieces
tron
parents:
3097
diff
changeset
|
783 |
case ROAD_DEPOT: { |
3060 | 784 |
uint32 ormod; |
785 |
PlayerID player; |
|
786 |
const DrawRoadSeqStruct* drss; |
|
0 | 787 |
|
3060 | 788 |
if (ti->tileh != 0) DrawFoundation(ti, ti->tileh); |
1398 | 789 |
|
3060 | 790 |
ormod = PALETTE_TO_GREY; //was this a bug/problem? |
791 |
player = GetTileOwner(ti->tile); |
|
792 |
if (player < MAX_PLAYERS) ormod = PLAYER_SPRITE_COLOR(player); |
|
0 | 793 |
|
3167
197b5ee5a831
(svn r3795) Add a function to request the orientation of a depot
tron
parents:
3150
diff
changeset
|
794 |
drss = _road_display_datas[GetRoadDepotDirection(ti->tile)]; |
3060 | 795 |
|
796 |
DrawGroundSprite(drss++->image); |
|
797 |
||
798 |
for (; drss->image != 0; drss++) { |
|
799 |
uint32 image = drss->image; |
|
800 |
||
801 |
if (image & PALETTE_MODIFIER_COLOR) image |= ormod; |
|
802 |
if (_display_opt & DO_TRANS_BUILDINGS) MAKE_TRANSPARENT(image); |
|
803 |
||
804 |
AddSortableSpriteToDraw(image, ti->x | drss->subcoord_x, |
|
805 |
ti->y | drss->subcoord_y, drss->width, drss->height, 0x14, ti->z |
|
806 |
); |
|
807 |
} |
|
808 |
break; |
|
0 | 809 |
} |
810 |
} |
|
811 |
} |
|
812 |
||
813 |
void DrawRoadDepotSprite(int x, int y, int image) |
|
814 |
{ |
|
815 |
uint32 ormod; |
|
816 |
const DrawRoadSeqStruct *dtss; |
|
817 |
||
818 |
ormod = PLAYER_SPRITE_COLOR(_local_player); |
|
819 |
||
1398 | 820 |
dtss = _road_display_datas[image]; |
0 | 821 |
|
2639 | 822 |
x += 33; |
823 |
y += 17; |
|
0 | 824 |
|
1398 | 825 |
DrawSprite(dtss++->image, x, y); |
0 | 826 |
|
2952 | 827 |
for (; dtss->image != 0; dtss++) { |
0 | 828 |
Point pt = RemapCoords(dtss->subcoord_x, dtss->subcoord_y, 0); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
829 |
|
0 | 830 |
image = dtss->image; |
2639 | 831 |
if (image & PALETTE_MODIFIER_COLOR) image |= ormod; |
0 | 832 |
|
833 |
DrawSprite(image, x + pt.x, y + pt.y); |
|
834 |
} |
|
835 |
} |
|
836 |
||
2537 | 837 |
static uint GetSlopeZ_Road(const TileInfo* ti) |
0 | 838 |
{ |
3286
3250f1488eb2
(svn r4000) Rewrite GetSlope{Tileh,Z}_{Road,Track} in a less confusing way
tron
parents:
3277
diff
changeset
|
839 |
uint tileh = ti->tileh; |
0 | 840 |
uint z = ti->z; |
3098
4c1320da876d
(svn r3687) Complete some bits I missed whenn adding accessor functions for road types and pieces
tron
parents:
3097
diff
changeset
|
841 |
|
3286
3250f1488eb2
(svn r4000) Rewrite GetSlope{Tileh,Z}_{Road,Track} in a less confusing way
tron
parents:
3277
diff
changeset
|
842 |
if (tileh == 0) return z; |
3250f1488eb2
(svn r4000) Rewrite GetSlope{Tileh,Z}_{Road,Track} in a less confusing way
tron
parents:
3277
diff
changeset
|
843 |
if (GetRoadType(ti->tile) == ROAD_NORMAL) { |
3250f1488eb2
(svn r4000) Rewrite GetSlope{Tileh,Z}_{Road,Track} in a less confusing way
tron
parents:
3277
diff
changeset
|
844 |
uint f = GetRoadFoundation(tileh, GetRoadBits(ti->tile)); |
3060 | 845 |
|
3286
3250f1488eb2
(svn r4000) Rewrite GetSlope{Tileh,Z}_{Road,Track} in a less confusing way
tron
parents:
3277
diff
changeset
|
846 |
if (f != 0) { |
3250f1488eb2
(svn r4000) Rewrite GetSlope{Tileh,Z}_{Road,Track} in a less confusing way
tron
parents:
3277
diff
changeset
|
847 |
if (f < 15) return z + 8; // leveled foundation |
3250f1488eb2
(svn r4000) Rewrite GetSlope{Tileh,Z}_{Road,Track} in a less confusing way
tron
parents:
3277
diff
changeset
|
848 |
tileh = _inclined_tileh[f - 15]; // inclined foundation |
0 | 849 |
} |
3286
3250f1488eb2
(svn r4000) Rewrite GetSlope{Tileh,Z}_{Road,Track} in a less confusing way
tron
parents:
3277
diff
changeset
|
850 |
return z + GetPartialZ(ti->x & 0xF, ti->y & 0xF, tileh); |
3250f1488eb2
(svn r4000) Rewrite GetSlope{Tileh,Z}_{Road,Track} in a less confusing way
tron
parents:
3277
diff
changeset
|
851 |
} else { |
3250f1488eb2
(svn r4000) Rewrite GetSlope{Tileh,Z}_{Road,Track} in a less confusing way
tron
parents:
3277
diff
changeset
|
852 |
return z + 8; |
0 | 853 |
} |
39 | 854 |
} |
855 |
||
3418
a592d40a4d04
(svn r4242) Pass TileIndex and slope to GetSlopeTileh_*() instead of TileInfo
tron
parents:
3415
diff
changeset
|
856 |
static uint GetSlopeTileh_Road(TileIndex tile, uint tileh) |
39 | 857 |
{ |
3418
a592d40a4d04
(svn r4242) Pass TileIndex and slope to GetSlopeTileh_*() instead of TileInfo
tron
parents:
3415
diff
changeset
|
858 |
if (tileh == 0) return 0; |
a592d40a4d04
(svn r4242) Pass TileIndex and slope to GetSlopeTileh_*() instead of TileInfo
tron
parents:
3415
diff
changeset
|
859 |
if (GetRoadType(tile) == ROAD_NORMAL) { |
a592d40a4d04
(svn r4242) Pass TileIndex and slope to GetSlopeTileh_*() instead of TileInfo
tron
parents:
3415
diff
changeset
|
860 |
uint f = GetRoadFoundation(tileh, GetRoadBits(tile)); |
3098
4c1320da876d
(svn r3687) Complete some bits I missed whenn adding accessor functions for road types and pieces
tron
parents:
3097
diff
changeset
|
861 |
|
3418
a592d40a4d04
(svn r4242) Pass TileIndex and slope to GetSlopeTileh_*() instead of TileInfo
tron
parents:
3415
diff
changeset
|
862 |
if (f == 0) return tileh; |
3286
3250f1488eb2
(svn r4000) Rewrite GetSlope{Tileh,Z}_{Road,Track} in a less confusing way
tron
parents:
3277
diff
changeset
|
863 |
if (f < 15) return 0; // leveled foundation |
3250f1488eb2
(svn r4000) Rewrite GetSlope{Tileh,Z}_{Road,Track} in a less confusing way
tron
parents:
3277
diff
changeset
|
864 |
return _inclined_tileh[f - 15]; // inclined foundation |
3250f1488eb2
(svn r4000) Rewrite GetSlope{Tileh,Z}_{Road,Track} in a less confusing way
tron
parents:
3277
diff
changeset
|
865 |
} else { |
3250f1488eb2
(svn r4000) Rewrite GetSlope{Tileh,Z}_{Road,Track} in a less confusing way
tron
parents:
3277
diff
changeset
|
866 |
return 0; |
39 | 867 |
} |
0 | 868 |
} |
869 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1942
diff
changeset
|
870 |
static void GetAcceptedCargo_Road(TileIndex tile, AcceptedCargo ac) |
0 | 871 |
{ |
872 |
/* not used */ |
|
873 |
} |
|
874 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1942
diff
changeset
|
875 |
static void AnimateTile_Road(TileIndex tile) |
0 | 876 |
{ |
2639 | 877 |
if (IsLevelCrossing(tile)) MarkTileDirtyByTile(tile); |
0 | 878 |
} |
879 |
||
3430
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
880 |
static const RoadGroundType _town_road_types[5][2] = { |
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
881 |
{RGT_GRASS,RGT_GRASS}, |
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
882 |
{RGT_PAVED,RGT_PAVED}, |
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
883 |
{RGT_PAVED,RGT_PAVED}, |
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
884 |
{RGT_ALLEY,RGT_ALLEY}, |
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
885 |
{RGT_LIGHT,RGT_PAVED}, |
0 | 886 |
}; |
887 |
||
3430
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
888 |
static const RoadGroundType _town_road_types_2[5][2] = { |
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
889 |
{RGT_GRASS,RGT_GRASS}, |
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
890 |
{RGT_PAVED,RGT_PAVED}, |
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
891 |
{RGT_LIGHT,RGT_PAVED}, |
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
892 |
{RGT_LIGHT,RGT_PAVED}, |
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
893 |
{RGT_LIGHT,RGT_PAVED}, |
0 | 894 |
}; |
895 |
||
896 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1942
diff
changeset
|
897 |
static void TileLoop_Road(TileIndex tile) |
0 | 898 |
{ |
899 |
Town *t; |
|
900 |
int grp; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
901 |
|
3017
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
902 |
switch (_opt.landscape) { |
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
903 |
case LT_HILLY: |
3430
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
904 |
if (IsOnSnow(tile) != (GetTileZ(tile) > _opt.snow_line)) { |
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
905 |
ToggleSnow(tile); |
3017
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
906 |
MarkTileDirtyByTile(tile); |
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
907 |
} |
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
908 |
break; |
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
909 |
|
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
910 |
case LT_DESERT: |
3430
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
911 |
if (GetTropicZone(tile) == TROPICZONE_DESERT && !IsOnDesert(tile)) { |
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
912 |
ToggleDesert(tile); |
3017
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
913 |
MarkTileDirtyByTile(tile); |
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
914 |
} |
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
915 |
break; |
0 | 916 |
} |
917 |
||
3069
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
918 |
if (GetRoadType(tile) == ROAD_DEPOT) return; |
0 | 919 |
|
3430
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
920 |
if (!HasRoadWorks(tile)) { |
1281
1573d0e4e7a1
(svn r1785) -Fix: space-correctness in road_cmd.c, and one wrong line from last
truelight
parents:
1280
diff
changeset
|
921 |
t = ClosestTownFromTile(tile, (uint)-1); |
1280
b6925875de49
(svn r1784) -Fix: removed ClosestTownFromTile where possible, or replaced it
truelight
parents:
1264
diff
changeset
|
922 |
|
0 | 923 |
grp = 0; |
924 |
if (t != NULL) { |
|
925 |
grp = GetTownRadiusGroup(t, tile); |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
926 |
|
0 | 927 |
// Show an animation to indicate road work |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
928 |
if (t->road_build_months != 0 && |
1245
768d9bc95aaa
(svn r1749) Move the functions which calculate distances to map.[ch] and give the more meaningful names
tron
parents:
1214
diff
changeset
|
929 |
!(DistanceManhattan(t->xy, tile) >= 8 && grp == 0) && |
3430
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
930 |
GetRoadType(tile) == ROAD_NORMAL && (GetRoadBits(tile) == ROAD_X || GetRoadBits(tile) == ROAD_Y)) { |
3017
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
931 |
if (GetTileSlope(tile, NULL) == 0 && EnsureNoVehicle(tile) && CHANCE16(1, 20)) { |
3430
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
932 |
StartRoadWorks(tile); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
933 |
|
541 | 934 |
SndPlayTileFx(SND_21_JACKHAMMER, tile); |
0 | 935 |
CreateEffectVehicleAbove( |
3421
8ab76c47c72c
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3418
diff
changeset
|
936 |
TileX(tile) * TILE_SIZE + 7, |
8ab76c47c72c
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3418
diff
changeset
|
937 |
TileY(tile) * TILE_SIZE + 7, |
0 | 938 |
0, |
1359
8ba976aed634
(svn r1863) Give the effect vehicle type enums more descriptive names and use the enum as parameter type for CreateEffectVehicle*()
tron
parents:
1327
diff
changeset
|
939 |
EV_BULLDOZER); |
0 | 940 |
MarkTileDirtyByTile(tile); |
941 |
return; |
|
942 |
} |
|
943 |
} |
|
944 |
} |
|
945 |
||
946 |
{ |
|
3430
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
947 |
/* Adjust road ground type depending on 'grp' (grp is the distance to the center) */ |
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
948 |
const RoadGroundType *target_rgt = (_opt.landscape == LT_CANDY) ? _town_road_types_2[grp] : _town_road_types[grp]; |
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
949 |
RoadGroundType rgt = GetGroundType(tile); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
950 |
|
3430
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
951 |
/* We have our desired type, do nothing */ |
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
952 |
if (rgt == target_rgt[0]) return; |
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
953 |
|
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
954 |
/* We have the pre-type of the desired type, switch to the desired type */ |
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
955 |
if (rgt == target_rgt[1]) { |
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
956 |
rgt = target_rgt[0]; |
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
957 |
/* We have barren land, install the pre-type */ |
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
958 |
} else if (rgt == RGT_BARREN) { |
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
959 |
rgt = target_rgt[1]; |
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
960 |
/* We're totally off limits, remove any installation and make barren land */ |
0 | 961 |
} else { |
3430
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
962 |
rgt = RGT_BARREN; |
0 | 963 |
} |
3430
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
964 |
SetGroundType(tile, rgt); |
0 | 965 |
MarkTileDirtyByTile(tile); |
966 |
} |
|
3430
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
967 |
} else if (IncreaseRoadWorksCounter(tile)) { |
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
968 |
TerminateRoadWorks(tile); |
0 | 969 |
MarkTileDirtyByTile(tile); |
970 |
} |
|
971 |
} |
|
972 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1942
diff
changeset
|
973 |
void ShowRoadDepotWindow(TileIndex tile); |
0 | 974 |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1942
diff
changeset
|
975 |
static void ClickTile_Road(TileIndex tile) |
0 | 976 |
{ |
3069
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
977 |
if (GetRoadType(tile) == ROAD_DEPOT) ShowRoadDepotWindow(tile); |
0 | 978 |
} |
979 |
||
980 |
static const byte _road_trackbits[16] = { |
|
981 |
0x0, 0x0, 0x0, 0x10, 0x0, 0x2, 0x8, 0x1A, 0x0, 0x4, 0x1, 0x15, 0x20, 0x26, 0x29, 0x3F, |
|
982 |
}; |
|
983 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1942
diff
changeset
|
984 |
static uint32 GetTileTrackStatus_Road(TileIndex tile, TransportType mode) |
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1942
diff
changeset
|
985 |
{ |
3066
0d34dff23d98
(svn r3655) Simplify a boolean expression and turn 3 if-cascades into switches
tron
parents:
3061
diff
changeset
|
986 |
switch (mode) { |
0d34dff23d98
(svn r3655) Simplify a boolean expression and turn 3 if-cascades into switches
tron
parents:
3061
diff
changeset
|
987 |
case TRANSPORT_RAIL: |
0d34dff23d98
(svn r3655) Simplify a boolean expression and turn 3 if-cascades into switches
tron
parents:
3061
diff
changeset
|
988 |
if (!IsLevelCrossing(tile)) return 0; |
3267
591027d10884
(svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents:
3242
diff
changeset
|
989 |
return GetCrossingRailBits(tile) * 0x101; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
990 |
|
3066
0d34dff23d98
(svn r3655) Simplify a boolean expression and turn 3 if-cascades into switches
tron
parents:
3061
diff
changeset
|
991 |
case TRANSPORT_ROAD: |
3071
a6acfe74e0a7
(svn r3660) Convert further road bits and type references to the functions/enums
tron
parents:
3070
diff
changeset
|
992 |
switch (GetRoadType(tile)) { |
3069
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
993 |
case ROAD_NORMAL: |
3430
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
994 |
return HasRoadWorks(tile) ? 0 : _road_trackbits[GetRoadBits(tile)] * 0x101; |
3066
0d34dff23d98
(svn r3655) Simplify a boolean expression and turn 3 if-cascades into switches
tron
parents:
3061
diff
changeset
|
995 |
|
3069
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
996 |
case ROAD_CROSSING: { |
3415
4d76e72c6ac2
(svn r4230) The road is asked for, not the rail. Undo part of r4164. (Pointed out by peter1138)
tron
parents:
3381
diff
changeset
|
997 |
uint32 r = (GetCrossingRoadAxis(tile) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y) * 0x101; |
3272
7e556f209503
(svn r3984) Add a function to get the road axis of a level crossing
tron
parents:
3269
diff
changeset
|
998 |
|
3367 | 999 |
if (IsCrossingBarred(tile)) r *= 0x10001; |
3066
0d34dff23d98
(svn r3655) Simplify a boolean expression and turn 3 if-cascades into switches
tron
parents:
3061
diff
changeset
|
1000 |
return r; |
0d34dff23d98
(svn r3655) Simplify a boolean expression and turn 3 if-cascades into switches
tron
parents:
3061
diff
changeset
|
1001 |
} |
0d34dff23d98
(svn r3655) Simplify a boolean expression and turn 3 if-cascades into switches
tron
parents:
3061
diff
changeset
|
1002 |
|
3069
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
1003 |
default: |
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
1004 |
case ROAD_DEPOT: |
3066
0d34dff23d98
(svn r3655) Simplify a boolean expression and turn 3 if-cascades into switches
tron
parents:
3061
diff
changeset
|
1005 |
break; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1006 |
} |
3066
0d34dff23d98
(svn r3655) Simplify a boolean expression and turn 3 if-cascades into switches
tron
parents:
3061
diff
changeset
|
1007 |
break; |
0d34dff23d98
(svn r3655) Simplify a boolean expression and turn 3 if-cascades into switches
tron
parents:
3061
diff
changeset
|
1008 |
|
0d34dff23d98
(svn r3655) Simplify a boolean expression and turn 3 if-cascades into switches
tron
parents:
3061
diff
changeset
|
1009 |
default: break; |
0 | 1010 |
} |
1011 |
return 0; |
|
1012 |
} |
|
1013 |
||
1014 |
static const StringID _road_tile_strings[] = { |
|
1015 |
STR_1814_ROAD, |
|
1016 |
STR_1814_ROAD, |
|
1017 |
STR_1814_ROAD, |
|
1018 |
STR_1815_ROAD_WITH_STREETLIGHTS, |
|
1019 |
STR_1814_ROAD, |
|
1020 |
STR_1816_TREE_LINED_ROAD, |
|
1021 |
STR_1814_ROAD, |
|
1022 |
STR_1814_ROAD, |
|
1023 |
}; |
|
1024 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1942
diff
changeset
|
1025 |
static void GetTileDesc_Road(TileIndex tile, TileDesc *td) |
0 | 1026 |
{ |
1901
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
1027 |
td->owner = GetTileOwner(tile); |
3069
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
1028 |
switch (GetRoadType(tile)) { |
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
1029 |
case ROAD_CROSSING: td->str = STR_1818_ROAD_RAIL_LEVEL_CROSSING; break; |
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
1030 |
case ROAD_DEPOT: td->str = STR_1817_ROAD_VEHICLE_DEPOT; break; |
3430
b283bb956a36
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
celestar
parents:
3421
diff
changeset
|
1031 |
default: td->str = _road_tile_strings[GetGroundType(tile)]; break; |
3069
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
1032 |
} |
0 | 1033 |
} |
1034 |
||
1035 |
static const byte _roadveh_enter_depot_unk0[4] = { |
|
1036 |
8, 9, 0, 1 |
|
1037 |
}; |
|
1038 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1942
diff
changeset
|
1039 |
static uint32 VehicleEnter_Road(Vehicle *v, TileIndex tile, int x, int y) |
0 | 1040 |
{ |
3069
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
1041 |
switch (GetRoadType(tile)) { |
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
1042 |
case ROAD_CROSSING: |
3322
fa5d46929db9
(svn r4088) -Codechange: Introduce {Unb,B}arCrossing and IsCrossingBarred to put and get the status of a level crossing
celestar
parents:
3319
diff
changeset
|
1043 |
if (v->type == VEH_Train && !IsCrossingBarred(tile)) { |
3060 | 1044 |
/* train crossing a road */ |
1045 |
SndPlayVehicleFx(SND_0E_LEVEL_CROSSING, v); |
|
3322
fa5d46929db9
(svn r4088) -Codechange: Introduce {Unb,B}arCrossing and IsCrossingBarred to put and get the status of a level crossing
celestar
parents:
3319
diff
changeset
|
1046 |
BarCrossing(tile); |
3060 | 1047 |
MarkTileDirtyByTile(tile); |
0 | 1048 |
} |
3060 | 1049 |
break; |
1050 |
||
3069
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
1051 |
case ROAD_DEPOT: |
3060 | 1052 |
if (v->type == VEH_Road && v->u.road.frame == 11) { |
3167
197b5ee5a831
(svn r3795) Add a function to request the orientation of a depot
tron
parents:
3150
diff
changeset
|
1053 |
if (_roadveh_enter_depot_unk0[GetRoadDepotDirection(tile)] == v->u.road.state) { |
3060 | 1054 |
RoadVehEnterDepot(v); |
1055 |
return 4; |
|
1056 |
} |
|
1057 |
} |
|
1058 |
break; |
|
1059 |
||
1060 |
default: break; |
|
0 | 1061 |
} |
1062 |
return 0; |
|
1063 |
} |
|
1064 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1942
diff
changeset
|
1065 |
static void VehicleLeave_Road(Vehicle *v, TileIndex tile, int x, int y) |
0 | 1066 |
{ |
1927
4126e0e3e884
(svn r2433) - CodeChange: unmagicify all road/train crossings with IsLevelCrossing() function (peter1138)
Darkvater
parents:
1902
diff
changeset
|
1067 |
if (IsLevelCrossing(tile) && v->type == VEH_Train && v->next == NULL) { |
3322
fa5d46929db9
(svn r4088) -Codechange: Introduce {Unb,B}arCrossing and IsCrossingBarred to put and get the status of a level crossing
celestar
parents:
3319
diff
changeset
|
1068 |
UnbarCrossing(tile); |
0 | 1069 |
MarkTileDirtyByTile(tile); |
1070 |
} |
|
1071 |
} |
|
1072 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
1073 |
static void ChangeTileOwner_Road(TileIndex tile, PlayerID old_player, PlayerID new_player) |
0 | 1074 |
{ |
3274 | 1075 |
if (IsLevelCrossing(tile) && GetCrossingRoadOwner(tile) == old_player) { |
1076 |
SetCrossingRoadOwner(tile, new_player == OWNER_SPECTATOR ? OWNER_NONE : new_player); |
|
0 | 1077 |
} |
1078 |
||
1901
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
1079 |
if (!IsTileOwner(tile, old_player)) return; |
0 | 1080 |
|
2502 | 1081 |
if (new_player != OWNER_SPECTATOR) { |
1902 | 1082 |
SetTileOwner(tile, new_player); |
0 | 1083 |
} else { |
3069
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
1084 |
switch (GetRoadType(tile)) { |
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
1085 |
case ROAD_NORMAL: |
3060 | 1086 |
SetTileOwner(tile, OWNER_NONE); |
1087 |
break; |
|
1088 |
||
3069
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
1089 |
case ROAD_CROSSING: |
3319
7d04847e4689
(svn r4085) Add GetTown{Index,ByTile}() to get the town index resp. the town from a tile
tron
parents:
3286
diff
changeset
|
1090 |
MakeRoadNormal(tile, GetCrossingRoadOwner(tile), GetCrossingRoadBits(tile), GetTownIndex(tile)); |
3060 | 1091 |
break; |
1092 |
||
3069
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
1093 |
default: |
0e6aca11c3da
(svn r3658) Add functions and symbolic names to retrieve road tile types and road pieces
tron
parents:
3068
diff
changeset
|
1094 |
case ROAD_DEPOT: |
3060 | 1095 |
DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); |
1096 |
break; |
|
0 | 1097 |
} |
1098 |
} |
|
1099 |
} |
|
1100 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1059
diff
changeset
|
1101 |
void InitializeRoad(void) |
0 | 1102 |
{ |
1103 |
_last_built_road_depot_tile = 0; |
|
1104 |
} |
|
1105 |
||
1106 |
const TileTypeProcs _tile_type_road_procs = { |
|
1107 |
DrawTile_Road, /* draw_tile_proc */ |
|
1108 |
GetSlopeZ_Road, /* get_slope_z_proc */ |
|
1109 |
ClearTile_Road, /* clear_tile_proc */ |
|
1110 |
GetAcceptedCargo_Road, /* get_accepted_cargo_proc */ |
|
1111 |
GetTileDesc_Road, /* get_tile_desc_proc */ |
|
1112 |
GetTileTrackStatus_Road, /* get_tile_track_status_proc */ |
|
1113 |
ClickTile_Road, /* click_tile_proc */ |
|
1114 |
AnimateTile_Road, /* animate_tile_proc */ |
|
1115 |
TileLoop_Road, /* tile_loop_clear */ |
|
1116 |
ChangeTileOwner_Road, /* change_tile_owner_clear */ |
|
1117 |
NULL, /* get_produced_cargo_proc */ |
|
1118 |
VehicleEnter_Road, /* vehicle_enter_tile_proc */ |
|
1119 |
VehicleLeave_Road, /* vehicle_leave_tile_proc */ |
|
39 | 1120 |
GetSlopeTileh_Road, /* get_slope_tileh_proc */ |
0 | 1121 |
}; |