equal
deleted
inserted
replaced
123 */ |
123 */ |
124 static void AdjustTileh(TileIndex tile, Slope *tileh) |
124 static void AdjustTileh(TileIndex tile, Slope *tileh) |
125 { |
125 { |
126 if (IsTileType(tile, MP_TUNNELBRIDGE)) { |
126 if (IsTileType(tile, MP_TUNNELBRIDGE)) { |
127 if (IsTunnel(tile)) { |
127 if (IsTunnel(tile)) { |
128 *tileh = SLOPE_STEEP; /* XXX - Hack to make tunnel entrances to always have a pylon */ |
128 *tileh = SLOPE_STEEP; // XXX - Hack to make tunnel entrances to always have a pylon |
|
129 } else if (*tileh != SLOPE_FLAT) { |
|
130 *tileh = SLOPE_FLAT; |
129 } else { |
131 } else { |
130 if (*tileh != SLOPE_FLAT) { |
132 switch (GetBridgeRampDirection(tile)) { |
131 *tileh = SLOPE_FLAT; |
133 case DIAGDIR_NE: *tileh = SLOPE_NE; break; |
132 } else { |
134 case DIAGDIR_SE: *tileh = SLOPE_SE; break; |
133 switch (GetBridgeRampDirection(tile)) { |
135 case DIAGDIR_SW: *tileh = SLOPE_SW; break; |
134 case DIAGDIR_NE: *tileh = SLOPE_NE; break; |
136 case DIAGDIR_NW: *tileh = SLOPE_NW; break; |
135 case DIAGDIR_SE: *tileh = SLOPE_SE; break; |
137 default: NOT_REACHED(); |
136 case DIAGDIR_SW: *tileh = SLOPE_SW; break; |
|
137 case DIAGDIR_NW: *tileh = SLOPE_NW; break; |
|
138 default: NOT_REACHED(); |
|
139 } |
|
140 } |
138 } |
141 } |
139 } |
142 } |
140 } |
143 } |
141 } |
144 |
142 |
185 tileh[TS_NEIGHBOUR] = GetTileSlope(neighbour, NULL); |
183 tileh[TS_NEIGHBOUR] = GetTileSlope(neighbour, NULL); |
186 trackconfig[TS_NEIGHBOUR] = GetRailTrackBitsUniversal(neighbour, NULL); |
184 trackconfig[TS_NEIGHBOUR] = GetRailTrackBitsUniversal(neighbour, NULL); |
187 if (IsTunnelTile(neighbour) && i != GetTunnelDirection(neighbour)) trackconfig[TS_NEIGHBOUR] = TRACK_BIT_NONE; |
185 if (IsTunnelTile(neighbour) && i != GetTunnelDirection(neighbour)) trackconfig[TS_NEIGHBOUR] = TRACK_BIT_NONE; |
188 isflat[TS_NEIGHBOUR] = ((trackconfig[TS_NEIGHBOUR] & (TRACK_BIT_HORZ | TRACK_BIT_VERT)) != 0); |
186 isflat[TS_NEIGHBOUR] = ((trackconfig[TS_NEIGHBOUR] & (TRACK_BIT_HORZ | TRACK_BIT_VERT)) != 0); |
189 |
187 |
190 PPPpreferred[i] = 0xFF; /* We start with preferring everything (end-of-line in any direction) */ |
188 PPPpreferred[i] = 0xFF; // We start with preferring everything (end-of-line in any direction) |
191 PPPallowed[i] = AllowedPPPonPCP[i]; |
189 PPPallowed[i] = AllowedPPPonPCP[i]; |
192 |
190 |
193 /* We cycle through all the existing tracks at a PCP and see what |
191 /* 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 */ |
192 * PPPs we want to have, or may not have at all */ |
195 for (k = 0; k < NUM_TRACKS_AT_PCP; k++) { |
193 for (k = 0; k < NUM_TRACKS_AT_PCP; k++) { |
204 * (TrackSourceTile) */ |
202 * (TrackSourceTile) */ |
205 if (HASBIT(trackconfig[TrackSourceTile[i][k]], TracksAtPCP[i][k])) { |
203 if (HASBIT(trackconfig[TrackSourceTile[i][k]], TracksAtPCP[i][k])) { |
206 /* track found, if track is in the neighbour tile, adjust the number |
204 /* track found, if track is in the neighbour tile, adjust the number |
207 * of the PCP for preferred/allowed determination*/ |
205 * of the PCP for preferred/allowed determination*/ |
208 DiagDirection PCPpos = (TrackSourceTile[i][k] == TS_HOME) ? i : ReverseDiagDir(i); |
206 DiagDirection PCPpos = (TrackSourceTile[i][k] == TS_HOME) ? i : ReverseDiagDir(i); |
209 SETBIT(PCPstatus, i); /* This PCP is in use */ |
207 SETBIT(PCPstatus, i); // This PCP is in use |
210 |
208 |
211 PPPpreferred[i] &= PreferredPPPofTrackAtPCP[TracksAtPCP[i][k]][PCPpos]; |
209 PPPpreferred[i] &= PreferredPPPofTrackAtPCP[TracksAtPCP[i][k]][PCPpos]; |
212 PPPallowed[i] &= ~DisallowedPPPofTrackAtPCP[TracksAtPCP[i][k]][PCPpos]; |
210 PPPallowed[i] &= ~DisallowedPPPofTrackAtPCP[TracksAtPCP[i][k]][PCPpos]; |
213 } |
211 } |
214 } |
212 } |
225 if (IsBridgeTile(neighbour)) { |
223 if (IsBridgeTile(neighbour)) { |
226 foundation = GetBridgeFoundation(tileh[TS_NEIGHBOUR], DiagDirToAxis(GetBridgeRampDirection(neighbour))); |
224 foundation = GetBridgeFoundation(tileh[TS_NEIGHBOUR], DiagDirToAxis(GetBridgeRampDirection(neighbour))); |
227 } |
225 } |
228 |
226 |
229 if (foundation != 0) { |
227 if (foundation != 0) { |
230 if (foundation < 15) { |
228 tileh[TS_NEIGHBOUR] = foundation < 15 ? SLOPE_FLAT : _inclined_tileh[foundation - 15]; |
231 tileh[TS_NEIGHBOUR] = SLOPE_FLAT; |
|
232 } else { |
|
233 tileh[TS_NEIGHBOUR] = _inclined_tileh[foundation - 15]; |
|
234 } |
|
235 } |
229 } |
236 |
230 |
237 AdjustTileh(neighbour, &tileh[TS_NEIGHBOUR]); |
231 AdjustTileh(neighbour, &tileh[TS_NEIGHBOUR]); |
238 |
232 |
239 /* If we have a straight (and level) track, we want a pylon only every 2 tiles |
233 /* If we have a straight (and level) track, we want a pylon only every 2 tiles |
253 if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile)) { |
247 if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile)) { |
254 Track bridgetrack = GetBridgeAxis(ti->tile) == AXIS_X ? TRACK_X : TRACK_Y; |
248 Track bridgetrack = GetBridgeAxis(ti->tile) == AXIS_X ? TRACK_X : TRACK_Y; |
255 uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile)); |
249 uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile)); |
256 |
250 |
257 if ((height <= TilePixelHeight(ti->tile) + TILE_HEIGHT) && |
251 if ((height <= TilePixelHeight(ti->tile) + TILE_HEIGHT) && |
258 (i == PCPpositions[bridgetrack][0] || i == PCPpositions[bridgetrack][1])) SETBIT(OverridePCP, i); |
252 (i == PCPpositions[bridgetrack][0] || i == PCPpositions[bridgetrack][1])) { |
|
253 SETBIT(OverridePCP, i); |
|
254 } |
259 } |
255 } |
260 |
256 |
261 if (PPPallowed[i] != 0 && HASBIT(PCPstatus, i) && !HASBIT(OverridePCP, i)) { |
257 if (PPPallowed[i] != 0 && HASBIT(PCPstatus, i) && !HASBIT(OverridePCP, i)) { |
262 for (k = 0; k < DIR_END; k++) { |
258 for (k = 0; k < DIR_END; k++) { |
263 byte temp = PPPorder[i][GetTLG(ti->tile)][k]; |
259 byte temp = PPPorder[i][GetTLG(ti->tile)][k]; |
290 |
286 |
291 /* Drawing of pylons is finished, now draw the wires */ |
287 /* Drawing of pylons is finished, now draw the wires */ |
292 for (t = TRACK_BEGIN; t < TRACK_END; t++) { |
288 for (t = TRACK_BEGIN; t < TRACK_END; t++) { |
293 if (HASBIT(trackconfig[TS_HOME], t)) { |
289 if (HASBIT(trackconfig[TS_HOME], t)) { |
294 if (IsTunnelTile(ti->tile)) { |
290 if (IsTunnelTile(ti->tile)) { |
295 const SortableSpriteStruct* sss = &CatenarySpriteData_Tunnel[GetTunnelDirection(ti->tile)]; |
291 const SortableSpriteStruct *sss = &CatenarySpriteData_Tunnel[GetTunnelDirection(ti->tile)]; |
296 |
292 |
297 AddSortableSpriteToDraw( |
293 AddSortableSpriteToDraw( |
298 sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset, |
294 sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset, |
299 sss->x_size, sss->y_size, sss->z_size, |
295 sss->x_size, sss->y_size, sss->z_size, |
300 GetTileZ(ti->tile) + sss->z_offset |
296 GetTileZ(ti->tile) + sss->z_offset |
378 } |
374 } |
379 if (_patches.disable_elrails) return; |
375 if (_patches.disable_elrails) return; |
380 |
376 |
381 switch (GetTileType(ti->tile)) { |
377 switch (GetTileType(ti->tile)) { |
382 case MP_RAILWAY: |
378 case MP_RAILWAY: |
383 if ( IsRailDepot(ti->tile)) { |
379 if (IsRailDepot(ti->tile)) { |
384 const SortableSpriteStruct* sss = &CatenarySpriteData_Depot[GetRailDepotDirection(ti->tile)]; |
380 const SortableSpriteStruct *sss = &CatenarySpriteData_Depot[GetRailDepotDirection(ti->tile)]; |
385 |
381 |
386 AddSortableSpriteToDraw( |
382 AddSortableSpriteToDraw( |
387 sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset, |
383 sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset, |
388 sss->x_size, sss->y_size, sss->z_size, |
384 sss->x_size, sss->y_size, sss->z_size, |
389 GetTileMaxZ(ti->tile) + sss->z_offset |
385 GetTileMaxZ(ti->tile) + sss->z_offset |
403 } |
399 } |
404 |
400 |
405 int32 SettingsDisableElrail(int32 p1) |
401 int32 SettingsDisableElrail(int32 p1) |
406 { |
402 { |
407 EngineID e_id; |
403 EngineID e_id; |
408 Vehicle* v; |
404 Vehicle *v; |
409 Player *p; |
405 Player *p; |
410 bool disable = (p1 != 0); |
406 bool disable = (p1 != 0); |
411 |
407 |
412 /* we will now walk through all electric train engines and change their railtypes if it is the wrong one*/ |
408 /* we will now walk through all electric train engines and change their railtypes if it is the wrong one*/ |
413 const RailType old_railtype = disable ? RAILTYPE_ELECTRIC : RAILTYPE_RAIL; |
409 const RailType old_railtype = disable ? RAILTYPE_ELECTRIC : RAILTYPE_RAIL; |