|
1 /* $Id$ */ |
|
2 /** @file elrail.c |
|
3 * This file deals with displaying wires and pylons for electric railways. |
|
4 * <h2>Basics</h2> |
|
5 * |
|
6 * <h3>Tile Types</h3> |
|
7 * |
|
8 * We have two different types of tiles in the drawing code: |
|
9 * Normal Railway Tiles (NRTs) which can have more than one track on it, and |
|
10 * Special Railways tiles (SRTs) which have only one track (like crossings, depots |
|
11 * stations, etc). |
|
12 * |
|
13 * <h3>Location Categories</h3> |
|
14 * |
|
15 * All tiles are categorized into three location groups (TLG): |
|
16 * Group 0: Tiles with both an even X coordinate and an even Y coordinate |
|
17 * Group 1: Tiles with an even X and an odd Y coordinate |
|
18 * Group 2: Tiles with an odd X and an even Y coordinate |
|
19 * Group 3: Tiles with both an odd X and Y coordnate. |
|
20 * |
|
21 * <h3>Pylon Points</h3> |
|
22 * <h4>Control Points</h4> |
|
23 * A Pylon Control Point (PCP) is a position where a wire (or rather two) |
|
24 * is mounted onto a pylon. |
|
25 * Each NRT does contain 4 PCPs which are bitmapped to a byte |
|
26 * variable and are represented by the DiagDirection enum |
|
27 * |
|
28 * Each track ends on two PCPs and thus requires one pylon on each end. However, |
|
29 * there is one exception: Straight-and-level tracks only have one pylon every |
|
30 * other tile. |
|
31 * |
|
32 * Now on each edge there are two PCPs: One from each adjacent tile. Both PCPs |
|
33 * are merged using an OR operation (i. e. if one tile needs a PCP at the postion |
|
34 * in question, both tiles get it). |
|
35 * |
|
36 * <h4>Position Points</h4> |
|
37 * A Pylon Position Point (PPP) is a position where a pylon is located on the |
|
38 * ground. Each PCP owns 8 in (45 degree steps) PPPs that are located around |
|
39 * it. PPPs are represented using the Direction enum. Each track bit has PPPs |
|
40 * that are impossible (because the pylon would be situated on the track) and |
|
41 * some that are preferred (because the pylon would be rectangular to the track). |
|
42 * |
|
43 * <img src="../../elrail_tile.png"> |
|
44 * <img src="../../elrail_track.png"> |
|
45 * |
|
46 */ |
|
47 |
|
48 #include "stdafx.h" |
|
49 #include "openttd.h" |
|
50 #include "station_map.h" |
|
51 #include "tile.h" |
|
52 #include "viewport.h" |
|
53 #include "functions.h" /* We should REALLY get rid of this goddamn file, as it is butt-ugly */ |
|
54 #include "variables.h" /* ... same here */ |
|
55 #include "rail.h" |
|
56 #include "debug.h" |
|
57 #include "tunnel_map.h" |
|
58 #include "road_map.h" |
|
59 #include "bridge_map.h" |
|
60 #include "bridge.h" |
|
61 #include "rail_map.h" |
|
62 #include "table/sprites.h" |
|
63 #include "table/elrail_data.h" |
|
64 #include "vehicle.h" |
|
65 #include "train.h" |
|
66 #include "gui.h" |
|
67 |
|
68 static inline TLG GetTLG(TileIndex t) |
|
69 { |
|
70 return (HASBIT(TileX(t), 0) << 1) + HASBIT(TileY(t), 0); |
|
71 } |
|
72 |
|
73 /** Finds which Rail Bits are present on a given tile. For bridge tiles, |
|
74 * returns track bits under the bridge |
|
75 */ |
|
76 static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override) |
|
77 { |
|
78 switch (GetTileType(t)) { |
|
79 case MP_RAILWAY: |
|
80 if (GetRailType(t) != RAILTYPE_ELECTRIC) return 0; |
|
81 switch (GetRailTileType(t)) { |
|
82 case RAIL_TILE_NORMAL: case RAIL_TILE_SIGNALS: |
|
83 return GetTrackBits(t); |
|
84 case RAIL_TILE_DEPOT_WAYPOINT: |
|
85 if (GetRailTileSubtype(t) == RAIL_SUBTYPE_WAYPOINT) return GetRailWaypointBits(t); |
|
86 default: |
|
87 return 0; |
|
88 } |
|
89 break; |
|
90 |
|
91 case MP_TUNNELBRIDGE: |
|
92 if (IsTunnel(t)) { |
|
93 if (GetRailType(t) != RAILTYPE_ELECTRIC) return 0; |
|
94 if (override != NULL) *override = 1 << GetTunnelDirection(t); |
|
95 return AxisToTrackBits(DiagDirToAxis(GetTunnelDirection(t))); |
|
96 } else { |
|
97 if (GetRailType(t) != RAILTYPE_ELECTRIC) return 0; |
|
98 if (override != NULL && DistanceMax(t, GetOtherBridgeEnd(t)) > 1) { |
|
99 *override = 1 << GetBridgeRampDirection(t); |
|
100 } |
|
101 return AxisToTrackBits(DiagDirToAxis(GetBridgeRampDirection(t))); |
|
102 } |
|
103 |
|
104 case MP_STREET: |
|
105 if (GetRoadTileType(t) != ROAD_TILE_CROSSING) return 0; |
|
106 if (GetRailTypeCrossing(t) != RAILTYPE_ELECTRIC) return 0; |
|
107 return GetCrossingRailBits(t); |
|
108 |
|
109 case MP_STATION: |
|
110 if (!IsRailwayStation(t)) return 0; |
|
111 if (GetRailType(t) != RAILTYPE_ELECTRIC) return 0; |
|
112 if (!IsStationTileElectrifiable(t)) return 0; |
|
113 return TrackToTrackBits(GetRailStationTrack(t)); |
|
114 |
|
115 default: |
|
116 return 0; |
|
117 } |
|
118 } |
|
119 |
|
120 /** Corrects the tileh for certain tile types. Returns an effective tileh for the track on the tile. |
|
121 * @param tile The tile to analyse |
|
122 * @param *tileh the tileh |
|
123 */ |
|
124 static void AdjustTileh(TileIndex tile, Slope *tileh) |
|
125 { |
|
126 if (IsTileType(tile, MP_TUNNELBRIDGE)) { |
|
127 if (IsTunnel(tile)) { |
|
128 *tileh = SLOPE_FLAT; |
|
129 } else { |
|
130 if (*tileh != SLOPE_FLAT) { |
|
131 *tileh = SLOPE_FLAT; |
|
132 } else { |
|
133 switch (GetBridgeRampDirection(tile)) { |
|
134 case DIAGDIR_NE: *tileh = SLOPE_NE; break; |
|
135 case DIAGDIR_SE: *tileh = SLOPE_SE; break; |
|
136 case DIAGDIR_SW: *tileh = SLOPE_SW; break; |
|
137 case DIAGDIR_NW: *tileh = SLOPE_NW; break; |
|
138 default: NOT_REACHED(); |
|
139 } |
|
140 } |
|
141 } |
|
142 } |
|
143 } |
|
144 |
|
145 /** Draws wires and, if required, pylons on a given tile |
|
146 * @param ti The Tileinfo to draw the tile for |
|
147 */ |
|
148 static void DrawCatenaryRailway(const TileInfo *ti) |
|
149 { |
|
150 /* Pylons are placed on a tile edge, so we need to take into account |
|
151 * the track configuration of 2 adjacent tiles. trackconfig[0] stores the |
|
152 * current tile (home tile) while [1] holds the neighbour */ |
|
153 TrackBits trackconfig[TS_END]; |
|
154 bool isflat[TS_END]; |
|
155 /* Note that ti->tileh has already been adjusted for Foundations */ |
|
156 Slope tileh[TS_END] = { ti->tileh, SLOPE_FLAT }; |
|
157 |
|
158 TLG tlg = GetTLG(ti->tile); |
|
159 byte PCPstatus = 0; |
|
160 byte OverridePCP = 0; |
|
161 byte PPPpreferred[DIAGDIR_END]; |
|
162 byte PPPallowed[DIAGDIR_END]; |
|
163 DiagDirection i; |
|
164 Track t; |
|
165 |
|
166 /* Find which rail bits are present, and select the override points. |
|
167 * We don't draw a pylon: |
|
168 * 1) INSIDE a tunnel (we wouldn't see it anyway) |
|
169 * 2) on the "far" end of a bridge head (the one that connects to bridge middle), |
|
170 * because that one is drawn on the bridge. Exception is for length 0 bridges |
|
171 * which have no middle tiles */ |
|
172 trackconfig[TS_HOME] = GetRailTrackBitsUniversal(ti->tile, &OverridePCP); |
|
173 /* If a track bit is present that is not in the main direction, the track is level */ |
|
174 isflat[TS_HOME] = trackconfig[TS_HOME] & (TRACK_BIT_HORZ | TRACK_BIT_VERT); |
|
175 |
|
176 AdjustTileh(ti->tile, &tileh[TS_HOME]); |
|
177 |
|
178 for (i = DIAGDIR_NE; i < DIAGDIR_END; i++) { |
|
179 TileIndex neighbour = ti->tile + TileOffsByDiagDir(i); |
|
180 uint foundation = 0; |
|
181 int k; |
|
182 |
|
183 /* Here's one of the main headaches. GetTileSlope does not correct for possibly |
|
184 * existing foundataions, so we do have to do that manually later on.*/ |
|
185 tileh[TS_NEIGHBOUR] = GetTileSlope(neighbour, NULL); |
|
186 trackconfig[TS_NEIGHBOUR] = GetRailTrackBitsUniversal(neighbour, NULL); |
|
187 if (IsTunnelTile(neighbour) && i != GetTunnelDirection(neighbour)) trackconfig[TS_NEIGHBOUR] = 0; |
|
188 isflat[TS_NEIGHBOUR] = trackconfig[TS_NEIGHBOUR] & (TRACK_BIT_HORZ | TRACK_BIT_VERT); |
|
189 |
|
190 PPPpreferred[i] = 0xFF; /* We start with preferring everything (end-of-line in any direction) */ |
|
191 PPPallowed[i] = AllowedPPPonPCP[i]; |
|
192 |
|
193 /* We cycle through all the existing tracks at a PCP and see what |
|
194 * PPPs we want to have, or may not have at all */ |
|
195 for (k = 0; k < NUM_TRACKS_AT_PCP; k++) { |
|
196 /* Next to us, we have a bridge head, don't worry about that one, if it shows away from us */ |
|
197 if (TrackSourceTile[i][k] == TS_NEIGHBOUR && |
|
198 IsBridgeTile(neighbour) && |
|
199 GetBridgeRampDirection(neighbour) == ReverseDiagDir(i)) { |
|
200 continue; |
|
201 } |
|
202 |
|
203 /* We check whether the track in question (k) is present in the tile |
|
204 * (TrackSourceTile) */ |
|
205 if (HASBIT(trackconfig[TrackSourceTile[i][k]], TracksAtPCP[i][k])) { |
|
206 /* track found, if track is in the neighbour tile, adjust the number |
|
207 * of the PCP for preferred/allowed determination*/ |
|
208 DiagDirection PCPpos = (TrackSourceTile[i][k] == TS_HOME) ? i : ReverseDiagDir(i); |
|
209 SETBIT(PCPstatus, i); /* This PCP is in use */ |
|
210 |
|
211 PPPpreferred[i] &= PreferredPPPofTrackAtPCP[TracksAtPCP[i][k]][PCPpos]; |
|
212 PPPallowed[i] &= ~DisallowedPPPofTrackAtPCP[TracksAtPCP[i][k]][PCPpos]; |
|
213 } |
|
214 } |
|
215 |
|
216 /* Deactivate all PPPs if PCP is not used */ |
|
217 PPPpreferred[i] *= HASBIT(PCPstatus, i); |
|
218 PPPallowed[i] *= HASBIT(PCPstatus, i); |
|
219 |
|
220 /* A station is always "flat", so adjust the tileh accordingly */ |
|
221 if (IsTileType(neighbour, MP_STATION)) tileh[TS_NEIGHBOUR] = SLOPE_FLAT; |
|
222 |
|
223 /* Read the foundataions if they are present, and adjust the tileh */ |
|
224 if (IsTileType(neighbour, MP_RAILWAY) && GetRailType(neighbour) == RAILTYPE_ELECTRIC) foundation = GetRailFoundation(tileh[TS_NEIGHBOUR], trackconfig[TS_NEIGHBOUR]); |
|
225 if (IsBridgeTile(neighbour)) { |
|
226 foundation = GetBridgeFoundation(tileh[TS_NEIGHBOUR], DiagDirToAxis(GetBridgeRampDirection(neighbour))); |
|
227 } |
|
228 |
|
229 if (foundation != 0) { |
|
230 if (foundation < 15) { |
|
231 tileh[TS_NEIGHBOUR] = SLOPE_FLAT; |
|
232 } else { |
|
233 tileh[TS_NEIGHBOUR] = _inclined_tileh[foundation - 15]; |
|
234 } |
|
235 } |
|
236 |
|
237 AdjustTileh(neighbour, &tileh[TS_NEIGHBOUR]); |
|
238 |
|
239 /* If we have a straight (and level) track, we want a pylon only every 2 tiles |
|
240 * Delete the PCP if this is the case. */ |
|
241 /* Level means that the slope is the same, or the track is flat */ |
|
242 if (tileh[TS_HOME] == tileh[TS_NEIGHBOUR] || (isflat[TS_HOME] && isflat[TS_NEIGHBOUR])) { |
|
243 for (k = 0; k < NUM_IGNORE_GROUPS; k++) |
|
244 if (PPPpreferred[i] == IgnoredPCP[k][tlg][i]) CLRBIT(PCPstatus, i); |
|
245 } |
|
246 |
|
247 /* Now decide where we draw our pylons. First try the preferred PPPs, but they may not exist. |
|
248 * In that case, we try the any of the allowed ones. if they don't exist either, don't draw |
|
249 * anything. Note that the preferred PPPs still contain the end-of-line markers. |
|
250 * Remove those (simply by ANDing with allowed, since these markers are never allowed) */ |
|
251 if ((PPPallowed[i] & PPPpreferred[i]) != 0) PPPallowed[i] &= PPPpreferred[i]; |
|
252 |
|
253 if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile)) { |
|
254 Track bridgetrack = GetBridgeAxis(ti->tile) == AXIS_X ? TRACK_X : TRACK_Y; |
|
255 uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile)); |
|
256 |
|
257 if ((height <= TilePixelHeight(ti->tile) + TILE_HEIGHT) && |
|
258 (i == PCPpositions[bridgetrack][0] || i == PCPpositions[bridgetrack][1])) SETBIT(OverridePCP, i); |
|
259 } |
|
260 |
|
261 if (PPPallowed[i] != 0 && HASBIT(PCPstatus, i) && !HASBIT(OverridePCP, i)) { |
|
262 for (k = 0; k < DIR_END; k++) { |
|
263 byte temp = PPPorder[i][GetTLG(ti->tile)][k]; |
|
264 |
|
265 if (HASBIT(PPPallowed[i], temp)) { |
|
266 uint x = ti->x + x_pcp_offsets[i] + x_ppp_offsets[temp]; |
|
267 uint y = ti->y + y_pcp_offsets[i] + y_ppp_offsets[temp]; |
|
268 |
|
269 /* Don't build the pylon if it would be outside the tile */ |
|
270 if (!HASBIT(OwnedPPPonPCP[i], temp)) { |
|
271 /* We have a neighour that will draw it, bail out */ |
|
272 if (trackconfig[TS_NEIGHBOUR] != 0) break; |
|
273 continue; /* No neighbour, go looking for a better position */ |
|
274 } |
|
275 |
|
276 AddSortableSpriteToDraw(pylons_normal[temp], x, y, 1, 1, 10, |
|
277 GetSlopeZ(ti->x + x_pcp_offsets[i], ti->y + y_pcp_offsets[i])); |
|
278 break; /* We already have drawn a pylon, bail out */ |
|
279 } |
|
280 } |
|
281 } |
|
282 } |
|
283 |
|
284 /* Don't draw a wire under a low bridge */ |
|
285 if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !(_display_opt & DO_TRANS_BUILDINGS)) { |
|
286 uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile)); |
|
287 |
|
288 if (height <= TilePixelHeight(ti->tile) + TILE_HEIGHT) return; |
|
289 } |
|
290 |
|
291 /* Drawing of pylons is finished, now draw the wires */ |
|
292 for (t = 0; t < TRACK_END; t++) { |
|
293 if (HASBIT(trackconfig[TS_HOME], t)) { |
|
294 |
|
295 byte PCPconfig = HASBIT(PCPstatus, PCPpositions[t][0]) + |
|
296 (HASBIT(PCPstatus, PCPpositions[t][1]) << 1); |
|
297 |
|
298 const SortableSpriteStruct *sss; |
|
299 int tileh_selector = !(tileh[TS_HOME] % 3) * tileh[TS_HOME] / 3; /* tileh for the slopes, 0 otherwise */ |
|
300 |
|
301 assert(PCPconfig != 0); /* We have a pylon on neither end of the wire, that doesn't work (since we have no sprites for that) */ |
|
302 assert(!IsSteepSlope(tileh[TS_HOME])); |
|
303 sss = &CatenarySpriteData[Wires[tileh_selector][t][PCPconfig]]; |
|
304 |
|
305 AddSortableSpriteToDraw( sss->image, ti->x + sss->x_offset, ti->y + sss->y_offset, |
|
306 sss->x_size, sss->y_size, sss->z_size, GetSlopeZ(ti->x + min(sss->x_offset, TILE_SIZE - 1), ti->y + min(sss->y_offset, TILE_SIZE - 1)) + sss->z_offset); |
|
307 } |
|
308 } |
|
309 } |
|
310 |
|
311 static void DrawCatenaryOnBridge(const TileInfo *ti) |
|
312 { |
|
313 TileIndex end = GetSouthernBridgeEnd(ti->tile); |
|
314 TileIndex start = GetOtherBridgeEnd(end); |
|
315 |
|
316 uint length = GetBridgeLength(start, end); |
|
317 uint num = DistanceMax(ti->tile, start); |
|
318 uint height; |
|
319 |
|
320 const SortableSpriteStruct *sss; |
|
321 Axis axis = GetBridgeAxis(ti->tile); |
|
322 TLG tlg = GetTLG(ti->tile); |
|
323 |
|
324 CatenarySprite offset = axis == AXIS_X ? 0 : WIRE_Y_FLAT_BOTH - WIRE_X_FLAT_BOTH; |
|
325 |
|
326 if ((length % 2) && num == length) { |
|
327 /* Draw the "short" wire on the southern end of the bridge |
|
328 * only needed if the length of the bridge is odd */ |
|
329 sss = &CatenarySpriteData[WIRE_X_FLAT_BOTH + offset]; |
|
330 } else { |
|
331 /* Draw "long" wires on all other tiles of the bridge (one pylon every two tiles) */ |
|
332 sss = &CatenarySpriteData[WIRE_X_FLAT_SW + (num % 2) + offset]; |
|
333 } |
|
334 |
|
335 height = GetBridgeHeight(end); |
|
336 |
|
337 AddSortableSpriteToDraw( sss->image, ti->x + sss->x_offset, ti->y + sss->y_offset, |
|
338 sss->x_size, sss->y_size, sss->z_size, height + sss->z_offset |
|
339 ); |
|
340 |
|
341 /* Finished with wires, draw pylons */ |
|
342 /* every other tile needs a pylon on the northern end */ |
|
343 if (num % 2) { |
|
344 if (axis == AXIS_X) { |
|
345 AddSortableSpriteToDraw(pylons_bridge[0 + HASBIT(tlg, 0)], ti->x, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, height); |
|
346 } else { |
|
347 AddSortableSpriteToDraw(pylons_bridge[2 + HASBIT(tlg, 1)], ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y, 1, 1, 10, height); |
|
348 } |
|
349 } |
|
350 |
|
351 /* need a pylon on the southern end of the bridge */ |
|
352 if (DistanceMax(ti->tile, start) == length) { |
|
353 if (axis == AXIS_X) { |
|
354 AddSortableSpriteToDraw(pylons_bridge[0 + HASBIT(tlg, 0)], ti->x + 16, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, height); |
|
355 } else { |
|
356 AddSortableSpriteToDraw(pylons_bridge[2 + HASBIT(tlg, 1)], ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y + 16, 1, 1, 10, height); |
|
357 } |
|
358 } |
|
359 } |
|
360 |
|
361 void DrawCatenary(const TileInfo *ti) |
|
362 { |
|
363 if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile)) { |
|
364 TileIndex head = GetNorthernBridgeEnd(ti->tile); |
|
365 |
|
366 if (GetBridgeTransportType(head) == TRANSPORT_RAIL && GetRailType(head) == RAILTYPE_ELECTRIC) { |
|
367 DrawCatenaryOnBridge(ti); |
|
368 } |
|
369 } |
|
370 if (_patches.disable_elrails) return; |
|
371 |
|
372 switch (GetTileType(ti->tile)) { |
|
373 case MP_RAILWAY: |
|
374 if (IsRailDepot(ti->tile)) { |
|
375 const SortableSpriteStruct* sss = &CatenarySpriteData_Depot[GetRailDepotDirection(ti->tile)]; |
|
376 |
|
377 AddSortableSpriteToDraw( |
|
378 sss->image, ti->x + sss->x_offset, ti->y + sss->y_offset, |
|
379 sss->x_size, sss->y_size, sss->z_size, |
|
380 GetTileMaxZ(ti->tile) + sss->z_offset |
|
381 ); |
|
382 return; |
|
383 } |
|
384 break; |
|
385 |
|
386 case MP_TUNNELBRIDGE: |
|
387 case MP_STREET: |
|
388 case MP_STATION: |
|
389 break; |
|
390 |
|
391 default: return; |
|
392 } |
|
393 DrawCatenaryRailway(ti); |
|
394 } |
|
395 |
|
396 int32 SettingsDisableElrail(int32 p1) |
|
397 { |
|
398 EngineID e_id; |
|
399 Vehicle* v; |
|
400 Player *p; |
|
401 bool disable = (p1 != 0); |
|
402 |
|
403 /* we will now walk through all electric train engines and change their railtypes if it is the wrong one*/ |
|
404 const RailType old_railtype = disable ? RAILTYPE_ELECTRIC : RAILTYPE_RAIL; |
|
405 const RailType new_railtype = disable ? RAILTYPE_RAIL : RAILTYPE_ELECTRIC; |
|
406 |
|
407 /* walk through all train engines */ |
|
408 for (e_id = 0; e_id < NUM_TRAIN_ENGINES; e_id++) { |
|
409 const RailVehicleInfo *rv_info = RailVehInfo(e_id); |
|
410 Engine *e = GetEngine(e_id); |
|
411 /* if it is an electric rail engine and its railtype is the wrong one */ |
|
412 if (rv_info->engclass == 2 && e->railtype == old_railtype) { |
|
413 /* change it to the proper one */ |
|
414 e->railtype = new_railtype; |
|
415 } |
|
416 } |
|
417 |
|
418 /* when disabling elrails, make sure that all existing trains can run on |
|
419 * normal rail too */ |
|
420 if (disable) { |
|
421 FOR_ALL_VEHICLES(v) { |
|
422 if (v->type == VEH_Train && v->u.rail.railtype == RAILTYPE_ELECTRIC) { |
|
423 /* this railroad vehicle is now compatible only with elrail, |
|
424 * so add there also normal rail compatibility */ |
|
425 v->u.rail.compatible_railtypes |= (1 << RAILTYPE_RAIL); |
|
426 v->u.rail.railtype = RAILTYPE_RAIL; |
|
427 SETBIT(v->u.rail.flags, VRF_EL_ENGINE_ALLOWED_NORMAL_RAIL); |
|
428 } |
|
429 } |
|
430 } |
|
431 |
|
432 /* setup total power for trains */ |
|
433 FOR_ALL_VEHICLES(v) { |
|
434 /* power is cached only for front engines */ |
|
435 if (v->type == VEH_Train && IsFrontEngine(v)) TrainPowerChanged(v); |
|
436 } |
|
437 |
|
438 FOR_ALL_PLAYERS(p) p->avail_railtypes = GetPlayerRailtypes(p->index); |
|
439 |
|
440 /* This resets the _last_built_railtype, which will be invalid for electric |
|
441 * rails. It may have unintended consequences if that function is ever |
|
442 * extended, though. */ |
|
443 ReinitGuiAfterToggleElrail(disable); |
|
444 return 0; |
|
445 } |