author | celestar |
Fri, 29 Dec 2006 12:03:28 +0000 | |
branch | custombridgeheads |
changeset 5594 | 04068f82afaa |
parent 5590 | dc34c43fc3eb |
child 5602 | de5228fb1871 |
permissions | -rw-r--r-- |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
1 |
/* $Id$ */ |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
2 |
/** @file elrail.c |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
3 |
* This file deals with displaying wires and pylons for electric railways. |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
4 |
* <h2>Basics</h2> |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
5 |
* |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
6 |
* <h3>Tile Types</h3> |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
7 |
* |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
8 |
* We have two different types of tiles in the drawing code: |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
9 |
* Normal Railway Tiles (NRTs) which can have more than one track on it, and |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
10 |
* Special Railways tiles (SRTs) which have only one track (like crossings, depots |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
11 |
* stations, etc). |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
12 |
* |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
13 |
* <h3>Location Categories</h3> |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
14 |
* |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
15 |
* All tiles are categorized into three location groups (TLG): |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
16 |
* Group 0: Tiles with both an even X coordinate and an even Y coordinate |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
17 |
* Group 1: Tiles with an even X and an odd Y coordinate |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
18 |
* Group 2: Tiles with an odd X and an even Y coordinate |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
19 |
* Group 3: Tiles with both an odd X and Y coordnate. |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
20 |
* |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
21 |
* <h3>Pylon Points</h3> |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
22 |
* <h4>Control Points</h4> |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
23 |
* A Pylon Control Point (PCP) is a position where a wire (or rather two) |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
24 |
* is mounted onto a pylon. |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
25 |
* Each NRT does contain 4 PCPs which are bitmapped to a byte |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
26 |
* variable and are represented by the DiagDirection enum |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
27 |
* |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
28 |
* Each track ends on two PCPs and thus requires one pylon on each end. However, |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
29 |
* there is one exception: Straight-and-level tracks only have one pylon every |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
30 |
* other tile. |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
31 |
* |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
32 |
* Now on each edge there are two PCPs: One from each adjacent tile. Both PCPs |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
33 |
* are merged using an OR operation (i. e. if one tile needs a PCP at the postion |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
34 |
* in question, both tiles get it). |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
35 |
* |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
36 |
* <h4>Position Points</h4> |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
37 |
* A Pylon Position Point (PPP) is a position where a pylon is located on the |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
38 |
* ground. Each PCP owns 8 in (45 degree steps) PPPs that are located around |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
39 |
* it. PPPs are represented using the Direction enum. Each track bit has PPPs |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
40 |
* that are impossible (because the pylon would be situated on the track) and |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
41 |
* some that are preferred (because the pylon would be rectangular to the track). |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
42 |
* |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
43 |
* <img src="../../elrail_tile.png"> |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
44 |
* <img src="../../elrail_track.png"> |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
45 |
* |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
46 |
*/ |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
47 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
48 |
#include "stdafx.h" |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
49 |
#include "openttd.h" |
3367 | 50 |
#include "station_map.h" |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
51 |
#include "tile.h" |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
52 |
#include "viewport.h" |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
53 |
#include "functions.h" /* We should REALLY get rid of this goddamn file, as it is butt-ugly */ |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
54 |
#include "variables.h" /* ... same here */ |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
55 |
#include "rail.h" |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
56 |
#include "debug.h" |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
57 |
#include "tunnel_map.h" |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
58 |
#include "road_map.h" |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
59 |
#include "bridge_map.h" |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
60 |
#include "bridge.h" |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
61 |
#include "rail_map.h" |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
62 |
#include "table/sprites.h" |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
63 |
#include "table/elrail_data.h" |
5116
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
64 |
#include "vehicle.h" |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
65 |
#include "train.h" |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
66 |
#include "gui.h" |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
67 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
68 |
static inline TLG GetTLG(TileIndex t) |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
69 |
{ |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
70 |
return (HASBIT(TileX(t), 0) << 1) + HASBIT(TileY(t), 0); |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
71 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
72 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
73 |
/** Finds which Rail Bits are present on a given tile. For bridge tiles, |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
74 |
* returns track bits under the bridge |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
75 |
*/ |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
76 |
static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override) |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
77 |
{ |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
78 |
switch (GetTileType(t)) { |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
79 |
case MP_RAILWAY: |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
80 |
if (GetRailType(t) != RAILTYPE_ELECTRIC) return 0; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
81 |
switch (GetRailTileType(t)) { |
3792
2eb8388731bf
(svn r4788) - Codechange: RAILTYPE_{NORMAL,ELECTRIC,...} and RAIL_TYPE_{NORMAL,SIGNAL,...} have nearly the same name, rename RAIL_TYPE_* to RAIL_TILE_* of extra clarity
rubidium
parents:
3789
diff
changeset
|
82 |
case RAIL_TILE_NORMAL: case RAIL_TILE_SIGNALS: |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
83 |
return GetTrackBits(t); |
3792
2eb8388731bf
(svn r4788) - Codechange: RAILTYPE_{NORMAL,ELECTRIC,...} and RAIL_TYPE_{NORMAL,SIGNAL,...} have nearly the same name, rename RAIL_TYPE_* to RAIL_TILE_* of extra clarity
rubidium
parents:
3789
diff
changeset
|
84 |
case RAIL_TILE_DEPOT_WAYPOINT: |
3376
a946f51034e7
(svn r4178) -Fix: Draw catenary inside waypoints as well
celestar
parents:
3375
diff
changeset
|
85 |
if (GetRailTileSubtype(t) == RAIL_SUBTYPE_WAYPOINT) return GetRailWaypointBits(t); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
86 |
default: |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
87 |
return 0; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
88 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
89 |
break; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4021
diff
changeset
|
90 |
|
5590
dc34c43fc3eb
(svn r7597) [cbh] - Codechange: Remove MP_TUNNELBRIDGE and introduce three new TileTypes: MP_TUNNEL, MP_STREET_BRIDGE, MP_RAILWAY_BRIDGE
celestar
parents:
5573
diff
changeset
|
91 |
case MP_TUNNEL: |
dc34c43fc3eb
(svn r7597) [cbh] - Codechange: Remove MP_TUNNELBRIDGE and introduce three new TileTypes: MP_TUNNEL, MP_STREET_BRIDGE, MP_RAILWAY_BRIDGE
celestar
parents:
5573
diff
changeset
|
92 |
if (GetRailType(t) != RAILTYPE_ELECTRIC) return 0; |
dc34c43fc3eb
(svn r7597) [cbh] - Codechange: Remove MP_TUNNELBRIDGE and introduce three new TileTypes: MP_TUNNEL, MP_STREET_BRIDGE, MP_RAILWAY_BRIDGE
celestar
parents:
5573
diff
changeset
|
93 |
if (override != NULL) *override = 1 << GetTunnelDirection(t); |
dc34c43fc3eb
(svn r7597) [cbh] - Codechange: Remove MP_TUNNELBRIDGE and introduce three new TileTypes: MP_TUNNEL, MP_STREET_BRIDGE, MP_RAILWAY_BRIDGE
celestar
parents:
5573
diff
changeset
|
94 |
return AxisToTrackBits(DiagDirToAxis(GetTunnelDirection(t))); |
dc34c43fc3eb
(svn r7597) [cbh] - Codechange: Remove MP_TUNNELBRIDGE and introduce three new TileTypes: MP_TUNNEL, MP_STREET_BRIDGE, MP_RAILWAY_BRIDGE
celestar
parents:
5573
diff
changeset
|
95 |
|
dc34c43fc3eb
(svn r7597) [cbh] - Codechange: Remove MP_TUNNELBRIDGE and introduce three new TileTypes: MP_TUNNEL, MP_STREET_BRIDGE, MP_RAILWAY_BRIDGE
celestar
parents:
5573
diff
changeset
|
96 |
case MP_RAILWAY_BRIDGE: |
dc34c43fc3eb
(svn r7597) [cbh] - Codechange: Remove MP_TUNNELBRIDGE and introduce three new TileTypes: MP_TUNNEL, MP_STREET_BRIDGE, MP_RAILWAY_BRIDGE
celestar
parents:
5573
diff
changeset
|
97 |
if (GetRailType(t) != RAILTYPE_ELECTRIC) return 0; |
dc34c43fc3eb
(svn r7597) [cbh] - Codechange: Remove MP_TUNNELBRIDGE and introduce three new TileTypes: MP_TUNNEL, MP_STREET_BRIDGE, MP_RAILWAY_BRIDGE
celestar
parents:
5573
diff
changeset
|
98 |
if (override != NULL && DistanceMax(t, GetOtherBridgeEnd(t)) > 1) { |
dc34c43fc3eb
(svn r7597) [cbh] - Codechange: Remove MP_TUNNELBRIDGE and introduce three new TileTypes: MP_TUNNEL, MP_STREET_BRIDGE, MP_RAILWAY_BRIDGE
celestar
parents:
5573
diff
changeset
|
99 |
*override = 1 << GetBridgeRampDirection(t); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
100 |
} |
5590
dc34c43fc3eb
(svn r7597) [cbh] - Codechange: Remove MP_TUNNELBRIDGE and introduce three new TileTypes: MP_TUNNEL, MP_STREET_BRIDGE, MP_RAILWAY_BRIDGE
celestar
parents:
5573
diff
changeset
|
101 |
return AxisToTrackBits(DiagDirToAxis(GetBridgeRampDirection(t))); |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4021
diff
changeset
|
102 |
|
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
103 |
case MP_STREET: |
3793
33cdb5bf7b21
(svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents:
3792
diff
changeset
|
104 |
if (GetRoadTileType(t) != ROAD_TILE_CROSSING) return 0; |
3367 | 105 |
if (GetRailTypeCrossing(t) != RAILTYPE_ELECTRIC) return 0; |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
106 |
return GetCrossingRailBits(t); |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4021
diff
changeset
|
107 |
|
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
108 |
case MP_STATION: |
3403
96b9eb3eee48
(svn r4214) -Fix: Do not try to obtain Trackbits for normal rails, bus stops, airports and other non-rail tiles
celestar
parents:
3395
diff
changeset
|
109 |
if (!IsRailwayStation(t)) return 0; |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
110 |
if (GetRailType(t) != RAILTYPE_ELECTRIC) return 0; |
3789
bf75e48227de
(svn r4785) - Newstations: don't draw catenary on non-track tiles
glx
parents:
3645
diff
changeset
|
111 |
if (!IsStationTileElectrifiable(t)) return 0; |
3375
7fea43d72298
(svn r4177) -Fix: GetRailTrackBitsUniversal needs Trackbits, not Track. While at it, remove an unused variable
celestar
parents:
3368
diff
changeset
|
112 |
return TrackToTrackBits(GetRailStationTrack(t)); |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4021
diff
changeset
|
113 |
|
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
114 |
default: |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
115 |
return 0; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
116 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
117 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
118 |
|
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
119 |
/** Corrects the tileh for certain tile types. Returns an effective tileh for the track on the tile. |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
120 |
* @param tile The tile to analyse |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
121 |
* @param *tileh the tileh |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
122 |
*/ |
4171 | 123 |
static void AdjustTileh(TileIndex tile, Slope *tileh) |
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
124 |
{ |
5590
dc34c43fc3eb
(svn r7597) [cbh] - Codechange: Remove MP_TUNNELBRIDGE and introduce three new TileTypes: MP_TUNNEL, MP_STREET_BRIDGE, MP_RAILWAY_BRIDGE
celestar
parents:
5573
diff
changeset
|
125 |
if (IsTileType(tile, MP_TUNNEL)) *tileh = SLOPE_FLAT; |
dc34c43fc3eb
(svn r7597) [cbh] - Codechange: Remove MP_TUNNELBRIDGE and introduce three new TileTypes: MP_TUNNEL, MP_STREET_BRIDGE, MP_RAILWAY_BRIDGE
celestar
parents:
5573
diff
changeset
|
126 |
|
dc34c43fc3eb
(svn r7597) [cbh] - Codechange: Remove MP_TUNNELBRIDGE and introduce three new TileTypes: MP_TUNNEL, MP_STREET_BRIDGE, MP_RAILWAY_BRIDGE
celestar
parents:
5573
diff
changeset
|
127 |
if (IsTileType(tile, MP_RAILWAY_BRIDGE)) { |
dc34c43fc3eb
(svn r7597) [cbh] - Codechange: Remove MP_TUNNELBRIDGE and introduce three new TileTypes: MP_TUNNEL, MP_STREET_BRIDGE, MP_RAILWAY_BRIDGE
celestar
parents:
5573
diff
changeset
|
128 |
if (*tileh != SLOPE_FLAT) { |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3463
diff
changeset
|
129 |
*tileh = SLOPE_FLAT; |
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
130 |
} else { |
5590
dc34c43fc3eb
(svn r7597) [cbh] - Codechange: Remove MP_TUNNELBRIDGE and introduce three new TileTypes: MP_TUNNEL, MP_STREET_BRIDGE, MP_RAILWAY_BRIDGE
celestar
parents:
5573
diff
changeset
|
131 |
switch (GetBridgeRampDirection(tile)) { |
dc34c43fc3eb
(svn r7597) [cbh] - Codechange: Remove MP_TUNNELBRIDGE and introduce three new TileTypes: MP_TUNNEL, MP_STREET_BRIDGE, MP_RAILWAY_BRIDGE
celestar
parents:
5573
diff
changeset
|
132 |
case DIAGDIR_NE: *tileh = SLOPE_NE; break; |
dc34c43fc3eb
(svn r7597) [cbh] - Codechange: Remove MP_TUNNELBRIDGE and introduce three new TileTypes: MP_TUNNEL, MP_STREET_BRIDGE, MP_RAILWAY_BRIDGE
celestar
parents:
5573
diff
changeset
|
133 |
case DIAGDIR_SE: *tileh = SLOPE_SE; break; |
dc34c43fc3eb
(svn r7597) [cbh] - Codechange: Remove MP_TUNNELBRIDGE and introduce three new TileTypes: MP_TUNNEL, MP_STREET_BRIDGE, MP_RAILWAY_BRIDGE
celestar
parents:
5573
diff
changeset
|
134 |
case DIAGDIR_SW: *tileh = SLOPE_SW; break; |
dc34c43fc3eb
(svn r7597) [cbh] - Codechange: Remove MP_TUNNELBRIDGE and introduce three new TileTypes: MP_TUNNEL, MP_STREET_BRIDGE, MP_RAILWAY_BRIDGE
celestar
parents:
5573
diff
changeset
|
135 |
case DIAGDIR_NW: *tileh = SLOPE_NW; break; |
dc34c43fc3eb
(svn r7597) [cbh] - Codechange: Remove MP_TUNNELBRIDGE and introduce three new TileTypes: MP_TUNNEL, MP_STREET_BRIDGE, MP_RAILWAY_BRIDGE
celestar
parents:
5573
diff
changeset
|
136 |
default: NOT_REACHED(); |
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
137 |
} |
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
138 |
} |
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
139 |
} |
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
140 |
} |
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
141 |
|
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
142 |
/** Draws wires and, if required, pylons on a given tile |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
143 |
* @param ti The Tileinfo to draw the tile for |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
144 |
*/ |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
145 |
static void DrawCatenaryRailway(const TileInfo *ti) |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
146 |
{ |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
147 |
/* Pylons are placed on a tile edge, so we need to take into account |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
148 |
* the track configuration of 2 adjacent tiles. trackconfig[0] stores the |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
149 |
* current tile (home tile) while [1] holds the neighbour */ |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
150 |
TrackBits trackconfig[TS_END]; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
151 |
bool isflat[TS_END]; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
152 |
/* Note that ti->tileh has already been adjusted for Foundations */ |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3463
diff
changeset
|
153 |
Slope tileh[TS_END] = { ti->tileh, SLOPE_FLAT }; |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
154 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
155 |
TLG tlg = GetTLG(ti->tile); |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
156 |
byte PCPstatus = 0; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
157 |
byte OverridePCP = 0; |
3395 | 158 |
byte PPPpreferred[DIAGDIR_END]; |
159 |
byte PPPallowed[DIAGDIR_END]; |
|
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
160 |
DiagDirection i; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
161 |
Track t; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
162 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
163 |
/* Find which rail bits are present, and select the override points. |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
164 |
* We don't draw a pylon: |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
165 |
* 1) INSIDE a tunnel (we wouldn't see it anyway) |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
166 |
* 2) on the "far" end of a bridge head (the one that connects to bridge middle), |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
167 |
* because that one is drawn on the bridge. Exception is for length 0 bridges |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
168 |
* which have no middle tiles */ |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
169 |
trackconfig[TS_HOME] = GetRailTrackBitsUniversal(ti->tile, &OverridePCP); |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
170 |
/* If a track bit is present that is not in the main direction, the track is level */ |
3461
958012fc3d77
(svn r4305) -Codechange: Minor elrail cleanup (Tron)
celestar
parents:
3452
diff
changeset
|
171 |
isflat[TS_HOME] = trackconfig[TS_HOME] & (TRACK_BIT_HORZ | TRACK_BIT_VERT); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
172 |
|
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
173 |
AdjustTileh(ti->tile, &tileh[TS_HOME]); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
174 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
175 |
for (i = DIAGDIR_NE; i < DIAGDIR_END; i++) { |
4559
c853d2440065
(svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents:
4549
diff
changeset
|
176 |
TileIndex neighbour = ti->tile + TileOffsByDiagDir(i); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
177 |
uint foundation = 0; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
178 |
int k; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
179 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
180 |
/* Here's one of the main headaches. GetTileSlope does not correct for possibly |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
181 |
* existing foundataions, so we do have to do that manually later on.*/ |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
182 |
tileh[TS_NEIGHBOUR] = GetTileSlope(neighbour, NULL); |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
183 |
trackconfig[TS_NEIGHBOUR] = GetRailTrackBitsUniversal(neighbour, NULL); |
3452
c3ee991eaba1
(svn r4284) -Fix: Tunnel portals no longer have a pylon ON them if there is a track right above the portal
celestar
parents:
3451
diff
changeset
|
184 |
if (IsTunnelTile(neighbour) && i != GetTunnelDirection(neighbour)) trackconfig[TS_NEIGHBOUR] = 0; |
3461
958012fc3d77
(svn r4305) -Codechange: Minor elrail cleanup (Tron)
celestar
parents:
3452
diff
changeset
|
185 |
isflat[TS_NEIGHBOUR] = trackconfig[TS_NEIGHBOUR] & (TRACK_BIT_HORZ | TRACK_BIT_VERT); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
186 |
|
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
187 |
PPPpreferred[i] = 0xFF; /* We start with preferring everything (end-of-line in any direction) */ |
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
188 |
PPPallowed[i] = AllowedPPPonPCP[i]; |
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
189 |
|
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
190 |
/* We cycle through all the existing tracks at a PCP and see what |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
191 |
* PPPs we want to have, or may not have at all */ |
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
192 |
for (k = 0; k < NUM_TRACKS_AT_PCP; k++) { |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
193 |
/* Next to us, we have a bridge head, don't worry about that one, if it shows away from us */ |
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
194 |
if (TrackSourceTile[i][k] == TS_NEIGHBOUR && |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
195 |
IsBridgeTile(neighbour) && |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3995
diff
changeset
|
196 |
GetBridgeRampDirection(neighbour) == ReverseDiagDir(i)) { |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3995
diff
changeset
|
197 |
continue; |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3995
diff
changeset
|
198 |
} |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
199 |
|
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
200 |
/* We check whether the track in question (k) is present in the tile |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
201 |
* (TrackSourceTile) */ |
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
202 |
if (HASBIT(trackconfig[TrackSourceTile[i][k]], TracksAtPCP[i][k])) { |
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
203 |
/* track found, if track is in the neighbour tile, adjust the number |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
204 |
* of the PCP for preferred/allowed determination*/ |
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
205 |
DiagDirection PCPpos = (TrackSourceTile[i][k] == TS_HOME) ? i : ReverseDiagDir(i); |
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
206 |
SETBIT(PCPstatus, i); /* This PCP is in use */ |
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
207 |
|
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
208 |
PPPpreferred[i] &= PreferredPPPofTrackAtPCP[TracksAtPCP[i][k]][PCPpos]; |
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
209 |
PPPallowed[i] &= ~DisallowedPPPofTrackAtPCP[TracksAtPCP[i][k]][PCPpos]; |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
210 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
211 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
212 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
213 |
/* Deactivate all PPPs if PCP is not used */ |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
214 |
PPPpreferred[i] *= HASBIT(PCPstatus, i); |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
215 |
PPPallowed[i] *= HASBIT(PCPstatus, i); |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
216 |
|
3880
cde142e509ec
(svn r4934) -Fix: Correct a misleading comment, and remove an unneeded condition from the corresponding if (thans Tron for pointing it out)
celestar
parents:
3793
diff
changeset
|
217 |
/* A station is always "flat", so adjust the tileh accordingly */ |
cde142e509ec
(svn r4934) -Fix: Correct a misleading comment, and remove an unneeded condition from the corresponding if (thans Tron for pointing it out)
celestar
parents:
3793
diff
changeset
|
218 |
if (IsTileType(neighbour, MP_STATION)) tileh[TS_NEIGHBOUR] = SLOPE_FLAT; |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
219 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
220 |
/* Read the foundataions if they are present, and adjust the tileh */ |
4448
3856ddf73609
(svn r6226) -Fix(r5864): an assertion was triggered when drawing catenary on steep slopes (TrueLight)
glx
parents:
4182
diff
changeset
|
221 |
if (IsTileType(neighbour, MP_RAILWAY) && GetRailType(neighbour) == RAILTYPE_ELECTRIC) foundation = GetRailFoundation(tileh[TS_NEIGHBOUR], trackconfig[TS_NEIGHBOUR]); |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
222 |
if (IsBridgeTile(neighbour)) { |
3368
57034dcd7978
(svn r4165) -Do not use GetBridgeAxis on bridge ramps (request by Tron)
celestar
parents:
3367
diff
changeset
|
223 |
foundation = GetBridgeFoundation(tileh[TS_NEIGHBOUR], DiagDirToAxis(GetBridgeRampDirection(neighbour))); |
57034dcd7978
(svn r4165) -Do not use GetBridgeAxis on bridge ramps (request by Tron)
celestar
parents:
3367
diff
changeset
|
224 |
} |
57034dcd7978
(svn r4165) -Do not use GetBridgeAxis on bridge ramps (request by Tron)
celestar
parents:
3367
diff
changeset
|
225 |
|
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
226 |
if (foundation != 0) { |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
227 |
if (foundation < 15) { |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3463
diff
changeset
|
228 |
tileh[TS_NEIGHBOUR] = SLOPE_FLAT; |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
229 |
} else { |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
230 |
tileh[TS_NEIGHBOUR] = _inclined_tileh[foundation - 15]; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
231 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
232 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
233 |
|
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
234 |
AdjustTileh(neighbour, &tileh[TS_NEIGHBOUR]); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
235 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
236 |
/* If we have a straight (and level) track, we want a pylon only every 2 tiles |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
237 |
* Delete the PCP if this is the case. */ |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
238 |
/* Level means that the slope is the same, or the track is flat */ |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
239 |
if (tileh[TS_HOME] == tileh[TS_NEIGHBOUR] || (isflat[TS_HOME] && isflat[TS_NEIGHBOUR])) { |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
240 |
for (k = 0; k < NUM_IGNORE_GROUPS; k++) |
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
241 |
if (PPPpreferred[i] == IgnoredPCP[k][tlg][i]) CLRBIT(PCPstatus, i); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
242 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
243 |
|
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
244 |
/* Now decide where we draw our pylons. First try the preferred PPPs, but they may not exist. |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
245 |
* In that case, we try the any of the allowed ones. if they don't exist either, don't draw |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
246 |
* anything. Note that the preferred PPPs still contain the end-of-line markers. |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
247 |
* Remove those (simply by ANDing with allowed, since these markers are never allowed) */ |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4021
diff
changeset
|
248 |
if ((PPPallowed[i] & PPPpreferred[i]) != 0) PPPallowed[i] &= PPPpreferred[i]; |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
249 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
250 |
if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile)) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
251 |
Track bridgetrack = GetBridgeAxis(ti->tile) == AXIS_X ? TRACK_X : TRACK_Y; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
252 |
uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile)); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
253 |
|
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
254 |
if ((height <= TilePixelHeight(ti->tile) + TILE_HEIGHT) && |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
255 |
(i == PCPpositions[bridgetrack][0] || i == PCPpositions[bridgetrack][1])) SETBIT(OverridePCP, i); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
256 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
257 |
|
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
258 |
if (PPPallowed[i] != 0 && HASBIT(PCPstatus, i) && !HASBIT(OverridePCP, i)) { |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
259 |
for (k = 0; k < DIR_END; k++) { |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
260 |
byte temp = PPPorder[i][GetTLG(ti->tile)][k]; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4021
diff
changeset
|
261 |
|
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
262 |
if (HASBIT(PPPallowed[i], temp)) { |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
263 |
uint x = ti->x + x_pcp_offsets[i] + x_ppp_offsets[temp]; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
264 |
uint y = ti->y + y_pcp_offsets[i] + y_ppp_offsets[temp]; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
265 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
266 |
/* Don't build the pylon if it would be outside the tile */ |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
267 |
if (!HASBIT(OwnedPPPonPCP[i], temp)) { |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
268 |
/* We have a neighour that will draw it, bail out */ |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
269 |
if (trackconfig[TS_NEIGHBOUR] != 0) break; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
270 |
continue; /* No neighbour, go looking for a better position */ |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
271 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
272 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
273 |
AddSortableSpriteToDraw(pylons_normal[temp], x, y, 1, 1, 10, |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
274 |
GetSlopeZ(ti->x + x_pcp_offsets[i], ti->y + y_pcp_offsets[i])); |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
275 |
break; /* We already have drawn a pylon, bail out */ |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
276 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
277 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
278 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
279 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
280 |
|
4480
2dfb09aaa11c
(svn r6265) Check whether to draw catenary at all once before the drawing loop instead of on every iteration
tron
parents:
4470
diff
changeset
|
281 |
/* Don't draw a wire under a low bridge */ |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
282 |
if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !(_display_opt & DO_TRANS_BUILDINGS)) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
283 |
uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile)); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
284 |
|
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
285 |
if (height <= TilePixelHeight(ti->tile) + TILE_HEIGHT) return; |
4480
2dfb09aaa11c
(svn r6265) Check whether to draw catenary at all once before the drawing loop instead of on every iteration
tron
parents:
4470
diff
changeset
|
286 |
} |
2dfb09aaa11c
(svn r6265) Check whether to draw catenary at all once before the drawing loop instead of on every iteration
tron
parents:
4470
diff
changeset
|
287 |
|
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
288 |
/* Drawing of pylons is finished, now draw the wires */ |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
289 |
for (t = 0; t < TRACK_END; t++) { |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
290 |
if (HASBIT(trackconfig[TS_HOME], t)) { |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
291 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
292 |
byte PCPconfig = HASBIT(PCPstatus, PCPpositions[t][0]) + |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
293 |
(HASBIT(PCPstatus, PCPpositions[t][1]) << 1); |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
294 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
295 |
const SortableSpriteStruct *sss; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
296 |
int tileh_selector = !(tileh[TS_HOME] % 3) * tileh[TS_HOME] / 3; /* tileh for the slopes, 0 otherwise */ |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
297 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
298 |
assert(PCPconfig != 0); /* We have a pylon on neither end of the wire, that doesn't work (since we have no sprites for that) */ |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3463
diff
changeset
|
299 |
assert(!IsSteepSlope(tileh[TS_HOME])); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
300 |
sss = &CatenarySpriteData[Wires[tileh_selector][t][PCPconfig]]; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
301 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
302 |
AddSortableSpriteToDraw( sss->image, ti->x + sss->x_offset, ti->y + sss->y_offset, |
3645
86af43f87885
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3636
diff
changeset
|
303 |
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); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
304 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
305 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
306 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
307 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
308 |
static void DrawCatenaryOnBridge(const TileInfo *ti) |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
309 |
{ |
3445
bd7f731c8e6f
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
310 |
TileIndex end = GetSouthernBridgeEnd(ti->tile); |
bd7f731c8e6f
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
311 |
TileIndex start = GetOtherBridgeEnd(end); |
bd7f731c8e6f
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
312 |
|
bd7f731c8e6f
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
313 |
uint length = GetBridgeLength(start, end); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
314 |
uint num = DistanceMax(ti->tile, start); |
4159
55c50b91e5b8
(svn r5584) When drawing catenary on a bridge calculate its height only once
tron
parents:
4158
diff
changeset
|
315 |
uint height; |
3445
bd7f731c8e6f
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
316 |
|
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
317 |
const SortableSpriteStruct *sss; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
318 |
Axis axis = GetBridgeAxis(ti->tile); |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
319 |
TLG tlg = GetTLG(ti->tile); |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
320 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
321 |
CatenarySprite offset = axis == AXIS_X ? 0 : WIRE_Y_FLAT_BOTH - WIRE_X_FLAT_BOTH; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
322 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
323 |
if ((length % 2) && num == length) { |
3445
bd7f731c8e6f
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
324 |
/* Draw the "short" wire on the southern end of the bridge |
bd7f731c8e6f
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
325 |
* only needed if the length of the bridge is odd */ |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
326 |
sss = &CatenarySpriteData[WIRE_X_FLAT_BOTH + offset]; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
327 |
} else { |
3445
bd7f731c8e6f
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
328 |
/* Draw "long" wires on all other tiles of the bridge (one pylon every two tiles) */ |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
329 |
sss = &CatenarySpriteData[WIRE_X_FLAT_SW + (num % 2) + offset]; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
330 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
331 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
332 |
height = GetBridgeHeight(end); |
4159
55c50b91e5b8
(svn r5584) When drawing catenary on a bridge calculate its height only once
tron
parents:
4158
diff
changeset
|
333 |
|
3445
bd7f731c8e6f
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
334 |
AddSortableSpriteToDraw( sss->image, ti->x + sss->x_offset, ti->y + sss->y_offset, |
4159
55c50b91e5b8
(svn r5584) When drawing catenary on a bridge calculate its height only once
tron
parents:
4158
diff
changeset
|
335 |
sss->x_size, sss->y_size, sss->z_size, height + sss->z_offset |
55c50b91e5b8
(svn r5584) When drawing catenary on a bridge calculate its height only once
tron
parents:
4158
diff
changeset
|
336 |
); |
3445
bd7f731c8e6f
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
337 |
|
bd7f731c8e6f
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
338 |
/* Finished with wires, draw pylons */ |
bd7f731c8e6f
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
339 |
/* every other tile needs a pylon on the northern end */ |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
340 |
if (num % 2) { |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
341 |
if (axis == AXIS_X) { |
4159
55c50b91e5b8
(svn r5584) When drawing catenary on a bridge calculate its height only once
tron
parents:
4158
diff
changeset
|
342 |
AddSortableSpriteToDraw(pylons_bridge[0 + HASBIT(tlg, 0)], ti->x, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, height); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
343 |
} else { |
4159
55c50b91e5b8
(svn r5584) When drawing catenary on a bridge calculate its height only once
tron
parents:
4158
diff
changeset
|
344 |
AddSortableSpriteToDraw(pylons_bridge[2 + HASBIT(tlg, 1)], ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y, 1, 1, 10, height); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
345 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
346 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
347 |
|
3445
bd7f731c8e6f
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
348 |
/* need a pylon on the southern end of the bridge */ |
bd7f731c8e6f
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
349 |
if (DistanceMax(ti->tile, start) == length) { |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
350 |
if (axis == AXIS_X) { |
4159
55c50b91e5b8
(svn r5584) When drawing catenary on a bridge calculate its height only once
tron
parents:
4158
diff
changeset
|
351 |
AddSortableSpriteToDraw(pylons_bridge[0 + HASBIT(tlg, 0)], ti->x + 16, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, height); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
352 |
} else { |
4159
55c50b91e5b8
(svn r5584) When drawing catenary on a bridge calculate its height only once
tron
parents:
4158
diff
changeset
|
353 |
AddSortableSpriteToDraw(pylons_bridge[2 + HASBIT(tlg, 1)], ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y + 16, 1, 1, 10, height); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
354 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
355 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
356 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
357 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
358 |
void DrawCatenary(const TileInfo *ti) |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
359 |
{ |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
360 |
if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile)) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
361 |
TileIndex head = GetNorthernBridgeEnd(ti->tile); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
362 |
|
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
363 |
if (GetBridgeTransportType(head) == TRANSPORT_RAIL && GetRailType(head) == RAILTYPE_ELECTRIC) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
364 |
DrawCatenaryOnBridge(ti); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
365 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
366 |
} |
5116
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
367 |
if (_patches.disable_elrails) return; |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
368 |
|
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
369 |
switch (GetTileType(ti->tile)) { |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
370 |
case MP_RAILWAY: |
4182
20d711816338
(svn r5624) Use {IsPlainRailTile,IsRailDepot,IsRailWaypoint,HasSignals}() instead of GetRailTile{T,Subt}ype() - this is more concise and a bit more flexible if/when the rail tile encoding changes
tron
parents:
4171
diff
changeset
|
371 |
if (IsRailDepot(ti->tile)) { |
4470 | 372 |
const SortableSpriteStruct* sss = &CatenarySpriteData_Depot[GetRailDepotDirection(ti->tile)]; |
373 |
||
374 |
AddSortableSpriteToDraw( |
|
375 |
sss->image, ti->x + sss->x_offset, ti->y + sss->y_offset, |
|
376 |
sss->x_size, sss->y_size, sss->z_size, |
|
377 |
GetTileMaxZ(ti->tile) + sss->z_offset |
|
378 |
); |
|
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
379 |
return; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
380 |
} |
3995
3a2d054689d6
(svn r5198) Fix some strange control flow: the case for MP_RAILWAY fell through the case for MP_TUNNELBRIDGE
tron
parents:
3977
diff
changeset
|
381 |
break; |
3a2d054689d6
(svn r5198) Fix some strange control flow: the case for MP_RAILWAY fell through the case for MP_TUNNELBRIDGE
tron
parents:
3977
diff
changeset
|
382 |
|
5590
dc34c43fc3eb
(svn r7597) [cbh] - Codechange: Remove MP_TUNNELBRIDGE and introduce three new TileTypes: MP_TUNNEL, MP_STREET_BRIDGE, MP_RAILWAY_BRIDGE
celestar
parents:
5573
diff
changeset
|
383 |
case MP_TUNNEL: |
dc34c43fc3eb
(svn r7597) [cbh] - Codechange: Remove MP_TUNNELBRIDGE and introduce three new TileTypes: MP_TUNNEL, MP_STREET_BRIDGE, MP_RAILWAY_BRIDGE
celestar
parents:
5573
diff
changeset
|
384 |
case MP_RAILWAY_BRIDGE: |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
385 |
case MP_STREET: |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
386 |
case MP_STATION: |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
387 |
break; |
3995
3a2d054689d6
(svn r5198) Fix some strange control flow: the case for MP_RAILWAY fell through the case for MP_TUNNELBRIDGE
tron
parents:
3977
diff
changeset
|
388 |
|
3a2d054689d6
(svn r5198) Fix some strange control flow: the case for MP_RAILWAY fell through the case for MP_TUNNELBRIDGE
tron
parents:
3977
diff
changeset
|
389 |
default: return; |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
390 |
} |
3995
3a2d054689d6
(svn r5198) Fix some strange control flow: the case for MP_RAILWAY fell through the case for MP_TUNNELBRIDGE
tron
parents:
3977
diff
changeset
|
391 |
DrawCatenaryRailway(ti); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
392 |
} |
5116
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
393 |
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
394 |
int32 SettingsDisableElrail(int32 p1) |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
395 |
{ |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
396 |
EngineID e_id; |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
397 |
Vehicle* v; |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
398 |
Player *p; |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
399 |
bool disable = (p1 != 0); |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
400 |
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
401 |
/* we will now walk through all electric train engines and change their railtypes if it is the wrong one*/ |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
402 |
const RailType old_railtype = disable ? RAILTYPE_ELECTRIC : RAILTYPE_RAIL; |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
403 |
const RailType new_railtype = disable ? RAILTYPE_RAIL : RAILTYPE_ELECTRIC; |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
404 |
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
405 |
/* walk through all train engines */ |
5314
021dbca1d6da
(svn r7470) -Codechange: Leave elrails enabled after loading old (pre-optional) and very old (pre-elrails) games. Let the user manually disable if if undesired.
Darkvater
parents:
5116
diff
changeset
|
406 |
for (e_id = 0; e_id < NUM_TRAIN_ENGINES; e_id++) { |
5116
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
407 |
const RailVehicleInfo *rv_info = RailVehInfo(e_id); |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
408 |
Engine *e = GetEngine(e_id); |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
409 |
/* if it is an electric rail engine and its railtype is the wrong one */ |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
410 |
if (rv_info->engclass == 2 && e->railtype == old_railtype) { |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
411 |
/* change it to the proper one */ |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
412 |
e->railtype = new_railtype; |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
413 |
} |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
414 |
} |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
415 |
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
416 |
/* when disabling elrails, make sure that all existing trains can run on |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
417 |
* normal rail too */ |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
418 |
if (disable) { |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
419 |
FOR_ALL_VEHICLES(v) { |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
420 |
if (v->type == VEH_Train && v->u.rail.railtype == RAILTYPE_ELECTRIC) { |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
421 |
/* this railroad vehicle is now compatible only with elrail, |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
422 |
* so add there also normal rail compatibility */ |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
423 |
v->u.rail.compatible_railtypes |= (1 << RAILTYPE_RAIL); |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
424 |
v->u.rail.railtype = RAILTYPE_RAIL; |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
425 |
SETBIT(v->u.rail.flags, VRF_EL_ENGINE_ALLOWED_NORMAL_RAIL); |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
426 |
} |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
427 |
} |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
428 |
} |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
429 |
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
430 |
/* setup total power for trains */ |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
431 |
FOR_ALL_VEHICLES(v) { |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
432 |
/* power is cached only for front engines */ |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
433 |
if (v->type == VEH_Train && IsFrontEngine(v)) TrainPowerChanged(v); |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
434 |
} |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
435 |
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
436 |
FOR_ALL_PLAYERS(p) p->avail_railtypes = GetPlayerRailtypes(p->index); |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
437 |
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
438 |
/* This resets the _last_built_railtype, which will be invalid for electric |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
439 |
* rails. It may have unintended consequences if that function is ever |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
440 |
* extended, though. */ |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
441 |
ReinitGuiAfterToggleElrail(disable); |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
442 |
return 0; |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
443 |
} |