author | KUDr |
Fri, 20 Apr 2007 19:43:06 +0000 | |
changeset 6513 | 454347ca3dfb |
parent 6453 | 226bcddeba32 |
child 6699 | d2f35126c1a6 |
permissions | -rw-r--r-- |
3355
e414a0b104a6
(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$ */ |
6117
6507b2a7e71d
(svn r8853) -Cleanup: doxygen changes. Correct forgotten c files to cpp files with the @file tag as well as a few general comments style
belugas
parents:
5823
diff
changeset
|
2 |
/** @file elrail.cpp |
4549
106ed18a7675
(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. |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
4 |
* <h2>Basics</h2> |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
5 |
* |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
6 |
* <h3>Tile Types</h3> |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
7 |
* |
106ed18a7675
(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: |
106ed18a7675
(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 |
106ed18a7675
(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 |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
11 |
* stations, etc). |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
12 |
* |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
13 |
* <h3>Location Categories</h3> |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
14 |
* |
106ed18a7675
(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): |
106ed18a7675
(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 |
106ed18a7675
(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 |
106ed18a7675
(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 |
106ed18a7675
(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. |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
20 |
* |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
21 |
* <h3>Pylon Points</h3> |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
22 |
* <h4>Control Points</h4> |
106ed18a7675
(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) |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
24 |
* is mounted onto a pylon. |
106ed18a7675
(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 |
106ed18a7675
(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 |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
27 |
* |
106ed18a7675
(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, |
106ed18a7675
(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 |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
30 |
* other tile. |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
31 |
* |
106ed18a7675
(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 |
106ed18a7675
(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 |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
34 |
* in question, both tiles get it). |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
35 |
* |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
36 |
* <h4>Position Points</h4> |
106ed18a7675
(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 |
106ed18a7675
(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 |
106ed18a7675
(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 |
106ed18a7675
(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 |
106ed18a7675
(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). |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
42 |
* |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
43 |
* <img src="../../elrail_tile.png"> |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
44 |
* <img src="../../elrail_track.png"> |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
45 |
* |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
46 |
*/ |
3355
e414a0b104a6
(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 |
|
e414a0b104a6
(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" |
e414a0b104a6
(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
e414a0b104a6
(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" |
e414a0b104a6
(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" |
e414a0b104a6
(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 */ |
e414a0b104a6
(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 */ |
6453
226bcddeba32
(svn r9609) -Codechange: Move some function prototypes out of functions.h and into landscape.h, and add a few where they didn't exist.
maedhros
parents:
6450
diff
changeset
|
55 |
#include "landscape.h" |
3355
e414a0b104a6
(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 "rail.h" |
e414a0b104a6
(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 "debug.h" |
e414a0b104a6
(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 "tunnel_map.h" |
e414a0b104a6
(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 "road_map.h" |
e414a0b104a6
(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_map.h" |
e414a0b104a6
(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 "bridge.h" |
e414a0b104a6
(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 "rail_map.h" |
e414a0b104a6
(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/sprites.h" |
e414a0b104a6
(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
|
64 |
#include "table/elrail_data.h" |
5116
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
65 |
#include "vehicle.h" |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
66 |
#include "train.h" |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
67 |
#include "gui.h" |
3355
e414a0b104a6
(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 |
|
e414a0b104a6
(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 |
static inline TLG GetTLG(TileIndex t) |
e414a0b104a6
(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 |
{ |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
71 |
return (TLG)((HASBIT(TileX(t), 0) << 1) + HASBIT(TileY(t), 0)); |
3355
e414a0b104a6
(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 |
} |
e414a0b104a6
(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 |
|
e414a0b104a6
(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
|
74 |
/** Finds which Rail Bits are present on a given tile. For bridge tiles, |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
75 |
* returns track bits under the bridge |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
76 |
*/ |
3355
e414a0b104a6
(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 |
static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override) |
e414a0b104a6
(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 |
{ |
e414a0b104a6
(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 |
switch (GetTileType(t)) { |
e414a0b104a6
(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 |
case MP_RAILWAY: |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
81 |
if (GetRailType(t) != RAILTYPE_ELECTRIC) return TRACK_BIT_NONE; |
3355
e414a0b104a6
(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
|
82 |
switch (GetRailTileType(t)) { |
3792
67c865c9315c
(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
|
83 |
case RAIL_TILE_NORMAL: case RAIL_TILE_SIGNALS: |
3355
e414a0b104a6
(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
|
84 |
return GetTrackBits(t); |
6172
e6d7a5b3d63f
(svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents:
6117
diff
changeset
|
85 |
case RAIL_TILE_WAYPOINT: |
e6d7a5b3d63f
(svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents:
6117
diff
changeset
|
86 |
return GetRailWaypointBits(t); |
3355
e414a0b104a6
(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 |
default: |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
88 |
return TRACK_BIT_NONE; |
3355
e414a0b104a6
(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 |
} |
e414a0b104a6
(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
|
90 |
break; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4021
diff
changeset
|
91 |
|
3355
e414a0b104a6
(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
|
92 |
case MP_TUNNELBRIDGE: |
e414a0b104a6
(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
|
93 |
if (IsTunnel(t)) { |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
94 |
if (GetRailType(t) != RAILTYPE_ELECTRIC) return TRACK_BIT_NONE; |
3355
e414a0b104a6
(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
|
95 |
if (override != NULL) *override = 1 << GetTunnelDirection(t); |
4158 | 96 |
return AxisToTrackBits(DiagDirToAxis(GetTunnelDirection(t))); |
3355
e414a0b104a6
(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
|
97 |
} else { |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
98 |
if (GetRailType(t) != RAILTYPE_ELECTRIC) return TRACK_BIT_NONE; |
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
99 |
if (override != NULL && DistanceMax(t, GetOtherBridgeEnd(t)) > 1) { |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
100 |
*override = 1 << GetBridgeRampDirection(t); |
3355
e414a0b104a6
(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
|
101 |
} |
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
102 |
return AxisToTrackBits(DiagDirToAxis(GetBridgeRampDirection(t))); |
3355
e414a0b104a6
(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 |
} |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4021
diff
changeset
|
104 |
|
3355
e414a0b104a6
(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
|
105 |
case MP_STREET: |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
106 |
if (GetRoadTileType(t) != ROAD_TILE_CROSSING) return TRACK_BIT_NONE; |
6172
e6d7a5b3d63f
(svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents:
6117
diff
changeset
|
107 |
if (GetRailType(t) != RAILTYPE_ELECTRIC) return TRACK_BIT_NONE; |
3355
e414a0b104a6
(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 |
return GetCrossingRailBits(t); |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4021
diff
changeset
|
109 |
|
3355
e414a0b104a6
(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 |
case MP_STATION: |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
111 |
if (!IsRailwayStation(t)) return TRACK_BIT_NONE; |
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
112 |
if (GetRailType(t) != RAILTYPE_ELECTRIC) return TRACK_BIT_NONE; |
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
113 |
if (!IsStationTileElectrifiable(t)) return TRACK_BIT_NONE; |
3375
5f3ddc988795
(svn r4177) -Fix: GetRailTrackBitsUniversal needs Trackbits, not Track. While at it, remove an unused variable
celestar
parents:
3368
diff
changeset
|
114 |
return TrackToTrackBits(GetRailStationTrack(t)); |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4021
diff
changeset
|
115 |
|
3355
e414a0b104a6
(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 |
default: |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
117 |
return TRACK_BIT_NONE; |
3355
e414a0b104a6
(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 |
} |
e414a0b104a6
(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
|
119 |
} |
e414a0b104a6
(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
|
120 |
|
3451
0e8ccac68fdf
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
121 |
/** Corrects the tileh for certain tile types. Returns an effective tileh for the track on the tile. |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
122 |
* @param tile The tile to analyse |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
123 |
* @param *tileh the tileh |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
124 |
*/ |
4171 | 125 |
static void AdjustTileh(TileIndex tile, Slope *tileh) |
3451
0e8ccac68fdf
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
126 |
{ |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4021
diff
changeset
|
127 |
if (IsTileType(tile, MP_TUNNELBRIDGE)) { |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4021
diff
changeset
|
128 |
if (IsTunnel(tile)) { |
6269 | 129 |
*tileh = SLOPE_STEEP; // XXX - Hack to make tunnel entrances to always have a pylon |
130 |
} else if (*tileh != SLOPE_FLAT) { |
|
131 |
*tileh = SLOPE_FLAT; |
|
3451
0e8ccac68fdf
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
132 |
} else { |
6269 | 133 |
switch (GetBridgeRampDirection(tile)) { |
134 |
case DIAGDIR_NE: *tileh = SLOPE_NE; break; |
|
135 |
case DIAGDIR_SE: *tileh = SLOPE_SE; break; |
|
136 |
case DIAGDIR_SW: *tileh = SLOPE_SW; break; |
|
137 |
case DIAGDIR_NW: *tileh = SLOPE_NW; break; |
|
138 |
default: NOT_REACHED(); |
|
3451
0e8ccac68fdf
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
139 |
} |
0e8ccac68fdf
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
140 |
} |
0e8ccac68fdf
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
141 |
} |
0e8ccac68fdf
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
142 |
} |
0e8ccac68fdf
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
143 |
|
3355
e414a0b104a6
(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
|
144 |
/** Draws wires and, if required, pylons on a given tile |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
145 |
* @param ti The Tileinfo to draw the tile for |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
146 |
*/ |
3355
e414a0b104a6
(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 |
static void DrawCatenaryRailway(const TileInfo *ti) |
e414a0b104a6
(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
|
148 |
{ |
e414a0b104a6
(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
|
149 |
/* Pylons are placed on a tile edge, so we need to take into account |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
150 |
* the track configuration of 2 adjacent tiles. trackconfig[0] stores the |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
151 |
* current tile (home tile) while [1] holds the neighbour */ |
3355
e414a0b104a6
(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 |
TrackBits trackconfig[TS_END]; |
e414a0b104a6
(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
|
153 |
bool isflat[TS_END]; |
e414a0b104a6
(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 |
/* Note that ti->tileh has already been adjusted for Foundations */ |
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3463
diff
changeset
|
155 |
Slope tileh[TS_END] = { ti->tileh, SLOPE_FLAT }; |
3355
e414a0b104a6
(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 |
|
e414a0b104a6
(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 |
TLG tlg = GetTLG(ti->tile); |
e414a0b104a6
(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
|
158 |
byte PCPstatus = 0; |
e414a0b104a6
(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
|
159 |
byte OverridePCP = 0; |
3395 | 160 |
byte PPPpreferred[DIAGDIR_END]; |
161 |
byte PPPallowed[DIAGDIR_END]; |
|
3355
e414a0b104a6
(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 |
DiagDirection i; |
e414a0b104a6
(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 |
Track t; |
e414a0b104a6
(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
|
164 |
|
e414a0b104a6
(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
|
165 |
/* Find which rail bits are present, and select the override points. |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
166 |
* We don't draw a pylon: |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
167 |
* 1) INSIDE a tunnel (we wouldn't see it anyway) |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
168 |
* 2) on the "far" end of a bridge head (the one that connects to bridge middle), |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
169 |
* because that one is drawn on the bridge. Exception is for length 0 bridges |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
170 |
* which have no middle tiles */ |
3355
e414a0b104a6
(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
|
171 |
trackconfig[TS_HOME] = GetRailTrackBitsUniversal(ti->tile, &OverridePCP); |
e414a0b104a6
(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 |
/* If a track bit is present that is not in the main direction, the track is level */ |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
173 |
isflat[TS_HOME] = ((trackconfig[TS_HOME] & (TRACK_BIT_HORZ | TRACK_BIT_VERT)) != 0); |
3355
e414a0b104a6
(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 |
|
3451
0e8ccac68fdf
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
175 |
AdjustTileh(ti->tile, &tileh[TS_HOME]); |
3355
e414a0b104a6
(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
|
176 |
|
e414a0b104a6
(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 |
for (i = DIAGDIR_NE; i < DIAGDIR_END; i++) { |
4559
aa0c13e39840
(svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents:
4549
diff
changeset
|
178 |
TileIndex neighbour = ti->tile + TileOffsByDiagDir(i); |
3355
e414a0b104a6
(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 |
uint foundation = 0; |
e414a0b104a6
(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 |
int k; |
e414a0b104a6
(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
|
181 |
|
e414a0b104a6
(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 |
/* Here's one of the main headaches. GetTileSlope does not correct for possibly |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
183 |
* existing foundataions, so we do have to do that manually later on.*/ |
3355
e414a0b104a6
(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
|
184 |
tileh[TS_NEIGHBOUR] = GetTileSlope(neighbour, NULL); |
e414a0b104a6
(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
|
185 |
trackconfig[TS_NEIGHBOUR] = GetRailTrackBitsUniversal(neighbour, NULL); |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
186 |
if (IsTunnelTile(neighbour) && i != GetTunnelDirection(neighbour)) trackconfig[TS_NEIGHBOUR] = TRACK_BIT_NONE; |
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
187 |
isflat[TS_NEIGHBOUR] = ((trackconfig[TS_NEIGHBOUR] & (TRACK_BIT_HORZ | TRACK_BIT_VERT)) != 0); |
3355
e414a0b104a6
(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
|
188 |
|
6269 | 189 |
PPPpreferred[i] = 0xFF; // We start with preferring everything (end-of-line in any direction) |
3451
0e8ccac68fdf
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
190 |
PPPallowed[i] = AllowedPPPonPCP[i]; |
0e8ccac68fdf
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
191 |
|
3355
e414a0b104a6
(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
|
192 |
/* We cycle through all the existing tracks at a PCP and see what |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
193 |
* PPPs we want to have, or may not have at all */ |
3451
0e8ccac68fdf
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
194 |
for (k = 0; k < NUM_TRACKS_AT_PCP; k++) { |
3355
e414a0b104a6
(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
|
195 |
/* Next to us, we have a bridge head, don't worry about that one, if it shows away from us */ |
3451
0e8ccac68fdf
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
196 |
if (TrackSourceTile[i][k] == TS_NEIGHBOUR && |
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
197 |
IsBridgeTile(neighbour) && |
4000
4009d092b306
(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 |
GetBridgeRampDirection(neighbour) == ReverseDiagDir(i)) { |
4009d092b306
(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
|
199 |
continue; |
4009d092b306
(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
|
200 |
} |
3355
e414a0b104a6
(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
|
201 |
|
3451
0e8ccac68fdf
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
202 |
/* We check whether the track in question (k) is present in the tile |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
203 |
* (TrackSourceTile) */ |
3451
0e8ccac68fdf
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
204 |
if (HASBIT(trackconfig[TrackSourceTile[i][k]], TracksAtPCP[i][k])) { |
0e8ccac68fdf
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
205 |
/* track found, if track is in the neighbour tile, adjust the number |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
206 |
* of the PCP for preferred/allowed determination*/ |
3451
0e8ccac68fdf
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
207 |
DiagDirection PCPpos = (TrackSourceTile[i][k] == TS_HOME) ? i : ReverseDiagDir(i); |
6269 | 208 |
SETBIT(PCPstatus, i); // This PCP is in use |
3451
0e8ccac68fdf
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
209 |
|
0e8ccac68fdf
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
210 |
PPPpreferred[i] &= PreferredPPPofTrackAtPCP[TracksAtPCP[i][k]][PCPpos]; |
0e8ccac68fdf
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
211 |
PPPallowed[i] &= ~DisallowedPPPofTrackAtPCP[TracksAtPCP[i][k]][PCPpos]; |
3355
e414a0b104a6
(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 |
} |
e414a0b104a6
(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 |
} |
e414a0b104a6
(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 |
|
e414a0b104a6
(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 |
/* Deactivate all PPPs if PCP is not used */ |
e414a0b104a6
(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 |
PPPpreferred[i] *= HASBIT(PCPstatus, i); |
e414a0b104a6
(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
|
217 |
PPPallowed[i] *= HASBIT(PCPstatus, i); |
e414a0b104a6
(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
|
218 |
|
3880
b493c5318c9b
(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
|
219 |
/* A station is always "flat", so adjust the tileh accordingly */ |
b493c5318c9b
(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
|
220 |
if (IsTileType(neighbour, MP_STATION)) tileh[TS_NEIGHBOUR] = SLOPE_FLAT; |
3355
e414a0b104a6
(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
|
221 |
|
e414a0b104a6
(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
|
222 |
/* Read the foundataions if they are present, and adjust the tileh */ |
4448
f19eae76b448
(svn r6226) -Fix(r5864): an assertion was triggered when drawing catenary on steep slopes (TrueLight)
glx
parents:
4182
diff
changeset
|
223 |
if (IsTileType(neighbour, MP_RAILWAY) && GetRailType(neighbour) == RAILTYPE_ELECTRIC) foundation = GetRailFoundation(tileh[TS_NEIGHBOUR], trackconfig[TS_NEIGHBOUR]); |
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
224 |
if (IsBridgeTile(neighbour)) { |
3368
d57156668a59
(svn r4165) -Do not use GetBridgeAxis on bridge ramps (request by Tron)
celestar
parents:
3367
diff
changeset
|
225 |
foundation = GetBridgeFoundation(tileh[TS_NEIGHBOUR], DiagDirToAxis(GetBridgeRampDirection(neighbour))); |
d57156668a59
(svn r4165) -Do not use GetBridgeAxis on bridge ramps (request by Tron)
celestar
parents:
3367
diff
changeset
|
226 |
} |
d57156668a59
(svn r4165) -Do not use GetBridgeAxis on bridge ramps (request by Tron)
celestar
parents:
3367
diff
changeset
|
227 |
|
3355
e414a0b104a6
(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
|
228 |
if (foundation != 0) { |
6269 | 229 |
tileh[TS_NEIGHBOUR] = foundation < 15 ? SLOPE_FLAT : _inclined_tileh[foundation - 15]; |
3355
e414a0b104a6
(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 |
} |
e414a0b104a6
(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 |
|
3451
0e8ccac68fdf
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
232 |
AdjustTileh(neighbour, &tileh[TS_NEIGHBOUR]); |
3355
e414a0b104a6
(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 |
|
e414a0b104a6
(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
|
234 |
/* If we have a straight (and level) track, we want a pylon only every 2 tiles |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
235 |
* Delete the PCP if this is the case. */ |
3355
e414a0b104a6
(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 |
/* Level means that the slope is the same, or the track is flat */ |
e414a0b104a6
(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
|
237 |
if (tileh[TS_HOME] == tileh[TS_NEIGHBOUR] || (isflat[TS_HOME] && isflat[TS_NEIGHBOUR])) { |
e414a0b104a6
(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 |
for (k = 0; k < NUM_IGNORE_GROUPS; k++) |
3451
0e8ccac68fdf
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
239 |
if (PPPpreferred[i] == IgnoredPCP[k][tlg][i]) CLRBIT(PCPstatus, i); |
3355
e414a0b104a6
(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 |
} |
e414a0b104a6
(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
|
241 |
|
3451
0e8ccac68fdf
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
242 |
/* Now decide where we draw our pylons. First try the preferred PPPs, but they may not exist. |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
243 |
* In that case, we try the any of the allowed ones. if they don't exist either, don't draw |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
244 |
* anything. Note that the preferred PPPs still contain the end-of-line markers. |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
245 |
* Remove those (simply by ANDing with allowed, since these markers are never allowed) */ |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4021
diff
changeset
|
246 |
if ((PPPallowed[i] & PPPpreferred[i]) != 0) PPPallowed[i] &= PPPpreferred[i]; |
3355
e414a0b104a6
(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
|
247 |
|
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
248 |
if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile)) { |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
249 |
Track bridgetrack = GetBridgeAxis(ti->tile) == AXIS_X ? TRACK_X : TRACK_Y; |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
250 |
uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile)); |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
251 |
|
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
252 |
if ((height <= TilePixelHeight(ti->tile) + TILE_HEIGHT) && |
6269 | 253 |
(i == PCPpositions[bridgetrack][0] || i == PCPpositions[bridgetrack][1])) { |
254 |
SETBIT(OverridePCP, i); |
|
255 |
} |
|
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
256 |
} |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
257 |
|
3451
0e8ccac68fdf
(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
e414a0b104a6
(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++) { |
e414a0b104a6
(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
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4021
diff
changeset
|
261 |
|
3451
0e8ccac68fdf
(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
e414a0b104a6
(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]; |
e414a0b104a6
(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]; |
e414a0b104a6
(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 |
|
e414a0b104a6
(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 */ |
e414a0b104a6
(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)) { |
e414a0b104a6
(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 */ |
e414a0b104a6
(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; |
e414a0b104a6
(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 */ |
e414a0b104a6
(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 |
} |
e414a0b104a6
(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 |
|
6427
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
273 |
SpriteID img = pylons_normal[temp]; |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
274 |
SpriteID pal = PAL_NONE; |
6450
54f746fcae4a
(svn r9598) -Fix (r9563): brainfart? in elrail transparency. who knows...
peter1138
parents:
6427
diff
changeset
|
275 |
if (HASBIT(_transparent_opt, TO_BUILDINGS)) { |
6427
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
276 |
SETBIT(img, PALETTE_MODIFIER_TRANSPARENT); |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
277 |
pal = PALETTE_TO_TRANSPARENT; |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
278 |
} |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
279 |
|
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
280 |
AddSortableSpriteToDraw(img, pal, x, y, 1, 1, 10, |
3355
e414a0b104a6
(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
|
281 |
GetSlopeZ(ti->x + x_pcp_offsets[i], ti->y + y_pcp_offsets[i])); |
e414a0b104a6
(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
|
282 |
break; /* We already have drawn a pylon, bail out */ |
e414a0b104a6
(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
|
283 |
} |
e414a0b104a6
(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
|
284 |
} |
e414a0b104a6
(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
|
285 |
} |
e414a0b104a6
(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
|
286 |
} |
e414a0b104a6
(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
|
287 |
|
4480
e7d8faa8ba93
(svn r6265) Check whether to draw catenary at all once before the drawing loop instead of on every iteration
tron
parents:
4470
diff
changeset
|
288 |
/* Don't draw a wire under a low bridge */ |
6450
54f746fcae4a
(svn r9598) -Fix (r9563): brainfart? in elrail transparency. who knows...
peter1138
parents:
6427
diff
changeset
|
289 |
if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !HASBIT(_transparent_opt, TO_BUILDINGS)) { |
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
290 |
uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile)); |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
291 |
|
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
292 |
if (height <= TilePixelHeight(ti->tile) + TILE_HEIGHT) return; |
4480
e7d8faa8ba93
(svn r6265) Check whether to draw catenary at all once before the drawing loop instead of on every iteration
tron
parents:
4470
diff
changeset
|
293 |
} |
e7d8faa8ba93
(svn r6265) Check whether to draw catenary at all once before the drawing loop instead of on every iteration
tron
parents:
4470
diff
changeset
|
294 |
|
3355
e414a0b104a6
(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 |
/* Drawing of pylons is finished, now draw the wires */ |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
296 |
for (t = TRACK_BEGIN; t < TRACK_END; t++) { |
3355
e414a0b104a6
(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 |
if (HASBIT(trackconfig[TS_HOME], t)) { |
6268
437cf82d933b
(svn r9077) -Fix [FS#612]: the wrong catenary wires were drawn for tunnel entrances.
rubidium
parents:
6259
diff
changeset
|
298 |
if (IsTunnelTile(ti->tile)) { |
6269 | 299 |
const SortableSpriteStruct *sss = &CatenarySpriteData_Tunnel[GetTunnelDirection(ti->tile)]; |
3355
e414a0b104a6
(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 |
|
6268
437cf82d933b
(svn r9077) -Fix [FS#612]: the wrong catenary wires were drawn for tunnel entrances.
rubidium
parents:
6259
diff
changeset
|
301 |
AddSortableSpriteToDraw( |
437cf82d933b
(svn r9077) -Fix [FS#612]: the wrong catenary wires were drawn for tunnel entrances.
rubidium
parents:
6259
diff
changeset
|
302 |
sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset, |
437cf82d933b
(svn r9077) -Fix [FS#612]: the wrong catenary wires were drawn for tunnel entrances.
rubidium
parents:
6259
diff
changeset
|
303 |
sss->x_size, sss->y_size, sss->z_size, |
437cf82d933b
(svn r9077) -Fix [FS#612]: the wrong catenary wires were drawn for tunnel entrances.
rubidium
parents:
6259
diff
changeset
|
304 |
GetTileZ(ti->tile) + sss->z_offset |
437cf82d933b
(svn r9077) -Fix [FS#612]: the wrong catenary wires were drawn for tunnel entrances.
rubidium
parents:
6259
diff
changeset
|
305 |
); |
437cf82d933b
(svn r9077) -Fix [FS#612]: the wrong catenary wires were drawn for tunnel entrances.
rubidium
parents:
6259
diff
changeset
|
306 |
break; |
437cf82d933b
(svn r9077) -Fix [FS#612]: the wrong catenary wires were drawn for tunnel entrances.
rubidium
parents:
6259
diff
changeset
|
307 |
} |
3355
e414a0b104a6
(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 |
byte PCPconfig = HASBIT(PCPstatus, PCPpositions[t][0]) + |
e414a0b104a6
(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 |
(HASBIT(PCPstatus, PCPpositions[t][1]) << 1); |
e414a0b104a6
(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
|
310 |
|
e414a0b104a6
(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
|
311 |
const SortableSpriteStruct *sss; |
e414a0b104a6
(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
|
312 |
int tileh_selector = !(tileh[TS_HOME] % 3) * tileh[TS_HOME] / 3; /* tileh for the slopes, 0 otherwise */ |
e414a0b104a6
(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
|
313 |
|
e414a0b104a6
(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 |
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
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3463
diff
changeset
|
315 |
assert(!IsSteepSlope(tileh[TS_HOME])); |
3355
e414a0b104a6
(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
|
316 |
sss = &CatenarySpriteData[Wires[tileh_selector][t][PCPconfig]]; |
e414a0b104a6
(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 |
|
6427
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
318 |
SpriteID img = sss->image; |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
319 |
SpriteID pal = PAL_NONE; |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
320 |
if (HASBIT(_transparent_opt, TO_BUILDINGS)) { |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
321 |
SETBIT(img, PALETTE_MODIFIER_TRANSPARENT); |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
322 |
pal = PALETTE_TO_TRANSPARENT; |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
323 |
} |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
324 |
|
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
325 |
AddSortableSpriteToDraw(img, pal, ti->x + sss->x_offset, ti->y + sss->y_offset, |
3645
7f950533d510
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3636
diff
changeset
|
326 |
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
e414a0b104a6
(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 |
} |
e414a0b104a6
(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
|
328 |
} |
e414a0b104a6
(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 |
} |
e414a0b104a6
(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 |
|
e414a0b104a6
(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 |
static void DrawCatenaryOnBridge(const TileInfo *ti) |
e414a0b104a6
(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
|
332 |
{ |
3445
972e0aa84c51
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
333 |
TileIndex end = GetSouthernBridgeEnd(ti->tile); |
972e0aa84c51
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
334 |
TileIndex start = GetOtherBridgeEnd(end); |
972e0aa84c51
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
335 |
|
972e0aa84c51
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
336 |
uint length = GetBridgeLength(start, end); |
3355
e414a0b104a6
(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
|
337 |
uint num = DistanceMax(ti->tile, start); |
4159
fc1d8605596d
(svn r5584) When drawing catenary on a bridge calculate its height only once
tron
parents:
4158
diff
changeset
|
338 |
uint height; |
3445
972e0aa84c51
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
339 |
|
3355
e414a0b104a6
(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 |
const SortableSpriteStruct *sss; |
e414a0b104a6
(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 |
Axis axis = GetBridgeAxis(ti->tile); |
e414a0b104a6
(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
|
342 |
TLG tlg = GetTLG(ti->tile); |
e414a0b104a6
(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 |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
344 |
CatenarySprite offset = (CatenarySprite)(axis == AXIS_X ? 0 : WIRE_Y_FLAT_BOTH - WIRE_X_FLAT_BOTH); |
3355
e414a0b104a6
(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 |
|
e414a0b104a6
(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 |
if ((length % 2) && num == length) { |
3445
972e0aa84c51
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
347 |
/* Draw the "short" wire on the southern end of the bridge |
972e0aa84c51
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
348 |
* only needed if the length of the bridge is odd */ |
3355
e414a0b104a6
(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
|
349 |
sss = &CatenarySpriteData[WIRE_X_FLAT_BOTH + offset]; |
e414a0b104a6
(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 |
} else { |
3445
972e0aa84c51
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
351 |
/* Draw "long" wires on all other tiles of the bridge (one pylon every two tiles) */ |
3355
e414a0b104a6
(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 |
sss = &CatenarySpriteData[WIRE_X_FLAT_SW + (num % 2) + offset]; |
e414a0b104a6
(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
|
353 |
} |
e414a0b104a6
(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 |
|
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
355 |
height = GetBridgeHeight(end); |
4159
fc1d8605596d
(svn r5584) When drawing catenary on a bridge calculate its height only once
tron
parents:
4158
diff
changeset
|
356 |
|
6427
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
357 |
SpriteID img = sss->image; |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
358 |
SpriteID pal = PAL_NONE; |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
359 |
if (HASBIT(_transparent_opt, TO_BUILDINGS)) { |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
360 |
SETBIT(img, PALETTE_MODIFIER_TRANSPARENT); |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
361 |
pal = PALETTE_TO_TRANSPARENT; |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
362 |
} |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
363 |
|
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
364 |
AddSortableSpriteToDraw(img, pal, ti->x + sss->x_offset, ti->y + sss->y_offset, |
4159
fc1d8605596d
(svn r5584) When drawing catenary on a bridge calculate its height only once
tron
parents:
4158
diff
changeset
|
365 |
sss->x_size, sss->y_size, sss->z_size, height + sss->z_offset |
fc1d8605596d
(svn r5584) When drawing catenary on a bridge calculate its height only once
tron
parents:
4158
diff
changeset
|
366 |
); |
3445
972e0aa84c51
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
367 |
|
972e0aa84c51
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
368 |
/* Finished with wires, draw pylons */ |
972e0aa84c51
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
369 |
/* every other tile needs a pylon on the northern end */ |
3355
e414a0b104a6
(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 |
if (num % 2) { |
e414a0b104a6
(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
|
371 |
if (axis == AXIS_X) { |
6427
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
372 |
img = pylons_bridge[0 + HASBIT(tlg, 0)]; |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
373 |
if (HASBIT(_transparent_opt, TO_BUILDINGS)) SETBIT(img, PALETTE_MODIFIER_TRANSPARENT); |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
374 |
AddSortableSpriteToDraw(img, pal, ti->x, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, height); |
3355
e414a0b104a6
(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
|
375 |
} else { |
6427
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
376 |
img = pylons_bridge[2 + HASBIT(tlg, 1)]; |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
377 |
if (HASBIT(_transparent_opt, TO_BUILDINGS)) SETBIT(img, PALETTE_MODIFIER_TRANSPARENT); |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
378 |
AddSortableSpriteToDraw(img, pal, ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y, 1, 1, 10, height); |
3355
e414a0b104a6
(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 |
} |
e414a0b104a6
(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 |
} |
e414a0b104a6
(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
|
381 |
|
3445
972e0aa84c51
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
382 |
/* need a pylon on the southern end of the bridge */ |
972e0aa84c51
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
383 |
if (DistanceMax(ti->tile, start) == length) { |
3355
e414a0b104a6
(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
|
384 |
if (axis == AXIS_X) { |
6427
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
385 |
img = pylons_bridge[0 + HASBIT(tlg, 0)]; |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
386 |
if (HASBIT(_transparent_opt, TO_BUILDINGS)) SETBIT(img, PALETTE_MODIFIER_TRANSPARENT); |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
387 |
AddSortableSpriteToDraw(img, pal, ti->x + 16, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, height); |
3355
e414a0b104a6
(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
|
388 |
} else { |
6427
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
389 |
img = pylons_bridge[2 + HASBIT(tlg, 1)]; |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
390 |
if (HASBIT(_transparent_opt, TO_BUILDINGS)) SETBIT(img, PALETTE_MODIFIER_TRANSPARENT); |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
391 |
AddSortableSpriteToDraw(img, pal, ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y + 16, 1, 1, 10, height); |
3355
e414a0b104a6
(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 |
} |
e414a0b104a6
(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
|
393 |
} |
e414a0b104a6
(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
|
394 |
} |
e414a0b104a6
(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
|
395 |
|
e414a0b104a6
(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
|
396 |
void DrawCatenary(const TileInfo *ti) |
e414a0b104a6
(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
|
397 |
{ |
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
398 |
if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile)) { |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
399 |
TileIndex head = GetNorthernBridgeEnd(ti->tile); |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
400 |
|
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
401 |
if (GetBridgeTransportType(head) == TRANSPORT_RAIL && GetRailType(head) == RAILTYPE_ELECTRIC) { |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
402 |
DrawCatenaryOnBridge(ti); |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
403 |
} |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
404 |
} |
5116
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
405 |
if (_patches.disable_elrails) return; |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
406 |
|
3355
e414a0b104a6
(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
|
407 |
switch (GetTileType(ti->tile)) { |
e414a0b104a6
(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
|
408 |
case MP_RAILWAY: |
6269 | 409 |
if (IsRailDepot(ti->tile)) { |
410 |
const SortableSpriteStruct *sss = &CatenarySpriteData_Depot[GetRailDepotDirection(ti->tile)]; |
|
4470 | 411 |
|
6427
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
412 |
SpriteID img = sss->image; |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
413 |
SpriteID pal = PAL_NONE; |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
414 |
if (HASBIT(_transparent_opt, TO_BUILDINGS)) { |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
415 |
SETBIT(img, PALETTE_MODIFIER_TRANSPARENT); |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
416 |
pal = PALETTE_TO_TRANSPARENT; |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
417 |
} |
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
418 |
|
4470 | 419 |
AddSortableSpriteToDraw( |
6427
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6269
diff
changeset
|
420 |
img, pal, ti->x + sss->x_offset, ti->y + sss->y_offset, |
4470 | 421 |
sss->x_size, sss->y_size, sss->z_size, |
422 |
GetTileMaxZ(ti->tile) + sss->z_offset |
|
423 |
); |
|
3355
e414a0b104a6
(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
|
424 |
return; |
e414a0b104a6
(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
|
425 |
} |
3995
2b86d5a99f0f
(svn r5198) Fix some strange control flow: the case for MP_RAILWAY fell through the case for MP_TUNNELBRIDGE
tron
parents:
3977
diff
changeset
|
426 |
break; |
2b86d5a99f0f
(svn r5198) Fix some strange control flow: the case for MP_RAILWAY fell through the case for MP_TUNNELBRIDGE
tron
parents:
3977
diff
changeset
|
427 |
|
3355
e414a0b104a6
(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
|
428 |
case MP_TUNNELBRIDGE: |
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
429 |
case MP_STREET: |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
430 |
case MP_STATION: |
3355
e414a0b104a6
(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
|
431 |
break; |
3995
2b86d5a99f0f
(svn r5198) Fix some strange control flow: the case for MP_RAILWAY fell through the case for MP_TUNNELBRIDGE
tron
parents:
3977
diff
changeset
|
432 |
|
2b86d5a99f0f
(svn r5198) Fix some strange control flow: the case for MP_RAILWAY fell through the case for MP_TUNNELBRIDGE
tron
parents:
3977
diff
changeset
|
433 |
default: return; |
3355
e414a0b104a6
(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
|
434 |
} |
3995
2b86d5a99f0f
(svn r5198) Fix some strange control flow: the case for MP_RAILWAY fell through the case for MP_TUNNELBRIDGE
tron
parents:
3977
diff
changeset
|
435 |
DrawCatenaryRailway(ti); |
3355
e414a0b104a6
(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
|
436 |
} |
5116
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
437 |
|
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
438 |
int32 SettingsDisableElrail(int32 p1) |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
439 |
{ |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
440 |
EngineID e_id; |
6269 | 441 |
Vehicle *v; |
5116
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
442 |
Player *p; |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
443 |
bool disable = (p1 != 0); |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
444 |
|
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
445 |
/* we will now walk through all electric train engines and change their railtypes if it is the wrong one*/ |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
446 |
const RailType old_railtype = disable ? RAILTYPE_ELECTRIC : RAILTYPE_RAIL; |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
447 |
const RailType new_railtype = disable ? RAILTYPE_RAIL : RAILTYPE_ELECTRIC; |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
448 |
|
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
449 |
/* walk through all train engines */ |
5314
fda2b099eec5
(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
|
450 |
for (e_id = 0; e_id < NUM_TRAIN_ENGINES; e_id++) { |
5823 | 451 |
RailVehicleInfo *rv_info = &_rail_vehicle_info[e_id]; |
5116
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
452 |
/* if it is an electric rail engine and its railtype is the wrong one */ |
5823 | 453 |
if (rv_info->engclass == 2 && rv_info->railtype == old_railtype) { |
5116
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
454 |
/* change it to the proper one */ |
5823 | 455 |
rv_info->railtype = new_railtype; |
5116
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
456 |
} |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
457 |
} |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
458 |
|
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
459 |
/* when disabling elrails, make sure that all existing trains can run on |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
460 |
* normal rail too */ |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
461 |
if (disable) { |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
462 |
FOR_ALL_VEHICLES(v) { |
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6172
diff
changeset
|
463 |
if (v->type == VEH_TRAIN && v->u.rail.railtype == RAILTYPE_ELECTRIC) { |
5116
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
464 |
/* this railroad vehicle is now compatible only with elrail, |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
465 |
* so add there also normal rail compatibility */ |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
466 |
v->u.rail.compatible_railtypes |= (1 << RAILTYPE_RAIL); |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
467 |
v->u.rail.railtype = RAILTYPE_RAIL; |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
468 |
SETBIT(v->u.rail.flags, VRF_EL_ENGINE_ALLOWED_NORMAL_RAIL); |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
469 |
} |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
470 |
} |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
471 |
} |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
472 |
|
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
473 |
/* setup total power for trains */ |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
474 |
FOR_ALL_VEHICLES(v) { |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
475 |
/* power is cached only for front engines */ |
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6172
diff
changeset
|
476 |
if (v->type == VEH_TRAIN && IsFrontEngine(v)) TrainPowerChanged(v); |
5116
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
477 |
} |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
478 |
|
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
479 |
FOR_ALL_PLAYERS(p) p->avail_railtypes = GetPlayerRailtypes(p->index); |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
480 |
|
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
481 |
/* This resets the _last_built_railtype, which will be invalid for electric |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
482 |
* rails. It may have unintended consequences if that function is ever |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
483 |
* extended, though. */ |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
484 |
ReinitGuiAfterToggleElrail(disable); |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
485 |
return 0; |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
486 |
} |