author | tron |
Tue, 19 Jul 2005 21:49:35 +0000 | |
changeset 2133 | 098c9da8292e |
parent 2124 | 425fb490ae70 |
child 2140 | d708eb80ab8b |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1785
diff
changeset
|
2 |
#include "openttd.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
|
3 |
#include "table/sprites.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
497
diff
changeset
|
4 |
#include "table/strings.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
|
5 |
#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
|
6 |
#include "tile.h" |
0 | 7 |
#include "vehicle.h" |
8 |
#include "viewport.h" |
|
9 |
#include "command.h" |
|
10 |
#include "player.h" |
|
11 |
#include "town.h" |
|
12 |
#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
|
13 |
#include "sound.h" |
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1281
diff
changeset
|
14 |
#include "depot.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
|
15 |
#include "pbs.h" |
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
|
16 |
#include "debug.h" |
0 | 17 |
|
22 | 18 |
/* When true, GetTrackStatus for roads will treat roads under reconstruction |
19 |
* as normal roads instead of impassable. This is used when detecting whether |
|
20 |
* a road can be removed. This is of course ugly, but I don't know a better |
|
21 |
* solution just like that... */ |
|
0 | 22 |
static bool _road_special_gettrackstatus; |
23 |
||
24 |
void RoadVehEnterDepot(Vehicle *v); |
|
25 |
||
26 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1942
diff
changeset
|
27 |
static bool HasTileRoadAt(TileIndex tile, int i) |
0 | 28 |
{ |
29 |
int mask; |
|
30 |
byte b; |
|
31 |
||
1214
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1209
diff
changeset
|
32 |
switch (GetTileType(tile)) { |
0 | 33 |
case MP_STREET: |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
34 |
b = _m[tile].m5; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
35 |
|
0 | 36 |
if ((b & 0xF0) == 0) { |
1927
4126e0e3e884
(svn r2433) - CodeChange: unmagicify all road/train crossings with IsLevelCrossing() function (peter1138)
Darkvater
parents:
1902
diff
changeset
|
37 |
} else if (IsLevelCrossing(tile)) { |
0 | 38 |
b = (b&8)?5:10; |
39 |
} else if ((b & 0xF0) == 0x20) { |
|
40 |
return (~b & 3) == i; |
|
41 |
} else |
|
42 |
return false; |
|
43 |
break; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
44 |
|
0 | 45 |
case MP_STATION: |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
46 |
b = _m[tile].m5; |
0 | 47 |
if (!IS_BYTE_INSIDE(b, 0x43, 0x43+8)) |
48 |
return false; |
|
49 |
return ((~(b - 0x43) & 3) == i); |
|
50 |
||
51 |
case MP_TUNNELBRIDGE: |
|
52 |
mask = GetRoadBitsByTile(tile); |
|
53 |
b = 10; if (mask & 1) break; |
|
54 |
b = 5; if (mask & 2) break; |
|
55 |
return false; |
|
56 |
||
57 |
default: |
|
58 |
return false; |
|
59 |
} |
|
60 |
||
61 |
return HASBIT(b, i); |
|
62 |
} |
|
63 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1942
diff
changeset
|
64 |
static bool CheckAllowRemoveRoad(TileIndex tile, uint br, bool *edge_road) |
0 | 65 |
{ |
66 |
int blocks; |
|
67 |
byte owner; |
|
68 |
uint n; |
|
69 |
*edge_road = true; |
|
70 |
||
71 |
if (_game_mode == GM_EDITOR) |
|
72 |
return true; |
|
73 |
||
74 |
blocks = GetRoadBitsByTile(tile); |
|
75 |
if (blocks == 0) |
|
76 |
return true; |
|
77 |
||
78 |
// Only do the special processing for actual players. |
|
79 |
if (_current_player >= MAX_PLAYERS) |
|
80 |
return true; |
|
81 |
||
82 |
// A railway crossing has the road owner in the map3_lo byte. |
|
1927
4126e0e3e884
(svn r2433) - CodeChange: unmagicify all road/train crossings with IsLevelCrossing() function (peter1138)
Darkvater
parents:
1902
diff
changeset
|
83 |
if (IsTileType(tile, MP_STREET) && IsLevelCrossing(tile)) { |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
84 |
owner = _m[tile].m3; |
0 | 85 |
} 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
|
86 |
owner = GetTileOwner(tile); |
0 | 87 |
} |
88 |
// Only do the special processing if the road is owned |
|
89 |
// by a town |
|
90 |
if (owner != OWNER_TOWN) { |
|
91 |
return owner == OWNER_NONE || CheckOwnership(owner); |
|
92 |
} |
|
93 |
||
94 |
if (_cheats.magic_bulldozer.value) |
|
95 |
return true; |
|
96 |
||
97 |
// Get a bitmask of which neighbouring roads has a tile |
|
98 |
n = 0; |
|
99 |
if (blocks&0x25 && HasTileRoadAt(TILE_ADDXY(tile,-1, 0), 1)) n |= 8; |
|
100 |
if (blocks&0x2A && HasTileRoadAt(TILE_ADDXY(tile, 0, 1), 0)) n |= 4; |
|
101 |
if (blocks&0x19 && HasTileRoadAt(TILE_ADDXY(tile, 1, 0), 3)) n |= 2; |
|
102 |
if (blocks&0x16 && HasTileRoadAt(TILE_ADDXY(tile, 0,-1), 2)) n |= 1; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
103 |
|
0 | 104 |
// If 0 or 1 bits are set in n, or if no bits that match the bits to remove, |
105 |
// then allow it |
|
106 |
if ((n & (n-1)) != 0 && (n & br) != 0) { |
|
107 |
Town *t; |
|
108 |
*edge_road = false; |
|
109 |
// you can remove all kind of roads with extra dynamite |
|
110 |
if (_patches.extra_dynamite) |
|
111 |
return true; |
|
112 |
||
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
|
113 |
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
|
114 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
115 |
SetDParam(0, t->index); |
0 | 116 |
_error_message = STR_2009_LOCAL_AUTHORITY_REFUSES; |
117 |
return false; |
|
118 |
} |
|
119 |
||
120 |
return true; |
|
121 |
} |
|
122 |
||
123 |
uint GetRoadBitsByTile(TileIndex tile) |
|
124 |
{ |
|
159
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
149
diff
changeset
|
125 |
uint32 r = GetTileTrackStatus(tile, TRANSPORT_ROAD); |
0 | 126 |
return (byte)(r | (r >> 8)); |
127 |
} |
|
128 |
||
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
129 |
/** 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
|
130 |
* @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
|
131 |
* @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
|
132 |
* @param p2 unused |
0 | 133 |
*/ |
134 |
int32 CmdRemoveRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
135 |
{ |
|
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
|
136 |
// 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
|
137 |
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
|
138 |
|
0 | 139 |
TileInfo ti; |
140 |
int32 cost; |
|
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
|
141 |
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
|
142 |
PlayerID owner; |
0 | 143 |
Town *t; |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
144 |
/* 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
|
145 |
* false if it was a center piece. Affects town ratings drop */ |
0 | 146 |
bool edge_road; |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
147 |
byte pieces = (byte)p1; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
148 |
|
0 | 149 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
150 |
||
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
151 |
/* Road pieces are max 4 bitset values (NE, NW, SE, SW) */ |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
152 |
if (pieces >> 4) return CMD_ERROR; |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
153 |
|
0 | 154 |
FindLandscapeHeight(&ti, x, y); |
155 |
tile = ti.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
|
156 |
|
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
|
157 |
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
|
158 |
|
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
|
159 |
// owner for railroad crossing is stored somewhere else |
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
|
160 |
// XXX - Fix this so for a given tiletype the owner of the type is in the same variable |
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
|
161 |
owner = IsLevelCrossing(tile) ? _m[tile].m3 : 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
|
162 |
|
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
|
163 |
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
|
164 |
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
|
165 |
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
|
166 |
} else |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
167 |
t = GetTown(_m[tile].m2); |
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
|
168 |
} else |
1280
b6925875de49
(svn r1784) -Fix: removed ClosestTownFromTile where possible, or replaced it
truelight
parents:
1264
diff
changeset
|
169 |
t = NULL; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
170 |
|
0 | 171 |
// allow deleting road under bridge |
172 |
if (ti.type != MP_TUNNELBRIDGE && !EnsureNoVehicle(tile)) |
|
173 |
return CMD_ERROR; |
|
174 |
||
175 |
{ |
|
176 |
bool b; |
|
177 |
_road_special_gettrackstatus = true; |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
178 |
b = CheckAllowRemoveRoad(tile, pieces, &edge_road); |
0 | 179 |
_road_special_gettrackstatus = false; |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
180 |
if (!b) return CMD_ERROR; |
0 | 181 |
} |
182 |
||
183 |
if (ti.type == MP_TUNNELBRIDGE) { |
|
1041
be151b7bc909
(svn r1542) Rename TileHeight to TilePixelHeight, because this is what it actually returns
tron
parents:
1035
diff
changeset
|
184 |
if (!EnsureNoVehicleZ(tile, TilePixelHeight(tile))) |
0 | 185 |
return CMD_ERROR; |
186 |
||
187 |
if ((ti.map5 & 0xE9) == 0xE8) { |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
188 |
if (pieces & 10) goto return_error; |
0 | 189 |
} else if ((ti.map5 & 0xE9) == 0xE9) { |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
190 |
if (pieces & 5) goto return_error; |
0 | 191 |
} else |
192 |
goto return_error; |
|
193 |
||
194 |
cost = _price.remove_road * 2; |
|
195 |
||
196 |
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
|
197 |
ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM); |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
198 |
_m[tile].m5 = ti.map5 & 0xC7; |
1902 | 199 |
SetTileOwner(tile, OWNER_NONE); |
0 | 200 |
MarkTileDirtyByTile(tile); |
201 |
} |
|
202 |
return cost; |
|
203 |
} else if (ti.type == MP_STREET) { |
|
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
|
204 |
// check if you're allowed to remove the street owned by a town |
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
|
205 |
// removal allowance depends on difficulty setting |
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
|
206 |
if (!CheckforTownRating(tile, flags, t, ROAD_REMOVE)) return CMD_ERROR; |
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
|
207 |
|
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
|
208 |
// XXX - change cascading ifs to switch when doing rewrite |
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
|
209 |
if ((ti.map5 & 0xF0) == 0) { // normal road |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
210 |
byte c = pieces, t2; |
0 | 211 |
|
212 |
if (ti.tileh != 0 && (ti.map5 == 5 || ti.map5 == 10)) { |
|
213 |
c |= (c & 0xC) >> 2; |
|
214 |
c |= (c & 0x3) << 2; |
|
215 |
} |
|
216 |
||
217 |
// limit the bits to delete to the existing bits. |
|
218 |
if ((c &= ti.map5) == 0) goto return_error; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
219 |
|
0 | 220 |
// calculate the cost |
221 |
t2 = c; |
|
222 |
cost = 0; |
|
223 |
do { |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
224 |
if (t2&1) cost += _price.remove_road; |
0 | 225 |
} while(t2>>=1); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
226 |
|
0 | 227 |
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
|
228 |
ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM); |
0 | 229 |
|
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
230 |
_m[tile].m5 ^= c; |
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
231 |
if ((_m[tile].m5&0xF) == 0) |
0 | 232 |
DoClearSquare(tile); |
233 |
else |
|
234 |
MarkTileDirtyByTile(tile); |
|
235 |
||
236 |
} |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
237 |
return cost; |
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
|
238 |
} else if ((ti.map5 & 0xE0) == 0) { // railroad crossing |
0 | 239 |
byte c; |
240 |
||
241 |
if (!(ti.map5 & 8)) { |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
242 |
c = 2; |
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
243 |
if (pieces & 5) goto return_error; |
0 | 244 |
} else { |
245 |
c = 1; |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
246 |
if (pieces & 10) goto return_error; |
0 | 247 |
} |
248 |
||
249 |
cost = _price.remove_road * 2; |
|
250 |
if (flags & DC_EXEC) { |
|
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
|
251 |
byte pbs_track = PBSTileReserved(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
|
252 |
ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM); |
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
|
253 |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
254 |
ModifyTile(tile, |
0 | 255 |
MP_SETTYPE(MP_RAILWAY) | |
256 |
MP_MAP2_CLEAR | MP_MAP3LO | MP_MAP3HI_CLEAR | MP_MAP5, |
|
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
257 |
_m[tile].m4 & 0xF, /* map3_lo */ |
0 | 258 |
c /* map5 */ |
259 |
); |
|
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
|
260 |
if (pbs_track != 0) |
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
|
261 |
PBSReserveTrack(tile, FIND_FIRST_BIT(pbs_track)); |
0 | 262 |
} |
263 |
return cost; |
|
264 |
} else |
|
265 |
goto return_error; |
|
266 |
||
267 |
} else { |
|
268 |
return_error:; |
|
269 |
return_cmd_error(INVALID_STRING_ID); |
|
270 |
} |
|
271 |
} |
|
272 |
||
273 |
||
274 |
enum { |
|
275 |
ROAD_NW = 1, // NW road track |
|
276 |
ROAD_SW = 2, // SW road track |
|
277 |
ROAD_SE = 4, // SE road track |
|
278 |
ROAD_NE = 8, // NE road track |
|
279 |
ROAD_ALL = (ROAD_NW | ROAD_SW | ROAD_SE | ROAD_NE) |
|
280 |
}; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
281 |
|
13
3e7c1f74a996
(svn r14) Fix: railroad crossings on slopes are now possible
dominik
parents:
0
diff
changeset
|
282 |
static const byte _valid_tileh_slopes_road[3][15] = { |
0 | 283 |
// set of normal ones |
284 |
{ |
|
285 |
ROAD_ALL, 0, 0, |
|
286 |
ROAD_SW | ROAD_NE, 0, 0, // 3, 4, 5 |
|
287 |
ROAD_NW | ROAD_SE, 0, 0, |
|
288 |
ROAD_NW | ROAD_SE, 0, 0, // 9, 10, 11 |
|
289 |
ROAD_SW | ROAD_NE, 0, 0 |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
290 |
}, |
0 | 291 |
// 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
|
292 |
{ |
0 | 293 |
0, |
294 |
ROAD_SW | ROAD_NW, |
|
295 |
ROAD_SW | ROAD_SE, |
|
296 |
ROAD_NW | ROAD_SE | ROAD_SW, |
|
297 |
||
298 |
ROAD_SE | ROAD_NE, // 4 |
|
299 |
ROAD_ALL, |
|
300 |
ROAD_SW | ROAD_NE | ROAD_SE, |
|
301 |
ROAD_ALL, |
|
302 |
||
303 |
ROAD_NW | ROAD_NE, // 8 |
|
304 |
ROAD_SW | ROAD_NE | ROAD_NW, |
|
305 |
ROAD_ALL, |
|
306 |
ROAD_ALL, |
|
307 |
||
308 |
ROAD_NW | ROAD_SE | ROAD_NE, // 12 |
|
309 |
ROAD_ALL, |
|
310 |
ROAD_ALL |
|
13
3e7c1f74a996
(svn r14) Fix: railroad crossings on slopes are now possible
dominik
parents:
0
diff
changeset
|
311 |
}, |
3e7c1f74a996
(svn r14) Fix: railroad crossings on slopes are now possible
dominik
parents:
0
diff
changeset
|
312 |
// valid railway crossings on slopes |
3e7c1f74a996
(svn r14) Fix: railroad crossings on slopes are now possible
dominik
parents:
0
diff
changeset
|
313 |
{ |
3e7c1f74a996
(svn r14) Fix: railroad crossings on slopes are now possible
dominik
parents:
0
diff
changeset
|
314 |
1, 0, 0, // 0, 1, 2 |
3e7c1f74a996
(svn r14) Fix: railroad crossings on slopes are now possible
dominik
parents:
0
diff
changeset
|
315 |
0, 0, 1, // 3, 4, 5 |
3e7c1f74a996
(svn r14) Fix: railroad crossings on slopes are now possible
dominik
parents:
0
diff
changeset
|
316 |
0, 1, 0, // 6, 7, 8 |
3e7c1f74a996
(svn r14) Fix: railroad crossings on slopes are now possible
dominik
parents:
0
diff
changeset
|
317 |
0, 1, 1, // 9, 10, 11 |
3e7c1f74a996
(svn r14) Fix: railroad crossings on slopes are now possible
dominik
parents:
0
diff
changeset
|
318 |
0, 1, 1, // 12, 13, 14 |
0 | 319 |
} |
320 |
}; |
|
321 |
||
322 |
||
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
323 |
static uint32 CheckRoadSlope(int tileh, byte *pieces, byte existing) |
0 | 324 |
{ |
2085
ae9e92ffe168
(svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents:
2074
diff
changeset
|
325 |
if (!IsSteepTileh(tileh)) { |
0 | 326 |
byte road_bits = *pieces | existing; |
327 |
||
328 |
// no special foundation |
|
329 |
if ((~_valid_tileh_slopes_road[0][tileh] & road_bits) == 0) { |
|
330 |
// force that all bits are set when we have slopes |
|
331 |
if (tileh != 0) *pieces |= _valid_tileh_slopes_road[0][tileh]; |
|
332 |
return 0; // no extra cost |
|
333 |
} |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
334 |
|
0 | 335 |
// foundation is used. Whole tile is leveled up |
336 |
if ((~_valid_tileh_slopes_road[1][tileh] & road_bits) == 0) { |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
337 |
return existing ? 0 : _price.terraform; |
0 | 338 |
} |
339 |
||
340 |
// partly leveled up tile, only if there's no road on that tile |
|
341 |
if ( !existing && (tileh == 1 || tileh == 2 || tileh == 4 || tileh == 8) ) { |
|
342 |
// force full pieces. |
|
343 |
*pieces |= (*pieces & 0xC) >> 2; |
|
344 |
*pieces |= (*pieces & 0x3) << 2; |
|
72
24bdf837198c
(svn r73) -Fix: Wrong building of road-slopes for a future AI/Town
darkvater
parents:
39
diff
changeset
|
345 |
return (*pieces == (ROAD_NE|ROAD_SW) || *pieces == (ROAD_SE|ROAD_NW)) ? _price.terraform : CMD_ERROR; |
0 | 346 |
} |
347 |
} |
|
348 |
return CMD_ERROR; |
|
349 |
} |
|
350 |
||
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
351 |
/** 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
|
352 |
* @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
|
353 |
* @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
|
354 |
* @param p2 the town that is building the road (0 if not applicable) |
0 | 355 |
*/ |
356 |
int32 CmdBuildRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
357 |
{ |
|
358 |
TileInfo ti; |
|
359 |
int32 cost; |
|
360 |
byte pieces = (byte)p1, existing = 0; |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
361 |
TileIndex tile; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
362 |
|
0 | 363 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
364 |
||
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
365 |
/* 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
|
366 |
* if a non-player is building the road */ |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
367 |
if ((pieces >> 4) || (_current_player < MAX_PLAYERS && p2 != 0) || !IsTownIndex(p2)) return CMD_ERROR; |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
368 |
|
0 | 369 |
FindLandscapeHeight(&ti, x, y); |
370 |
tile = ti.tile; |
|
371 |
||
372 |
// allow building road under bridge |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
373 |
if (ti.type != MP_TUNNELBRIDGE && !EnsureNoVehicle(tile)) return CMD_ERROR; |
0 | 374 |
|
375 |
if (ti.type == MP_STREET) { |
|
376 |
if (!(ti.map5 & 0xF0)) { |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
377 |
if ( (pieces & (byte)(ti.map5)) == (pieces)) |
0 | 378 |
return_cmd_error(STR_1007_ALREADY_BUILT); |
379 |
existing = ti.map5; |
|
380 |
} else { |
|
381 |
if (!(ti.map5 & 0xE0) && pieces != ((ti.map5 & 8) ? 5 : 10)) |
|
382 |
return_cmd_error(STR_1007_ALREADY_BUILT); |
|
383 |
goto do_clear; |
|
384 |
} |
|
385 |
} else if (ti.type == MP_RAILWAY) { |
|
386 |
byte m5; |
|
387 |
||
2124
425fb490ae70
(svn r2634) Fix typo: IsSteepTile expects a tileh, not a TileIndex (thanks to peter1138)
tron
parents:
2085
diff
changeset
|
388 |
if (IsSteepTileh(ti.tileh)) // very steep tile |
13
3e7c1f74a996
(svn r14) Fix: railroad crossings on slopes are now possible
dominik
parents:
0
diff
changeset
|
389 |
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
3e7c1f74a996
(svn r14) Fix: railroad crossings on slopes are now possible
dominik
parents:
0
diff
changeset
|
390 |
|
3e7c1f74a996
(svn r14) Fix: railroad crossings on slopes are now possible
dominik
parents:
0
diff
changeset
|
391 |
if(!_valid_tileh_slopes_road[2][ti.tileh]) // prevent certain slopes |
3e7c1f74a996
(svn r14) Fix: railroad crossings on slopes are now possible
dominik
parents:
0
diff
changeset
|
392 |
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
3e7c1f74a996
(svn r14) Fix: railroad crossings on slopes are now possible
dominik
parents:
0
diff
changeset
|
393 |
|
0 | 394 |
if (ti.map5 == 2) { |
395 |
if (pieces & 5) goto do_clear; |
|
396 |
m5 = 0x10; |
|
397 |
} else if (ti.map5 == 1) { |
|
398 |
if (pieces & 10) goto do_clear; |
|
399 |
m5 = 0x18; |
|
400 |
} else |
|
401 |
goto do_clear; |
|
402 |
||
403 |
if (flags & DC_EXEC) { |
|
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
|
404 |
byte pbs_track = PBSTileReserved(tile); |
0 | 405 |
ModifyTile(tile, |
406 |
MP_SETTYPE(MP_STREET) | |
|
1264
280792016b02
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1247
diff
changeset
|
407 |
MP_MAP2 | MP_MAP3LO | MP_MAP3HI | MP_MAP5, |
280792016b02
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1247
diff
changeset
|
408 |
p2, |
0 | 409 |
_current_player, /* map3_lo */ |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
410 |
_m[tile].m3 & 0xF, /* map3_hi */ |
0 | 411 |
m5 /* map5 */ |
412 |
); |
|
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
|
413 |
if (pbs_track != 0) |
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
|
414 |
PBSReserveTrack(tile, FIND_FIRST_BIT(pbs_track)); |
0 | 415 |
} |
416 |
return _price.build_road * 2; |
|
417 |
} else if (ti.type == MP_TUNNELBRIDGE) { |
|
418 |
||
419 |
/* check for flat land */ |
|
2085
ae9e92ffe168
(svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents:
2074
diff
changeset
|
420 |
if (IsSteepTileh(ti.tileh)) // very steep tile |
0 | 421 |
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
422 |
||
423 |
/* is this middle part of a bridge? */ |
|
424 |
if ((ti.map5 & 0xC0) != 0xC0) |
|
425 |
goto do_clear; |
|
426 |
||
427 |
/* only allow roads pertendicular to bridge */ |
|
959
b031d88c76f3
(svn r1451) Fix some of the signed/unsigned comparison warnings
tron
parents:
926
diff
changeset
|
428 |
if ((pieces & 5U) == (ti.map5 & 0x01U)) |
0 | 429 |
goto do_clear; |
430 |
||
431 |
/* check if clear land under bridge */ |
|
432 |
if ((ti.map5 & 0xF8) == 0xE8) /* road under bridge */ |
|
433 |
return_cmd_error(STR_1007_ALREADY_BUILT); |
|
434 |
else if ((ti.map5 & 0xE0) == 0xE0) /* other transport route under bridge */ |
|
435 |
return_cmd_error(STR_1008_MUST_REMOVE_RAILROAD_TRACK); |
|
436 |
else if ((ti.map5 & 0xF8) == 0xC8) /* water under bridge */ |
|
437 |
return_cmd_error(STR_3807_CAN_T_BUILD_ON_WATER); |
|
438 |
||
439 |
/* all checked, can build road now! */ |
|
440 |
cost = _price.build_road * 2; |
|
441 |
if (flags & DC_EXEC) { |
|
442 |
ModifyTile(tile, |
|
443 |
MP_MAPOWNER_CURRENT | MP_MAP5, |
|
444 |
(ti.map5 & 0xC7) | 0x28 // map5 |
|
445 |
); |
|
446 |
} |
|
447 |
return cost; |
|
448 |
} else { |
|
449 |
do_clear:; |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
450 |
if (CmdFailed(DoCommandByTile(tile, 0, 0, flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR))) |
0 | 451 |
return CMD_ERROR; |
452 |
} |
|
453 |
||
454 |
cost = CheckRoadSlope(ti.tileh, &pieces, existing); |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
455 |
if (CmdFailed(cost)) return_cmd_error(STR_1800_LAND_SLOPED_IN_WRONG_DIRECTION); |
0 | 456 |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
72
diff
changeset
|
457 |
if (cost && (!_patches.build_on_slopes || (!_patches.ainew_active && _is_ai_player))) |
0 | 458 |
return CMD_ERROR; |
459 |
||
460 |
if (!(ti.type == MP_STREET && (ti.map5 & 0xF0) == 0)) { |
|
461 |
cost += DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
|
462 |
} else { |
|
463 |
// Don't put the pieces that already exist |
|
464 |
pieces &= ~ti.map5; |
|
465 |
} |
|
466 |
||
467 |
{ |
|
468 |
byte t = pieces; |
|
469 |
while (t) { |
|
470 |
if (t & 1) cost += _price.build_road; |
|
471 |
t >>= 1; |
|
472 |
} |
|
473 |
} |
|
474 |
||
475 |
if (flags & DC_EXEC) { |
|
476 |
if (ti.type != MP_STREET) { |
|
1059
c28c6be74291
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1041
diff
changeset
|
477 |
SetTileType(tile, MP_STREET); |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
478 |
_m[tile].m5 = 0; |
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
479 |
_m[tile].m2 = p2; |
1902 | 480 |
SetTileOwner(tile, _current_player); |
0 | 481 |
} |
482 |
||
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
483 |
_m[tile].m5 |= (byte)pieces; |
0 | 484 |
|
485 |
MarkTileDirtyByTile(tile); |
|
486 |
} |
|
487 |
return cost; |
|
488 |
} |
|
489 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1942
diff
changeset
|
490 |
int32 DoConvertStreetRail(TileIndex tile, uint totype, bool exec) |
0 | 491 |
{ |
492 |
// not a railroad crossing? |
|
1927
4126e0e3e884
(svn r2433) - CodeChange: unmagicify all road/train crossings with IsLevelCrossing() function (peter1138)
Darkvater
parents:
1902
diff
changeset
|
493 |
if (!IsLevelCrossing(tile)) return CMD_ERROR; |
0 | 494 |
|
495 |
// not owned by me? |
|
496 |
if (!CheckTileOwnership(tile) || !EnsureNoVehicle(tile)) return CMD_ERROR; |
|
497 |
||
498 |
// tile is already of requested type? |
|
2133 | 499 |
if ((_m[tile].m4 & 0xFU) == totype) return CMD_ERROR; |
0 | 500 |
|
501 |
if (exec) { |
|
502 |
// change type. |
|
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
503 |
_m[tile].m4 = (_m[tile].m4 & 0xF0) + totype; |
0 | 504 |
MarkTileDirtyByTile(tile); |
505 |
} |
|
506 |
||
507 |
return _price.build_rail >> 1; |
|
508 |
} |
|
509 |
||
510 |
||
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
511 |
/** 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
|
512 |
* @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
|
513 |
* @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
|
514 |
* @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
|
515 |
* - 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
|
516 |
* - 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
|
517 |
* - 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
|
518 |
*/ |
0 | 519 |
int32 CmdBuildLongRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
520 |
{ |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
521 |
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
|
522 |
int32 cost, ret; |
0 | 523 |
|
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
|
524 |
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
|
525 |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
526 |
if (p1 > MapSize()) return CMD_ERROR; |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
527 |
|
0 | 528 |
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
|
529 |
end_tile = TileVirtXY(x, y); |
0 | 530 |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
531 |
/* 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
|
532 |
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
|
533 |
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
|
534 |
|
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
535 |
/* 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
|
536 |
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
|
537 |
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
|
538 |
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
|
539 |
end_tile = t; |
0 | 540 |
p2 ^= IS_INT_INSIDE(p2&3, 1, 3) ? 3 : 0; |
541 |
} |
|
542 |
||
543 |
cost = 0; |
|
544 |
tile = start_tile; |
|
545 |
// 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
|
546 |
for (;;) { |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
547 |
uint bits = HASBIT(p2, 2) ? ROAD_SE | ROAD_NW : ROAD_SW | ROAD_NE; |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
548 |
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
|
549 |
if (tile == start_tile && HASBIT(p2, 0)) bits &= ROAD_SE | ROAD_SW; |
0 | 550 |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
551 |
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
|
552 |
if (CmdFailed(ret)) { |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
553 |
if (_error_message != STR_1007_ALREADY_BUILT) return CMD_ERROR; |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
554 |
} else |
0 | 555 |
cost += ret; |
556 |
||
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
557 |
if (tile == end_tile) break; |
0 | 558 |
|
1981 | 559 |
tile += HASBIT(p2, 2) ? TileDiffXY(0, 1) : TileDiffXY(1, 0); |
0 | 560 |
} |
561 |
||
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
562 |
return (cost == 0) ? CMD_ERROR : cost; |
0 | 563 |
} |
564 |
||
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
565 |
/** 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
|
566 |
* @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
|
567 |
* @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
|
568 |
* @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
|
569 |
* - 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
|
570 |
* - 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
|
571 |
* - 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
|
572 |
*/ |
0 | 573 |
int32 CmdRemoveLongRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
574 |
{ |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
575 |
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
|
576 |
int32 cost, ret; |
0 | 577 |
|
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
|
578 |
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
|
579 |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
580 |
if (p1 > MapSize()) return CMD_ERROR; |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
581 |
|
0 | 582 |
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
|
583 |
end_tile = TileVirtXY(x, y); |
0 | 584 |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
585 |
/* 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
|
586 |
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
|
587 |
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
|
588 |
|
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
589 |
/* 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
|
590 |
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
|
591 |
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
|
592 |
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
|
593 |
end_tile = t; |
0 | 594 |
p2 ^= IS_INT_INSIDE(p2&3, 1, 3) ? 3 : 0; |
595 |
} |
|
596 |
||
597 |
cost = 0; |
|
598 |
tile = start_tile; |
|
599 |
// 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
|
600 |
for (;;) { |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
601 |
uint bits = HASBIT(p2, 2) ? ROAD_SE | ROAD_NW : ROAD_SW | ROAD_NE; |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
602 |
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
|
603 |
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
|
604 |
|
0 | 605 |
// try to remove the halves. |
606 |
if (bits) { |
|
607 |
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
|
608 |
if (!CmdFailed(ret)) cost += ret; |
0 | 609 |
} |
610 |
||
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
611 |
if (tile == end_tile) break; |
0 | 612 |
|
1981 | 613 |
tile += HASBIT(p2, 2) ? TileDiffXY(0, 1) : TileDiffXY(1, 0); |
0 | 614 |
} |
615 |
||
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
616 |
return (cost == 0) ? CMD_ERROR : cost; |
0 | 617 |
} |
618 |
||
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
619 |
/** 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
|
620 |
* @param x,y tile coordinates where the depot will be built |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
621 |
* @param p1 depot direction (0 through 3), where 0 is NW, 1 is NE, etc. |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
622 |
* @param p2 unused |
2085
ae9e92ffe168
(svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents:
2074
diff
changeset
|
623 |
* |
ae9e92ffe168
(svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents:
2074
diff
changeset
|
624 |
* @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
|
625 |
* distingush between "Flat land required" and "land sloped in wrong direction" |
0 | 626 |
*/ |
627 |
int32 CmdBuildRoadDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
628 |
{ |
|
629 |
TileInfo ti; |
|
630 |
int32 cost; |
|
631 |
Depot *dep; |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1638
diff
changeset
|
632 |
TileIndex tile; |
0 | 633 |
|
634 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
|
635 |
||
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
|
636 |
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
|
637 |
|
0 | 638 |
FindLandscapeHeight(&ti, x, y); |
639 |
||
640 |
tile = ti.tile; |
|
641 |
||
642 |
if (!EnsureNoVehicle(tile)) |
|
643 |
return CMD_ERROR; |
|
644 |
||
2085
ae9e92ffe168
(svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents:
2074
diff
changeset
|
645 |
if ((ti.tileh != 0) && ( |
ae9e92ffe168
(svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents:
2074
diff
changeset
|
646 |
!_patches.build_on_slopes || |
ae9e92ffe168
(svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents:
2074
diff
changeset
|
647 |
IsSteepTileh(ti.tileh) || |
ae9e92ffe168
(svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents:
2074
diff
changeset
|
648 |
!CanBuildDepotByTileh(p1, ti.tileh) |
ae9e92ffe168
(svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents:
2074
diff
changeset
|
649 |
) |
ae9e92ffe168
(svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents:
2074
diff
changeset
|
650 |
) { |
0 | 651 |
return_cmd_error(STR_0007_FLAT_LAND_REQUIRED); |
652 |
} |
|
653 |
||
654 |
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
|
655 |
if (CmdFailed(cost)) return CMD_ERROR; |
0 | 656 |
|
657 |
dep = AllocateDepot(); |
|
658 |
if (dep == NULL) |
|
659 |
return CMD_ERROR; |
|
660 |
||
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
661 |
if (flags & DC_EXEC) { |
1986
5dd3db2b86d7
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1981
diff
changeset
|
662 |
if (_current_player == _local_player) _last_built_road_depot_tile = tile; |
0 | 663 |
|
664 |
dep->xy = tile; |
|
665 |
dep->town_index = ClosestTownFromTile(tile, (uint)-1)->index; |
|
666 |
||
667 |
ModifyTile(tile, |
|
668 |
MP_SETTYPE(MP_STREET) | |
|
669 |
MP_MAPOWNER_CURRENT | MP_MAP5, |
|
670 |
(p1 | 0x20) /* map5 */ |
|
671 |
); |
|
672 |
||
673 |
} |
|
674 |
return cost + _price.build_road_depot; |
|
675 |
} |
|
676 |
||
1979
f4462d4e8e62
(svn r2485) Missed two uint -> TileIndex, thanks _Luca_
tron
parents:
1977
diff
changeset
|
677 |
static int32 RemoveRoadDepot(TileIndex tile, uint32 flags) |
0 | 678 |
{ |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
84
diff
changeset
|
679 |
if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) |
0 | 680 |
return CMD_ERROR; |
681 |
||
682 |
if (!EnsureNoVehicle(tile)) |
|
683 |
return CMD_ERROR; |
|
684 |
||
685 |
if (flags & DC_EXEC) { |
|
686 |
DoDeleteDepot(tile); |
|
687 |
} |
|
688 |
||
689 |
return _price.remove_road_depot; |
|
690 |
} |
|
691 |
||
692 |
#define M(x) (1<<(x)) |
|
693 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1942
diff
changeset
|
694 |
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
|
695 |
{ |
0 | 696 |
int32 ret; |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
697 |
byte m5 = _m[tile].m5; |
0 | 698 |
|
699 |
if ( (m5 & 0xF0) == 0) { |
|
700 |
byte b = m5 & 0xF; |
|
701 |
||
702 |
if (! ((1 << b) & (M(1)|M(2)|M(4)|M(8))) ) { |
|
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
|
703 |
if ((!(flags & DC_AI_BUILDING) || !IsTileOwner(tile, OWNER_TOWN)) && flags & DC_AUTO) |
0 | 704 |
return_cmd_error(STR_1801_MUST_REMOVE_ROAD_FIRST); |
705 |
} |
|
706 |
return DoCommandByTile(tile, b, 0, flags, CMD_REMOVE_ROAD); |
|
707 |
} else if ( (m5 & 0xE0) == 0) { |
|
708 |
if (flags & DC_AUTO) |
|
709 |
return_cmd_error(STR_1801_MUST_REMOVE_ROAD_FIRST); |
|
710 |
||
711 |
ret = DoCommandByTile(tile, (m5&8)?5:10, 0, flags, CMD_REMOVE_ROAD); |
|
712 |
if (ret == CMD_ERROR) |
|
713 |
return CMD_ERROR; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
714 |
|
0 | 715 |
if (flags & DC_EXEC) { |
716 |
DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
717 |
} |
0 | 718 |
|
719 |
return ret; |
|
720 |
} else { |
|
721 |
if (flags & DC_AUTO) |
|
722 |
return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED); |
|
723 |
return RemoveRoadDepot(tile,flags); |
|
724 |
} |
|
725 |
} |
|
726 |
||
727 |
||
728 |
typedef struct DrawRoadTileStruct { |
|
729 |
uint16 image; |
|
730 |
byte subcoord_x; |
|
731 |
byte subcoord_y; |
|
732 |
} DrawRoadTileStruct; |
|
733 |
||
734 |
typedef struct DrawRoadSeqStruct { |
|
735 |
uint32 image; |
|
736 |
byte subcoord_x; |
|
737 |
byte subcoord_y; |
|
738 |
byte width; |
|
739 |
byte height; |
|
740 |
} DrawRoadSeqStruct; |
|
741 |
||
742 |
#include "table/road_land.h" |
|
743 |
||
744 |
||
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
72
diff
changeset
|
745 |
uint GetRoadFoundation(uint tileh, uint bits) { |
0 | 746 |
int i; |
747 |
// normal level sloped building |
|
748 |
if ((~_valid_tileh_slopes_road[1][tileh] & bits) == 0) |
|
749 |
return tileh; |
|
750 |
||
751 |
// inclined sloped building |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
752 |
if ( ((i=0, tileh == 1) || (i+=2, tileh == 2) || (i+=2, tileh == 4) || (i+=2, tileh == 8)) && |
0 | 753 |
((bits == (ROAD_SW | ROAD_NE)) || (i++, bits == (ROAD_NW | ROAD_SE)))) |
754 |
return i + 15; |
|
755 |
||
13
3e7c1f74a996
(svn r14) Fix: railroad crossings on slopes are now possible
dominik
parents:
0
diff
changeset
|
756 |
// rail crossing |
3e7c1f74a996
(svn r14) Fix: railroad crossings on slopes are now possible
dominik
parents:
0
diff
changeset
|
757 |
if ((bits & 0x10) && _valid_tileh_slopes_road[2][tileh]) |
3e7c1f74a996
(svn r14) Fix: railroad crossings on slopes are now possible
dominik
parents:
0
diff
changeset
|
758 |
return tileh; |
3e7c1f74a996
(svn r14) Fix: railroad crossings on slopes are now possible
dominik
parents:
0
diff
changeset
|
759 |
|
0 | 760 |
return 0; |
761 |
} |
|
762 |
||
763 |
const byte _road_sloped_sprites[14] = { |
|
764 |
0, 0, 2, 0, |
|
765 |
0, 1, 0, 0, |
|
766 |
3, 0, 0, 0, |
|
767 |
0, 0 |
|
768 |
}; |
|
769 |
||
770 |
static void DrawTile_Road(TileInfo *ti) |
|
771 |
{ |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
772 |
uint32 image; |
817
4f9377b7fd2b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
679
diff
changeset
|
773 |
uint16 m2; |
0 | 774 |
|
775 |
if ( (ti->map5 & 0xF0) == 0) { // if it is a road the upper 4 bits are 0 |
|
776 |
const DrawRoadTileStruct *drts; |
|
777 |
||
778 |
if (ti->tileh != 0) { |
|
779 |
int f = GetRoadFoundation(ti->tileh, ti->map5 & 0xF); |
|
780 |
if (f) DrawFoundation(ti, f); |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
781 |
|
0 | 782 |
// default sloped sprites.. |
783 |
if (ti->tileh != 0) { |
|
784 |
image = _road_sloped_sprites[ti->tileh - 1] + 0x53F; |
|
785 |
} else { |
|
786 |
image = _road_tile_sprites_1[ti->map5 & 0xF]; |
|
787 |
} |
|
788 |
} else { |
|
789 |
image = _road_tile_sprites_1[ti->map5 & 0xF]; |
|
790 |
} |
|
791 |
||
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
792 |
m2 = (_m[ti->tile].m4 & 0x70) >> 4; |
0 | 793 |
|
794 |
if (m2 == 0) image |= 0x3178000; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
795 |
|
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
796 |
if (_m[ti->tile].m4 & 0x80) { |
0 | 797 |
image += 19; |
798 |
} else if (m2 > 1 && m2 != 6) { |
|
799 |
image -= 19; /* pavement along the road? */ |
|
800 |
} |
|
801 |
||
802 |
DrawGroundSprite(image); |
|
803 |
||
804 |
if (!(_display_opt & DO_FULL_DETAIL) || _cur_dpi->zoom == 2) |
|
805 |
return; |
|
806 |
||
807 |
if (m2 >= 6) { |
|
808 |
// roadwork |
|
809 |
DrawGroundSprite(0x586 + ((ti->map5&8)!=0 ? 0 : 1)); |
|
810 |
return; |
|
811 |
} |
|
812 |
||
1398 | 813 |
drts = _road_display_table[m2][ti->map5 & 0xF]; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
814 |
|
0 | 815 |
while ((image = drts->image) != 0) { |
816 |
int x = ti->x | drts->subcoord_x; |
|
817 |
int y = ti->y | drts->subcoord_y; |
|
818 |
byte z = ti->z; |
|
819 |
if (ti->tileh != 0) z = GetSlopeZ(x, y); |
|
820 |
AddSortableSpriteToDraw(image, x, y, 2, 2, 0x10, z); |
|
821 |
drts++; |
|
822 |
} |
|
13
3e7c1f74a996
(svn r14) Fix: railroad crossings on slopes are now possible
dominik
parents:
0
diff
changeset
|
823 |
} else if ( (ti->map5 & 0xE0) == 0) { // railroad crossing |
3e7c1f74a996
(svn r14) Fix: railroad crossings on slopes are now possible
dominik
parents:
0
diff
changeset
|
824 |
int f = GetRoadFoundation(ti->tileh, ti->map5 & 0xF); |
3e7c1f74a996
(svn r14) Fix: railroad crossings on slopes are now possible
dominik
parents:
0
diff
changeset
|
825 |
if (f) DrawFoundation(ti, f); |
3e7c1f74a996
(svn r14) Fix: railroad crossings on slopes are now possible
dominik
parents:
0
diff
changeset
|
826 |
|
0 | 827 |
image = 0x55B; |
828 |
||
829 |
if ( (ti->map5 & 8) != 0) |
|
830 |
image--; |
|
831 |
||
832 |
if ( (ti->map5 & 4) != 0) |
|
833 |
image += 2; |
|
834 |
||
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
835 |
if ( _m[ti->tile].m4 & 0x80) { |
0 | 836 |
image += 8; |
837 |
} else { |
|
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
838 |
m2 = (_m[ti->tile].m4 & 0x70) >> 4; |
0 | 839 |
if (m2 == 0) image |= 0x3178000; |
840 |
if (m2 > 1) image += 4; |
|
841 |
} |
|
842 |
||
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
843 |
DrawGroundSprite(image + (_m[ti->tile].m4 & 0xF) * 12); |
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
|
844 |
|
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
|
845 |
if (_debug_pbs_level >= 1) { |
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
|
846 |
byte pbs = PBSTileReserved(ti->tile); |
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
|
847 |
if (pbs & TRACK_BIT_DIAG1) DrawGroundSprite(0x3ED | PALETTE_CRASH); |
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
|
848 |
if (pbs & TRACK_BIT_DIAG2) DrawGroundSprite(0x3EE | PALETTE_CRASH); |
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
|
849 |
if (pbs & TRACK_BIT_UPPER) DrawGroundSprite(0x3EF | PALETTE_CRASH); |
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
|
850 |
if (pbs & TRACK_BIT_LOWER) DrawGroundSprite(0x3F0 | PALETTE_CRASH); |
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
|
851 |
if (pbs & TRACK_BIT_LEFT) DrawGroundSprite(0x3F2 | PALETTE_CRASH); |
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
|
852 |
if (pbs & TRACK_BIT_RIGHT) DrawGroundSprite(0x3F1 | PALETTE_CRASH); |
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
|
853 |
} |
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
|
854 |
|
0 | 855 |
} else { |
856 |
uint32 ormod; |
|
857 |
int player; |
|
858 |
const DrawRoadSeqStruct *drss; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
859 |
|
0 | 860 |
if (ti->tileh != 0) { DrawFoundation(ti, ti->tileh); } |
861 |
||
862 |
ormod = 0x315; |
|
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
|
863 |
player = GetTileOwner(ti->tile); |
0 | 864 |
if (player < MAX_PLAYERS) |
865 |
ormod = PLAYER_SPRITE_COLOR(player); |
|
866 |
||
1398 | 867 |
drss = _road_display_datas[ti->map5 & 0xF]; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
868 |
|
1398 | 869 |
DrawGroundSprite(drss++->image); |
0 | 870 |
|
1398 | 871 |
for (; drss->image != 0; drss++) { |
872 |
uint32 image = drss->image; |
|
873 |
||
0 | 874 |
if (image & 0x8000) |
875 |
image |= ormod; |
|
497
2d6d31173813
(svn r787) Invert the sense of the DO_TRANS_BUILDINGS flag to be consistent with its own name and all other DO_* flags.
tron
parents:
473
diff
changeset
|
876 |
if (_display_opt & DO_TRANS_BUILDINGS) // show transparent depots |
204
1646d7049950
(svn r205) -Fix: [1026271] Vehicle depots not transparent with transparent buildings.
darkvater
parents:
201
diff
changeset
|
877 |
image = (image & 0x3FFF) | 0x3224000; |
0 | 878 |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
879 |
AddSortableSpriteToDraw(image, ti->x | drss->subcoord_x, |
0 | 880 |
ti->y | drss->subcoord_y, drss->width, drss->height, 0x14, ti->z); |
881 |
} |
|
882 |
} |
|
883 |
} |
|
884 |
||
885 |
void DrawRoadDepotSprite(int x, int y, int image) |
|
886 |
{ |
|
887 |
uint32 ormod; |
|
888 |
const DrawRoadSeqStruct *dtss; |
|
889 |
||
890 |
ormod = PLAYER_SPRITE_COLOR(_local_player); |
|
891 |
||
1398 | 892 |
dtss = _road_display_datas[image]; |
0 | 893 |
|
894 |
x+=33; |
|
895 |
y+=17; |
|
896 |
||
1398 | 897 |
DrawSprite(dtss++->image, x, y); |
0 | 898 |
|
1398 | 899 |
for(; dtss->image != 0; dtss++) { |
0 | 900 |
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
|
901 |
|
0 | 902 |
image = dtss->image; |
903 |
if (image & 0x8000) |
|
904 |
image |= ormod; |
|
905 |
||
906 |
DrawSprite(image, x + pt.x, y + pt.y); |
|
907 |
} |
|
908 |
} |
|
909 |
||
410 | 910 |
static uint GetSlopeZ_Road(TileInfo *ti) |
0 | 911 |
{ |
912 |
uint z = ti->z; |
|
913 |
int th = ti->tileh; |
|
914 |
||
915 |
// check if it's a foundation |
|
916 |
if (ti->tileh != 0) { |
|
13
3e7c1f74a996
(svn r14) Fix: railroad crossings on slopes are now possible
dominik
parents:
0
diff
changeset
|
917 |
if ((ti->map5 & 0xE0) == 0) { /* road or crossing */ |
0 | 918 |
uint f = GetRoadFoundation(ti->tileh, ti->map5 & 0x3F); |
919 |
if (f != 0) { |
|
920 |
if (f < 15) { |
|
921 |
// leveled foundation |
|
922 |
return z + 8; |
|
923 |
} |
|
924 |
// inclined foundation |
|
925 |
th = _inclined_tileh[f - 15]; |
|
926 |
} |
|
927 |
} else if ((ti->map5 & 0xF0) == 0x20) { |
|
928 |
// depot |
|
929 |
return z + 8; |
|
930 |
} |
|
931 |
return GetPartialZ(ti->x&0xF, ti->y&0xF, th) + z; |
|
932 |
} |
|
39 | 933 |
return z; // normal Z if no slope |
934 |
} |
|
935 |
||
1095 | 936 |
static uint GetSlopeTileh_Road(TileInfo *ti) |
39 | 937 |
{ |
938 |
// check if it's a foundation |
|
939 |
if (ti->tileh != 0) { |
|
940 |
if ((ti->map5 & 0xE0) == 0) { /* road or crossing */ |
|
941 |
uint f = GetRoadFoundation(ti->tileh, ti->map5 & 0x3F); |
|
942 |
if (f != 0) { |
|
943 |
if (f < 15) { |
|
944 |
// leveled foundation |
|
945 |
return 0; |
|
946 |
} |
|
947 |
// inclined foundation |
|
948 |
return _inclined_tileh[f - 15]; |
|
949 |
} |
|
950 |
} else if ((ti->map5 & 0xF0) == 0x20) { |
|
951 |
// depot |
|
952 |
return 0; |
|
953 |
} |
|
954 |
} |
|
955 |
return ti->tileh; |
|
0 | 956 |
} |
957 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1942
diff
changeset
|
958 |
static void GetAcceptedCargo_Road(TileIndex tile, AcceptedCargo ac) |
0 | 959 |
{ |
960 |
/* not used */ |
|
961 |
} |
|
962 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1942
diff
changeset
|
963 |
static void AnimateTile_Road(TileIndex tile) |
0 | 964 |
{ |
1927
4126e0e3e884
(svn r2433) - CodeChange: unmagicify all road/train crossings with IsLevelCrossing() function (peter1138)
Darkvater
parents:
1902
diff
changeset
|
965 |
if (IsLevelCrossing(tile)) { |
0 | 966 |
MarkTileDirtyByTile(tile); |
967 |
} |
|
968 |
} |
|
969 |
||
970 |
static const byte _town_road_types[5][2] = { |
|
971 |
{1,1}, |
|
972 |
{2,2}, |
|
973 |
{2,2}, |
|
974 |
{5,5}, |
|
975 |
{3,2}, |
|
976 |
}; |
|
977 |
||
978 |
static const byte _town_road_types_2[5][2] = { |
|
979 |
{1,1}, |
|
980 |
{2,2}, |
|
981 |
{3,2}, |
|
982 |
{3,2}, |
|
983 |
{3,2}, |
|
984 |
}; |
|
985 |
||
986 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1942
diff
changeset
|
987 |
static void TileLoop_Road(TileIndex tile) |
0 | 988 |
{ |
989 |
Town *t; |
|
990 |
int grp; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
991 |
|
0 | 992 |
if (_opt.landscape == LT_HILLY) { |
993 |
// Fix snow style if the road is above the snowline |
|
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
994 |
if ((_m[tile].m4 & 0x80) != ((GetTileZ(tile) > _opt.snow_line) ? 0x80 : 0x00)) { |
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
995 |
_m[tile].m4 ^= 0x80; |
0 | 996 |
MarkTileDirtyByTile(tile); |
997 |
} |
|
998 |
} else if (_opt.landscape == LT_DESERT) { |
|
999 |
// Fix desert style |
|
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1000 |
if (GetMapExtraBits(tile) == 1 && !(_m[tile].m4 & 0x80)) { |
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1001 |
_m[tile].m4 |= 0x80; |
0 | 1002 |
MarkTileDirtyByTile(tile); |
1003 |
} |
|
1004 |
} |
|
1005 |
||
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1006 |
if (_m[tile].m5 & 0xE0) |
0 | 1007 |
return; |
1008 |
||
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1009 |
if (((_m[tile].m4 & 0x70) >> 4) < 6) { |
1281
1573d0e4e7a1
(svn r1785) -Fix: space-correctness in road_cmd.c, and one wrong line from last
truelight
parents:
1280
diff
changeset
|
1010 |
t = ClosestTownFromTile(tile, (uint)-1); |
1280
b6925875de49
(svn r1784) -Fix: removed ClosestTownFromTile where possible, or replaced it
truelight
parents:
1264
diff
changeset
|
1011 |
|
0 | 1012 |
grp = 0; |
1013 |
if (t != NULL) { |
|
1014 |
grp = GetTownRadiusGroup(t, tile); |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1015 |
|
0 | 1016 |
// 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
|
1017 |
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
|
1018 |
!(DistanceManhattan(t->xy, tile) >= 8 && grp == 0) && |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1019 |
(_m[tile].m5==5 || _m[tile].m5==10)) { |
0 | 1020 |
if (GetTileSlope(tile, NULL) == 0 && EnsureNoVehicle(tile) && CHANCE16(1,20)) { |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1021 |
_m[tile].m4 |= ((((_m[tile].m4 & 0x70) >> 4 ) <= 2) ? 7 : 6) << 4; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1022 |
|
541 | 1023 |
SndPlayTileFx(SND_21_JACKHAMMER, tile); |
0 | 1024 |
CreateEffectVehicleAbove( |
926
bd4312619522
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents:
889
diff
changeset
|
1025 |
TileX(tile) * 16 + 7, |
bd4312619522
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents:
889
diff
changeset
|
1026 |
TileY(tile) * 16 + 7, |
0 | 1027 |
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
|
1028 |
EV_BULLDOZER); |
0 | 1029 |
MarkTileDirtyByTile(tile); |
1030 |
return; |
|
1031 |
} |
|
1032 |
} |
|
1033 |
} |
|
1034 |
||
1035 |
{ |
|
1036 |
const byte *p = (_opt.landscape == LT_CANDY) ? _town_road_types_2[grp] : _town_road_types[grp]; |
|
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1037 |
byte b = (_m[tile].m4 & 0x70) >> 4; |
0 | 1038 |
|
1039 |
if (b == p[0]) |
|
1040 |
return; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1041 |
|
0 | 1042 |
if (b == p[1]) { |
1043 |
b = p[0]; |
|
1044 |
} else if (b == 0) { |
|
1045 |
b = p[1]; |
|
1046 |
} else { |
|
1047 |
b = 0; |
|
1048 |
} |
|
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1049 |
_m[tile].m4 = (_m[tile].m4 & ~0x70) | (b << 4); |
0 | 1050 |
MarkTileDirtyByTile(tile); |
1051 |
} |
|
1052 |
} else { |
|
1053 |
// Handle road work |
|
1264
280792016b02
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1247
diff
changeset
|
1054 |
//XXX undocumented |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1055 |
|
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1056 |
byte b = _m[tile].m4; |
1264
280792016b02
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1247
diff
changeset
|
1057 |
//roadworks take place only |
280792016b02
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1247
diff
changeset
|
1058 |
//keep roadworks running for 16 loops |
280792016b02
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1247
diff
changeset
|
1059 |
//lower 4 bits of map3_hi store the counter now |
280792016b02
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1247
diff
changeset
|
1060 |
if ((b & 0xF) != 0xF) { |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1061 |
_m[tile].m4 = b + 1; |
0 | 1062 |
return; |
1063 |
} |
|
1264
280792016b02
(svn r1768) -Codechange: Store town index in _map2 of town tiles
celestar
parents:
1247
diff
changeset
|
1064 |
//roadworks finished |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1065 |
_m[tile].m4 = ((((b& 0x70) >> 4)== 6) ? 1 : 2) << 4; |
0 | 1066 |
MarkTileDirtyByTile(tile); |
1067 |
} |
|
1068 |
} |
|
1069 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1942
diff
changeset
|
1070 |
void ShowRoadDepotWindow(TileIndex tile); |
0 | 1071 |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1942
diff
changeset
|
1072 |
static void ClickTile_Road(TileIndex tile) |
0 | 1073 |
{ |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1074 |
if ((_m[tile].m5 & 0xF0) == 0x20) { |
0 | 1075 |
ShowRoadDepotWindow(tile); |
1076 |
} |
|
1077 |
} |
|
1078 |
||
1079 |
static const byte _road_trackbits[16] = { |
|
1080 |
0x0, 0x0, 0x0, 0x10, 0x0, 0x2, 0x8, 0x1A, 0x0, 0x4, 0x1, 0x15, 0x20, 0x26, 0x29, 0x3F, |
|
1081 |
}; |
|
1082 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1942
diff
changeset
|
1083 |
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
|
1084 |
{ |
159
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
149
diff
changeset
|
1085 |
if (mode == TRANSPORT_RAIL) { |
1927
4126e0e3e884
(svn r2433) - CodeChange: unmagicify all road/train crossings with IsLevelCrossing() function (peter1138)
Darkvater
parents:
1902
diff
changeset
|
1086 |
if (!IsLevelCrossing(tile)) |
0 | 1087 |
return 0; |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1088 |
return _m[tile].m5 & 8 ? 0x101 : 0x202; |
159
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
149
diff
changeset
|
1089 |
} else if (mode == TRANSPORT_ROAD) { |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1090 |
byte b = _m[tile].m5; |
0 | 1091 |
if ((b & 0xF0) == 0) { |
159
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
149
diff
changeset
|
1092 |
/* Ordinary road */ |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1093 |
if (!_road_special_gettrackstatus && ((_m[tile].m4&0x70) >> 4) >= 6) |
0 | 1094 |
return 0; |
1095 |
return _road_trackbits[b&0xF] * 0x101; |
|
1927
4126e0e3e884
(svn r2433) - CodeChange: unmagicify all road/train crossings with IsLevelCrossing() function (peter1138)
Darkvater
parents:
1902
diff
changeset
|
1096 |
} else if (IsLevelCrossing(tile)) { |
159
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
149
diff
changeset
|
1097 |
/* Crossing */ |
0 | 1098 |
uint32 r = 0x101; |
1099 |
if (b&8) r <<= 1; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1100 |
|
0 | 1101 |
if (b&4) { |
1102 |
r *= 0x10001; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1103 |
} |
0 | 1104 |
return r; |
1105 |
} |
|
1106 |
} |
|
1107 |
return 0; |
|
1108 |
} |
|
1109 |
||
1110 |
static const StringID _road_tile_strings[] = { |
|
1111 |
STR_1818_ROAD_RAIL_LEVEL_CROSSING, |
|
1112 |
STR_1817_ROAD_VEHICLE_DEPOT, |
|
1113 |
||
1114 |
STR_1814_ROAD, |
|
1115 |
STR_1814_ROAD, |
|
1116 |
STR_1814_ROAD, |
|
1117 |
STR_1815_ROAD_WITH_STREETLIGHTS, |
|
1118 |
STR_1814_ROAD, |
|
1119 |
STR_1816_TREE_LINED_ROAD, |
|
1120 |
STR_1814_ROAD, |
|
1121 |
STR_1814_ROAD, |
|
1122 |
}; |
|
1123 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1942
diff
changeset
|
1124 |
static void GetTileDesc_Road(TileIndex tile, TileDesc *td) |
0 | 1125 |
{ |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1126 |
int i = (_m[tile].m5 >> 4); |
0 | 1127 |
if (i == 0) |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1128 |
i = ((_m[tile].m4 & 0x70) >> 4) + 3; |
0 | 1129 |
td->str = _road_tile_strings[i - 1]; |
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
|
1130 |
td->owner = GetTileOwner(tile); |
0 | 1131 |
} |
1132 |
||
1133 |
static const byte _roadveh_enter_depot_unk0[4] = { |
|
1134 |
8, 9, 0, 1 |
|
1135 |
}; |
|
1136 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1942
diff
changeset
|
1137 |
static uint32 VehicleEnter_Road(Vehicle *v, TileIndex tile, int x, int y) |
0 | 1138 |
{ |
1927
4126e0e3e884
(svn r2433) - CodeChange: unmagicify all road/train crossings with IsLevelCrossing() function (peter1138)
Darkvater
parents:
1902
diff
changeset
|
1139 |
if (IsLevelCrossing(tile)) { |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1140 |
if (v->type == VEH_Train && (_m[tile].m5 & 4) == 0) { |
0 | 1141 |
/* train crossing a road */ |
541 | 1142 |
SndPlayVehicleFx(SND_0E_LEVEL_CROSSING, v); |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1143 |
_m[tile].m5 |= 4; |
0 | 1144 |
MarkTileDirtyByTile(tile); |
1145 |
} |
|
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1146 |
} else if ((_m[tile].m5&0xF0) == 0x20){ |
0 | 1147 |
if (v->type == VEH_Road && v->u.road.frame == 11) { |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1148 |
if (_roadveh_enter_depot_unk0[_m[tile].m5&3] == v->u.road.state) { |
0 | 1149 |
RoadVehEnterDepot(v); |
1150 |
return 4; |
|
1151 |
} |
|
1152 |
} |
|
1153 |
} |
|
1154 |
return 0; |
|
1155 |
} |
|
1156 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1942
diff
changeset
|
1157 |
static void VehicleLeave_Road(Vehicle *v, TileIndex tile, int x, int y) |
0 | 1158 |
{ |
1927
4126e0e3e884
(svn r2433) - CodeChange: unmagicify all road/train crossings with IsLevelCrossing() function (peter1138)
Darkvater
parents:
1902
diff
changeset
|
1159 |
if (IsLevelCrossing(tile) && v->type == VEH_Train && v->next == NULL) { |
4126e0e3e884
(svn r2433) - CodeChange: unmagicify all road/train crossings with IsLevelCrossing() function (peter1138)
Darkvater
parents:
1902
diff
changeset
|
1160 |
// Turn off level crossing lights |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1161 |
_m[tile].m5 &= ~4; |
0 | 1162 |
MarkTileDirtyByTile(tile); |
1163 |
} |
|
1164 |
} |
|
1165 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1942
diff
changeset
|
1166 |
static void ChangeTileOwner_Road(TileIndex tile, byte old_player, byte new_player) |
0 | 1167 |
{ |
1168 |
byte b; |
|
1169 |
||
1170 |
// road/rail crossing where the road is owned by the current player? |
|
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1171 |
if (old_player == _m[tile].m3 && IsLevelCrossing(tile)) { |
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1172 |
_m[tile].m3 = (new_player == 0xFF) ? OWNER_NONE : new_player; |
0 | 1173 |
} |
1174 |
||
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
|
1175 |
if (!IsTileOwner(tile, old_player)) return; |
0 | 1176 |
|
1177 |
if (new_player != 255) { |
|
1902 | 1178 |
SetTileOwner(tile, new_player); |
0 | 1179 |
} else { |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1180 |
b = _m[tile].m5&0xF0; |
0 | 1181 |
if (b == 0) { |
1902 | 1182 |
SetTileOwner(tile, OWNER_NONE); |
1927
4126e0e3e884
(svn r2433) - CodeChange: unmagicify all road/train crossings with IsLevelCrossing() function (peter1138)
Darkvater
parents:
1902
diff
changeset
|
1183 |
} else if (IsLevelCrossing(tile)) { |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1184 |
_m[tile].m5 = (_m[tile].m5&8) ? 0x5 : 0xA; |
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1185 |
SetTileOwner(tile, _m[tile].m3); |
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1186 |
_m[tile].m3 = 0; |
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2008
diff
changeset
|
1187 |
_m[tile].m4 &= 0x80; |
0 | 1188 |
} else { |
1189 |
DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); |
|
1190 |
} |
|
1191 |
} |
|
1192 |
} |
|
1193 |
||
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
|
1194 |
void InitializeRoad(void) |
0 | 1195 |
{ |
1196 |
_last_built_road_depot_tile = 0; |
|
1197 |
} |
|
1198 |
||
1199 |
const TileTypeProcs _tile_type_road_procs = { |
|
1200 |
DrawTile_Road, /* draw_tile_proc */ |
|
1201 |
GetSlopeZ_Road, /* get_slope_z_proc */ |
|
1202 |
ClearTile_Road, /* clear_tile_proc */ |
|
1203 |
GetAcceptedCargo_Road, /* get_accepted_cargo_proc */ |
|
1204 |
GetTileDesc_Road, /* get_tile_desc_proc */ |
|
1205 |
GetTileTrackStatus_Road, /* get_tile_track_status_proc */ |
|
1206 |
ClickTile_Road, /* click_tile_proc */ |
|
1207 |
AnimateTile_Road, /* animate_tile_proc */ |
|
1208 |
TileLoop_Road, /* tile_loop_clear */ |
|
1209 |
ChangeTileOwner_Road, /* change_tile_owner_clear */ |
|
1210 |
NULL, /* get_produced_cargo_proc */ |
|
1211 |
VehicleEnter_Road, /* vehicle_enter_tile_proc */ |
|
1212 |
VehicleLeave_Road, /* vehicle_leave_tile_proc */ |
|
39 | 1213 |
GetSlopeTileh_Road, /* get_slope_tileh_proc */ |
0 | 1214 |
}; |