author | rubidium |
Wed, 07 May 2008 21:45:27 +0000 | |
changeset 10457 | ea18877d8eba |
parent 10429 | 1b99254f9607 |
child 10473 | ad730880e443 |
permissions | -rw-r--r-- |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
1 |
/* $Id$ */ |
10429
1b99254f9607
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
10382
diff
changeset
|
2 |
|
6443
b8f06d8eb7be
(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:
6074
diff
changeset
|
3 |
/** @file elrail.cpp |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
4 |
* This file deals with displaying wires and pylons for electric railways. |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
5 |
* <h2>Basics</h2> |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
6 |
* |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
7 |
* <h3>Tile Types</h3> |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
8 |
* |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
9 |
* We have two different types of tiles in the drawing code: |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
10 |
* Normal Railway Tiles (NRTs) which can have more than one track on it, and |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
11 |
* Special Railways tiles (SRTs) which have only one track (like crossings, depots |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
12 |
* stations, etc). |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
13 |
* |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
14 |
* <h3>Location Categories</h3> |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
15 |
* |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
16 |
* All tiles are categorized into three location groups (TLG): |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
17 |
* Group 0: Tiles with both an even X coordinate and an even Y coordinate |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
18 |
* Group 1: Tiles with an even X and an odd Y coordinate |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
19 |
* Group 2: Tiles with an odd X and an even Y coordinate |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
20 |
* Group 3: Tiles with both an odd X and Y coordnate. |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
21 |
* |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
22 |
* <h3>Pylon Points</h3> |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
23 |
* <h4>Control Points</h4> |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
24 |
* A Pylon Control Point (PCP) is a position where a wire (or rather two) |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
25 |
* is mounted onto a pylon. |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
26 |
* Each NRT does contain 4 PCPs which are bitmapped to a byte |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
27 |
* variable and are represented by the DiagDirection enum |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
28 |
* |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
29 |
* Each track ends on two PCPs and thus requires one pylon on each end. However, |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
30 |
* there is one exception: Straight-and-level tracks only have one pylon every |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
31 |
* other tile. |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
32 |
* |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
33 |
* Now on each edge there are two PCPs: One from each adjacent tile. Both PCPs |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
34 |
* are merged using an OR operation (i. e. if one tile needs a PCP at the postion |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
35 |
* in question, both tiles get it). |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
36 |
* |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
37 |
* <h4>Position Points</h4> |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
38 |
* A Pylon Position Point (PPP) is a position where a pylon is located on the |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
39 |
* ground. Each PCP owns 8 in (45 degree steps) PPPs that are located around |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
40 |
* it. PPPs are represented using the Direction enum. Each track bit has PPPs |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
41 |
* that are impossible (because the pylon would be situated on the track) and |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
42 |
* some that are preferred (because the pylon would be rectangular to the track). |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
43 |
* |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
44 |
* <img src="../../elrail_tile.png"> |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
45 |
* <img src="../../elrail_track.png"> |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
46 |
* |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
47 |
*/ |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
48 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
49 |
#include "stdafx.h" |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
50 |
#include "openttd.h" |
3367 | 51 |
#include "station_map.h" |
8720
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
52 |
#include "viewport_func.h" |
8766
c86cfa3a7580
(svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents:
8760
diff
changeset
|
53 |
#include "settings_type.h" |
6949
72d11a1e1e60
(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:
6946
diff
changeset
|
54 |
#include "landscape.h" |
8599
b609cdeeff3f
(svn r11664) -Codechange: use more specific ("rail_type.h" instead of "rail.h" that includes way more than only "rail_type.h") includes at some places.
rubidium
parents:
8584
diff
changeset
|
55 |
#include "rail_type.h" |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
56 |
#include "debug.h" |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
57 |
#include "tunnel_map.h" |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
58 |
#include "road_map.h" |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
59 |
#include "bridge_map.h" |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
60 |
#include "bridge.h" |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
61 |
#include "rail_map.h" |
5116
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
62 |
#include "train.h" |
8607
d16299e657ba
(svn r11672) -Codechange: refactor some stuff out of gui.h.
rubidium
parents:
8604
diff
changeset
|
63 |
#include "rail_gui.h" |
8345
6caa3fdb972c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
8260
diff
changeset
|
64 |
#include "transparency.h" |
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8427
diff
changeset
|
65 |
#include "tunnelbridge_map.h" |
8640
1e93b81e96d2
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents:
8627
diff
changeset
|
66 |
#include "vehicle_func.h" |
8750
fdd6054e7bae
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8733
diff
changeset
|
67 |
#include "player_base.h" |
8894
1e5b2d4380b8
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz
parents:
8766
diff
changeset
|
68 |
#include "tunnelbridge.h" |
9282
2bb9703aeb39
(svn r12490) -Codechange: rename engine.h to engine_func.h and remove unneeded inclusions of engine.h and/or replace them with engine_type.h.
rubidium
parents:
9228
diff
changeset
|
69 |
#include "engine_func.h" |
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10313
diff
changeset
|
70 |
#include "engine_base.h" |
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8427
diff
changeset
|
71 |
|
8760
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
72 |
#include "table/sprites.h" |
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
73 |
#include "table/elrail_data.h" |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
74 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
75 |
static inline TLG GetTLG(TileIndex t) |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
76 |
{ |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8345
diff
changeset
|
77 |
return (TLG)((HasBit(TileX(t), 0) << 1) + HasBit(TileY(t), 0)); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
78 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
79 |
|
8895
2334ae41b76e
(svn r11969) -Codechange: documentation update, there are no 'track bits under bridge' anymore
smatz
parents:
8894
diff
changeset
|
80 |
/** |
2334ae41b76e
(svn r11969) -Codechange: documentation update, there are no 'track bits under bridge' anymore
smatz
parents:
8894
diff
changeset
|
81 |
* Finds which Electrified Rail Bits are present on a given tile. |
2334ae41b76e
(svn r11969) -Codechange: documentation update, there are no 'track bits under bridge' anymore
smatz
parents:
8894
diff
changeset
|
82 |
* @param t tile to check |
2334ae41b76e
(svn r11969) -Codechange: documentation update, there are no 'track bits under bridge' anymore
smatz
parents:
8894
diff
changeset
|
83 |
* @param override pointer to PCP override, can be NULL |
2334ae41b76e
(svn r11969) -Codechange: documentation update, there are no 'track bits under bridge' anymore
smatz
parents:
8894
diff
changeset
|
84 |
* @return trackbits of tile if it is electrified |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
85 |
*/ |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
86 |
static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override) |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
87 |
{ |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
88 |
switch (GetTileType(t)) { |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
89 |
case MP_RAILWAY: |
9228
e7f3b7bf239a
(svn r12410) -Codechange: abstract out the test for catenary on electric rails
peter1138
parents:
9059
diff
changeset
|
90 |
if (!HasCatenary(GetRailType(t))) return TRACK_BIT_NONE; |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
91 |
switch (GetRailTileType(t)) { |
3792
2eb8388731bf
(svn r4788) - Codechange: RAILTYPE_{NORMAL,ELECTRIC,...} and RAIL_TYPE_{NORMAL,SIGNAL,...} have nearly the same name, rename RAIL_TYPE_* to RAIL_TILE_* of extra clarity
rubidium
parents:
3789
diff
changeset
|
92 |
case RAIL_TILE_NORMAL: case RAIL_TILE_SIGNALS: |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
93 |
return GetTrackBits(t); |
6498
aff910a05c6e
(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:
6443
diff
changeset
|
94 |
case RAIL_TILE_WAYPOINT: |
aff910a05c6e
(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:
6443
diff
changeset
|
95 |
return GetRailWaypointBits(t); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
96 |
default: |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
97 |
return TRACK_BIT_NONE; |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
98 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
99 |
break; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4021
diff
changeset
|
100 |
|
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
101 |
case MP_TUNNELBRIDGE: |
9228
e7f3b7bf239a
(svn r12410) -Codechange: abstract out the test for catenary on electric rails
peter1138
parents:
9059
diff
changeset
|
102 |
if (!HasCatenary(GetRailType(t))) return TRACK_BIT_NONE; |
8895
2334ae41b76e
(svn r11969) -Codechange: documentation update, there are no 'track bits under bridge' anymore
smatz
parents:
8894
diff
changeset
|
103 |
if (override != NULL && (IsTunnel(t) || GetTunnelBridgeLength(t, GetOtherBridgeEnd(t)) > 0)) { |
8584
a8b6dffead63
(svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz
parents:
8579
diff
changeset
|
104 |
*override = 1 << GetTunnelBridgeDirection(t); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
105 |
} |
8584
a8b6dffead63
(svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz
parents:
8579
diff
changeset
|
106 |
return AxisToTrackBits(DiagDirToAxis(GetTunnelBridgeDirection(t))); |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4021
diff
changeset
|
107 |
|
7866
e19fda04e8d3
(svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium
parents:
7831
diff
changeset
|
108 |
case MP_ROAD: |
9059
04edde3eb0c6
(svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch
parents:
9024
diff
changeset
|
109 |
if (!IsLevelCrossing(t)) return TRACK_BIT_NONE; |
9228
e7f3b7bf239a
(svn r12410) -Codechange: abstract out the test for catenary on electric rails
peter1138
parents:
9059
diff
changeset
|
110 |
if (!HasCatenary(GetRailType(t))) return TRACK_BIT_NONE; |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
111 |
return GetCrossingRailBits(t); |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4021
diff
changeset
|
112 |
|
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
113 |
case MP_STATION: |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
114 |
if (!IsRailwayStation(t)) return TRACK_BIT_NONE; |
9228
e7f3b7bf239a
(svn r12410) -Codechange: abstract out the test for catenary on electric rails
peter1138
parents:
9059
diff
changeset
|
115 |
if (!HasCatenary(GetRailType(t))) return TRACK_BIT_NONE; |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
116 |
if (!IsStationTileElectrifiable(t)) return TRACK_BIT_NONE; |
3375
7fea43d72298
(svn r4177) -Fix: GetRailTrackBitsUniversal needs Trackbits, not Track. While at it, remove an unused variable
celestar
parents:
3368
diff
changeset
|
117 |
return TrackToTrackBits(GetRailStationTrack(t)); |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4021
diff
changeset
|
118 |
|
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
119 |
default: |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
120 |
return TRACK_BIT_NONE; |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
121 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
122 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
123 |
|
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
124 |
/** Corrects the tileh for certain tile types. Returns an effective tileh for the track on the tile. |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
125 |
* @param tile The tile to analyse |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
126 |
* @param *tileh the tileh |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
127 |
*/ |
4171 | 128 |
static void AdjustTileh(TileIndex tile, Slope *tileh) |
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
129 |
{ |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4021
diff
changeset
|
130 |
if (IsTileType(tile, MP_TUNNELBRIDGE)) { |
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4021
diff
changeset
|
131 |
if (IsTunnel(tile)) { |
6595 | 132 |
*tileh = SLOPE_STEEP; // XXX - Hack to make tunnel entrances to always have a pylon |
133 |
} else if (*tileh != SLOPE_FLAT) { |
|
134 |
*tileh = SLOPE_FLAT; |
|
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
135 |
} else { |
8909
fa15e9afad2f
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8897
diff
changeset
|
136 |
*tileh = InclinedSlope(GetTunnelBridgeDirection(tile)); |
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
137 |
} |
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
138 |
} |
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
139 |
} |
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
140 |
|
8030
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
141 |
/** |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
142 |
* Returns the Z position of a Pylon Control Point. |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
143 |
* |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
144 |
* @param tile The tile the pylon should stand on. |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
145 |
* @param PCPpos The PCP of the tile. |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
146 |
* @return The Z position of the PCP. |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
147 |
*/ |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
148 |
static byte GetPCPElevation(TileIndex tile, DiagDirection PCPpos) |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
149 |
{ |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
150 |
/* The elevation of the "pylon"-sprite should be the elevation at the PCP. |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
151 |
* PCPs are always on a tile edge. |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
152 |
* |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
153 |
* This position can be outside of the tile, i.e. ?_pcp_offset == TILE_SIZE > TILE_SIZE - 1. |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
154 |
* So we have to move it inside the tile, because if the neighboured tile has a foundation, |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
155 |
* that does not smoothly connect to the current tile, we will get a wrong elevation from GetSlopeZ(). |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
156 |
* |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
157 |
* When we move the position inside the tile, we will get a wrong elevation if we have a slope. |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
158 |
* To catch all cases we round the Z position to the next (TILE_HEIGHT / 2). |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
159 |
* This will return the correct elevation for slopes and will also detect non-continuous elevation on edges. |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
160 |
* |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
161 |
* Also note that the result of GetSlopeZ() is very special on bridge-ramps. |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
162 |
*/ |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
163 |
|
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
164 |
byte z = GetSlopeZ(TileX(tile) * TILE_SIZE + min(x_pcp_offsets[PCPpos], TILE_SIZE - 1), TileY(tile) * TILE_SIZE + min(y_pcp_offsets[PCPpos], TILE_SIZE - 1)); |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
165 |
return (z + 2) & ~3; // this means z = (z + TILE_HEIGHT / 4) / (TILE_HEIGHT / 2) * (TILE_HEIGHT / 2); |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
166 |
} |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
167 |
|
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
168 |
/** |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
169 |
* Draws wires on a tunnel tile |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
170 |
* |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
171 |
* DrawTile_TunnelBridge() calls this function to draw the wires as SpriteCombine with the tunnel roof. |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
172 |
* |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
173 |
* @param ti The Tileinfo to draw the tile for |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
174 |
*/ |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
175 |
void DrawCatenaryOnTunnel(const TileInfo *ti) |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
176 |
{ |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
177 |
/* xmin, ymin, xmax + 1, ymax + 1 of BB */ |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
178 |
static const int _tunnel_wire_BB[4][4] = { |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
179 |
{ 0, 1, 16, 15 }, // NE |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
180 |
{ 1, 0, 15, 16 }, // SE |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
181 |
{ 0, 1, 16, 15 }, // SW |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
182 |
{ 1, 0, 15, 16 }, // NW |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
183 |
}; |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
184 |
|
9228
e7f3b7bf239a
(svn r12410) -Codechange: abstract out the test for catenary on electric rails
peter1138
parents:
9059
diff
changeset
|
185 |
if (!HasCatenary(GetRailType(ti->tile)) || _patches.disable_elrails) return; |
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
186 |
|
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8427
diff
changeset
|
187 |
DiagDirection dir = GetTunnelBridgeDirection(ti->tile); |
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
188 |
|
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
189 |
const SortableSpriteStruct *sss = &CatenarySpriteData_Tunnel[dir]; |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
190 |
const int *BB_data = _tunnel_wire_BB[dir]; |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
191 |
AddSortableSpriteToDraw( |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
192 |
sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset, |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
193 |
BB_data[2] - sss->x_offset, BB_data[3] - sss->y_offset, BB_Z_SEPARATOR - sss->z_offset + 1, |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
194 |
GetTileZ(ti->tile) + sss->z_offset, |
9024
85bc26dd4935
(svn r12103) -Feature(tte): separate catenary transparency settings from building transparency settings
smatz
parents:
8909
diff
changeset
|
195 |
IsTransparencySet(TO_CATENARY), |
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
196 |
BB_data[0] - sss->x_offset, BB_data[1] - sss->y_offset, BB_Z_SEPARATOR - sss->z_offset |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
197 |
); |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
198 |
} |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
199 |
|
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
200 |
/** Draws wires and, if required, pylons on a given tile |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
201 |
* @param ti The Tileinfo to draw the tile for |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
202 |
*/ |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
203 |
static void DrawCatenaryRailway(const TileInfo *ti) |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
204 |
{ |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
205 |
/* Pylons are placed on a tile edge, so we need to take into account |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
206 |
* the track configuration of 2 adjacent tiles. trackconfig[0] stores the |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
207 |
* current tile (home tile) while [1] holds the neighbour */ |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
208 |
TrackBits trackconfig[TS_END]; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
209 |
bool isflat[TS_END]; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
210 |
/* Note that ti->tileh has already been adjusted for Foundations */ |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3463
diff
changeset
|
211 |
Slope tileh[TS_END] = { ti->tileh, SLOPE_FLAT }; |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
212 |
|
8260
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8097
diff
changeset
|
213 |
/* Half tile slopes coincide only with horizontal/vertical track. |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8097
diff
changeset
|
214 |
* Faking a flat slope results in the correct sprites on positions. */ |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8097
diff
changeset
|
215 |
if (IsHalftileSlope(tileh[TS_HOME])) tileh[TS_HOME] = SLOPE_FLAT; |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8097
diff
changeset
|
216 |
|
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
217 |
TLG tlg = GetTLG(ti->tile); |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
218 |
byte PCPstatus = 0; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
219 |
byte OverridePCP = 0; |
3395 | 220 |
byte PPPpreferred[DIAGDIR_END]; |
221 |
byte PPPallowed[DIAGDIR_END]; |
|
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
222 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
223 |
/* Find which rail bits are present, and select the override points. |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
224 |
* We don't draw a pylon: |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
225 |
* 1) INSIDE a tunnel (we wouldn't see it anyway) |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
226 |
* 2) on the "far" end of a bridge head (the one that connects to bridge middle), |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
227 |
* because that one is drawn on the bridge. Exception is for length 0 bridges |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
228 |
* which have no middle tiles */ |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
229 |
trackconfig[TS_HOME] = GetRailTrackBitsUniversal(ti->tile, &OverridePCP); |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
230 |
/* If a track bit is present that is not in the main direction, the track is level */ |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
231 |
isflat[TS_HOME] = ((trackconfig[TS_HOME] & (TRACK_BIT_HORZ | TRACK_BIT_VERT)) != 0); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
232 |
|
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
233 |
AdjustTileh(ti->tile, &tileh[TS_HOME]); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
234 |
|
10313
53b9d5708068
(svn r12854) -Codechange: make drawing of rail catenary a bit faster
smatz
parents:
10312
diff
changeset
|
235 |
for (DiagDirection i = DIAGDIR_NE; i < DIAGDIR_END; i++) { |
4559
c853d2440065
(svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents:
4549
diff
changeset
|
236 |
TileIndex neighbour = ti->tile + TileOffsByDiagDir(i); |
7831
5dded9b03500
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7829
diff
changeset
|
237 |
Foundation foundation = FOUNDATION_NONE; |
10313
53b9d5708068
(svn r12854) -Codechange: make drawing of rail catenary a bit faster
smatz
parents:
10312
diff
changeset
|
238 |
byte elevation = GetPCPElevation(ti->tile, i); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
239 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
240 |
/* Here's one of the main headaches. GetTileSlope does not correct for possibly |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
241 |
* existing foundataions, so we do have to do that manually later on.*/ |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
242 |
tileh[TS_NEIGHBOUR] = GetTileSlope(neighbour, NULL); |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
243 |
trackconfig[TS_NEIGHBOUR] = GetRailTrackBitsUniversal(neighbour, NULL); |
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8427
diff
changeset
|
244 |
if (IsTunnelTile(neighbour) && i != GetTunnelBridgeDirection(neighbour)) trackconfig[TS_NEIGHBOUR] = TRACK_BIT_NONE; |
8030
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
245 |
|
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
246 |
/* If the neighboured tile does not smoothly connect to the current tile (because of a foundation), |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
247 |
* we have to draw all pillars on the current tile. */ |
10313
53b9d5708068
(svn r12854) -Codechange: make drawing of rail catenary a bit faster
smatz
parents:
10312
diff
changeset
|
248 |
if (elevation != GetPCPElevation(neighbour, ReverseDiagDir(i))) trackconfig[TS_NEIGHBOUR] = TRACK_BIT_NONE; |
8030
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
249 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
250 |
isflat[TS_NEIGHBOUR] = ((trackconfig[TS_NEIGHBOUR] & (TRACK_BIT_HORZ | TRACK_BIT_VERT)) != 0); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
251 |
|
6595 | 252 |
PPPpreferred[i] = 0xFF; // We start with preferring everything (end-of-line in any direction) |
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
253 |
PPPallowed[i] = AllowedPPPonPCP[i]; |
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
254 |
|
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
255 |
/* We cycle through all the existing tracks at a PCP and see what |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
256 |
* PPPs we want to have, or may not have at all */ |
10313
53b9d5708068
(svn r12854) -Codechange: make drawing of rail catenary a bit faster
smatz
parents:
10312
diff
changeset
|
257 |
for (uint k = 0; k < NUM_TRACKS_AT_PCP; k++) { |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
258 |
/* Next to us, we have a bridge head, don't worry about that one, if it shows away from us */ |
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
259 |
if (TrackSourceTile[i][k] == TS_NEIGHBOUR && |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
260 |
IsBridgeTile(neighbour) && |
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8427
diff
changeset
|
261 |
GetTunnelBridgeDirection(neighbour) == ReverseDiagDir(i)) { |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3995
diff
changeset
|
262 |
continue; |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3995
diff
changeset
|
263 |
} |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
264 |
|
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
265 |
/* We check whether the track in question (k) is present in the tile |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
266 |
* (TrackSourceTile) */ |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8345
diff
changeset
|
267 |
if (HasBit(trackconfig[TrackSourceTile[i][k]], TracksAtPCP[i][k])) { |
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
268 |
/* track found, if track is in the neighbour tile, adjust the number |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
269 |
* of the PCP for preferred/allowed determination*/ |
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
270 |
DiagDirection PCPpos = (TrackSourceTile[i][k] == TS_HOME) ? i : ReverseDiagDir(i); |
8427
143b0be22af1
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents:
8425
diff
changeset
|
271 |
SetBit(PCPstatus, i); // This PCP is in use |
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
272 |
|
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
273 |
PPPpreferred[i] &= PreferredPPPofTrackAtPCP[TracksAtPCP[i][k]][PCPpos]; |
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
274 |
PPPallowed[i] &= ~DisallowedPPPofTrackAtPCP[TracksAtPCP[i][k]][PCPpos]; |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
275 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
276 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
277 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
278 |
/* Deactivate all PPPs if PCP is not used */ |
10313
53b9d5708068
(svn r12854) -Codechange: make drawing of rail catenary a bit faster
smatz
parents:
10312
diff
changeset
|
279 |
if (!HasBit(PCPstatus, i)) { |
53b9d5708068
(svn r12854) -Codechange: make drawing of rail catenary a bit faster
smatz
parents:
10312
diff
changeset
|
280 |
PPPpreferred[i] = 0; |
53b9d5708068
(svn r12854) -Codechange: make drawing of rail catenary a bit faster
smatz
parents:
10312
diff
changeset
|
281 |
PPPallowed[i] = 0; |
53b9d5708068
(svn r12854) -Codechange: make drawing of rail catenary a bit faster
smatz
parents:
10312
diff
changeset
|
282 |
} |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
283 |
|
3880
cde142e509ec
(svn r4934) -Fix: Correct a misleading comment, and remove an unneeded condition from the corresponding if (thans Tron for pointing it out)
celestar
parents:
3793
diff
changeset
|
284 |
/* A station is always "flat", so adjust the tileh accordingly */ |
cde142e509ec
(svn r4934) -Fix: Correct a misleading comment, and remove an unneeded condition from the corresponding if (thans Tron for pointing it out)
celestar
parents:
3793
diff
changeset
|
285 |
if (IsTileType(neighbour, MP_STATION)) tileh[TS_NEIGHBOUR] = SLOPE_FLAT; |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
286 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
287 |
/* Read the foundataions if they are present, and adjust the tileh */ |
9228
e7f3b7bf239a
(svn r12410) -Codechange: abstract out the test for catenary on electric rails
peter1138
parents:
9059
diff
changeset
|
288 |
if (trackconfig[TS_NEIGHBOUR] != TRACK_BIT_NONE && IsTileType(neighbour, MP_RAILWAY) && HasCatenary(GetRailType(neighbour))) foundation = GetRailFoundation(tileh[TS_NEIGHBOUR], trackconfig[TS_NEIGHBOUR]); |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
289 |
if (IsBridgeTile(neighbour)) { |
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8427
diff
changeset
|
290 |
foundation = GetBridgeFoundation(tileh[TS_NEIGHBOUR], DiagDirToAxis(GetTunnelBridgeDirection(neighbour))); |
3368
57034dcd7978
(svn r4165) -Do not use GetBridgeAxis on bridge ramps (request by Tron)
celestar
parents:
3367
diff
changeset
|
291 |
} |
57034dcd7978
(svn r4165) -Do not use GetBridgeAxis on bridge ramps (request by Tron)
celestar
parents:
3367
diff
changeset
|
292 |
|
7831
5dded9b03500
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7829
diff
changeset
|
293 |
ApplyFoundationToSlope(foundation, &tileh[TS_NEIGHBOUR]); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
294 |
|
10313
53b9d5708068
(svn r12854) -Codechange: make drawing of rail catenary a bit faster
smatz
parents:
10312
diff
changeset
|
295 |
/* Half tile slopes coincide only with horizontal/vertical track. |
53b9d5708068
(svn r12854) -Codechange: make drawing of rail catenary a bit faster
smatz
parents:
10312
diff
changeset
|
296 |
* Faking a flat slope results in the correct sprites on positions. */ |
8260
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8097
diff
changeset
|
297 |
if (IsHalftileSlope(tileh[TS_NEIGHBOUR])) tileh[TS_NEIGHBOUR] = SLOPE_FLAT; |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8097
diff
changeset
|
298 |
|
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
299 |
AdjustTileh(neighbour, &tileh[TS_NEIGHBOUR]); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
300 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
301 |
/* If we have a straight (and level) track, we want a pylon only every 2 tiles |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
302 |
* Delete the PCP if this is the case. */ |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
303 |
/* Level means that the slope is the same, or the track is flat */ |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
304 |
if (tileh[TS_HOME] == tileh[TS_NEIGHBOUR] || (isflat[TS_HOME] && isflat[TS_NEIGHBOUR])) { |
10313
53b9d5708068
(svn r12854) -Codechange: make drawing of rail catenary a bit faster
smatz
parents:
10312
diff
changeset
|
305 |
for (uint k = 0; k < NUM_IGNORE_GROUPS; k++) { |
8425
72a71d480c5f
(svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents:
8424
diff
changeset
|
306 |
if (PPPpreferred[i] == IgnoredPCP[k][tlg][i]) ClrBit(PCPstatus, i); |
10313
53b9d5708068
(svn r12854) -Codechange: make drawing of rail catenary a bit faster
smatz
parents:
10312
diff
changeset
|
307 |
} |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
308 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
309 |
|
3451
86ff1ac451d8
(svn r4283) -Cleanup: More elrail housekeeping, remove code dublication, more meaningful variable names, simplify control flow..
celestar
parents:
3449
diff
changeset
|
310 |
/* Now decide where we draw our pylons. First try the preferred PPPs, but they may not exist. |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
311 |
* In that case, we try the any of the allowed ones. if they don't exist either, don't draw |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
312 |
* anything. Note that the preferred PPPs still contain the end-of-line markers. |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4480
diff
changeset
|
313 |
* Remove those (simply by ANDing with allowed, since these markers are never allowed) */ |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4021
diff
changeset
|
314 |
if ((PPPallowed[i] & PPPpreferred[i]) != 0) PPPallowed[i] &= PPPpreferred[i]; |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
315 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
316 |
if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile)) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
317 |
Track bridgetrack = GetBridgeAxis(ti->tile) == AXIS_X ? TRACK_X : TRACK_Y; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
318 |
uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile)); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
319 |
|
7195
6edfafb988be
(svn r9931) -Fix: some glitches with catenary and bridges.
rubidium
parents:
6949
diff
changeset
|
320 |
if ((height <= GetTileMaxZ(ti->tile) + TILE_HEIGHT) && |
6595 | 321 |
(i == PCPpositions[bridgetrack][0] || i == PCPpositions[bridgetrack][1])) { |
8427
143b0be22af1
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents:
8425
diff
changeset
|
322 |
SetBit(OverridePCP, i); |
6595 | 323 |
} |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
324 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
325 |
|
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8345
diff
changeset
|
326 |
if (PPPallowed[i] != 0 && HasBit(PCPstatus, i) && !HasBit(OverridePCP, i)) { |
10313
53b9d5708068
(svn r12854) -Codechange: make drawing of rail catenary a bit faster
smatz
parents:
10312
diff
changeset
|
327 |
for (Direction k = DIR_BEGIN; k < DIR_END; k++) { |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
328 |
byte temp = PPPorder[i][GetTLG(ti->tile)][k]; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4021
diff
changeset
|
329 |
|
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8345
diff
changeset
|
330 |
if (HasBit(PPPallowed[i], temp)) { |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
331 |
uint x = ti->x + x_pcp_offsets[i] + x_ppp_offsets[temp]; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
332 |
uint y = ti->y + y_pcp_offsets[i] + y_ppp_offsets[temp]; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
333 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
334 |
/* Don't build the pylon if it would be outside the tile */ |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8345
diff
changeset
|
335 |
if (!HasBit(OwnedPPPonPCP[i], temp)) { |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
336 |
/* We have a neighour that will draw it, bail out */ |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
337 |
if (trackconfig[TS_NEIGHBOUR] != 0) break; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
338 |
continue; /* No neighbour, go looking for a better position */ |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
339 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
340 |
|
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
341 |
AddSortableSpriteToDraw(pylon_sprites[temp], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, |
10313
53b9d5708068
(svn r12854) -Codechange: make drawing of rail catenary a bit faster
smatz
parents:
10312
diff
changeset
|
342 |
elevation, IsTransparencySet(TO_CATENARY), -1, -1); |
53b9d5708068
(svn r12854) -Codechange: make drawing of rail catenary a bit faster
smatz
parents:
10312
diff
changeset
|
343 |
|
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
344 |
break; /* We already have drawn a pylon, bail out */ |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
345 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
346 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
347 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
348 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
349 |
|
4480
2dfb09aaa11c
(svn r6265) Check whether to draw catenary at all once before the drawing loop instead of on every iteration
tron
parents:
4470
diff
changeset
|
350 |
/* Don't draw a wire under a low bridge */ |
9024
85bc26dd4935
(svn r12103) -Feature(tte): separate catenary transparency settings from building transparency settings
smatz
parents:
8909
diff
changeset
|
351 |
if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !IsTransparencySet(TO_CATENARY)) { |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
352 |
uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile)); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
353 |
|
7195
6edfafb988be
(svn r9931) -Fix: some glitches with catenary and bridges.
rubidium
parents:
6949
diff
changeset
|
354 |
if (height <= GetTileMaxZ(ti->tile) + TILE_HEIGHT) return; |
4480
2dfb09aaa11c
(svn r6265) Check whether to draw catenary at all once before the drawing loop instead of on every iteration
tron
parents:
4470
diff
changeset
|
355 |
} |
2dfb09aaa11c
(svn r6265) Check whether to draw catenary at all once before the drawing loop instead of on every iteration
tron
parents:
4470
diff
changeset
|
356 |
|
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
357 |
/* Drawing of pylons is finished, now draw the wires */ |
10313
53b9d5708068
(svn r12854) -Codechange: make drawing of rail catenary a bit faster
smatz
parents:
10312
diff
changeset
|
358 |
for (Track t = TRACK_BEGIN; t < TRACK_END; t++) { |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8345
diff
changeset
|
359 |
if (HasBit(trackconfig[TS_HOME], t)) { |
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8030
diff
changeset
|
360 |
if (IsTunnelTile(ti->tile)) break; // drawn together with tunnel-roof (see DrawCatenaryOnTunnel()) |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8345
diff
changeset
|
361 |
byte PCPconfig = HasBit(PCPstatus, PCPpositions[t][0]) + |
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8345
diff
changeset
|
362 |
(HasBit(PCPstatus, PCPpositions[t][1]) << 1); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
363 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
364 |
const SortableSpriteStruct *sss; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
365 |
int tileh_selector = !(tileh[TS_HOME] % 3) * tileh[TS_HOME] / 3; /* tileh for the slopes, 0 otherwise */ |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
366 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
367 |
assert(PCPconfig != 0); /* We have a pylon on neither end of the wire, that doesn't work (since we have no sprites for that) */ |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3463
diff
changeset
|
368 |
assert(!IsSteepSlope(tileh[TS_HOME])); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
369 |
sss = &CatenarySpriteData[Wires[tileh_selector][t][PCPconfig]]; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
370 |
|
8030
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
371 |
/* |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
372 |
* The "wire"-sprite position is inside the tile, i.e. 0 <= sss->?_offset < TILE_SIZE. |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
373 |
* Therefore it is save to use GetSlopeZ() for the elevation. |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
374 |
* Also note, that the result of GetSlopeZ() is very special for bridge-ramps. |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
375 |
*/ |
7829
88883899c9e6
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium
parents:
7516
diff
changeset
|
376 |
AddSortableSpriteToDraw(sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset, |
8030
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
377 |
sss->x_size, sss->y_size, sss->z_size, GetSlopeZ(ti->x + sss->x_offset, ti->y + sss->y_offset) + sss->z_offset, |
9024
85bc26dd4935
(svn r12103) -Feature(tte): separate catenary transparency settings from building transparency settings
smatz
parents:
8909
diff
changeset
|
378 |
IsTransparencySet(TO_CATENARY)); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
379 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
380 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
381 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
382 |
|
10312
53a9159f194d
(svn r12853) -Fix: catenary on tunnel entrances and middle bridge pieces was drawn twice in some cases
smatz
parents:
9302
diff
changeset
|
383 |
void DrawCatenaryOnBridge(const TileInfo *ti) |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
384 |
{ |
10312
53a9159f194d
(svn r12853) -Fix: catenary on tunnel entrances and middle bridge pieces was drawn twice in some cases
smatz
parents:
9302
diff
changeset
|
385 |
if (_patches.disable_elrails) return; |
53a9159f194d
(svn r12853) -Fix: catenary on tunnel entrances and middle bridge pieces was drawn twice in some cases
smatz
parents:
9302
diff
changeset
|
386 |
|
53a9159f194d
(svn r12853) -Fix: catenary on tunnel entrances and middle bridge pieces was drawn twice in some cases
smatz
parents:
9302
diff
changeset
|
387 |
/* Do not draw catenary if it is invisible */ |
53a9159f194d
(svn r12853) -Fix: catenary on tunnel entrances and middle bridge pieces was drawn twice in some cases
smatz
parents:
9302
diff
changeset
|
388 |
if (IsInvisibilitySet(TO_CATENARY)) return; |
53a9159f194d
(svn r12853) -Fix: catenary on tunnel entrances and middle bridge pieces was drawn twice in some cases
smatz
parents:
9302
diff
changeset
|
389 |
|
3445
bd7f731c8e6f
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
390 |
TileIndex end = GetSouthernBridgeEnd(ti->tile); |
bd7f731c8e6f
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
391 |
TileIndex start = GetOtherBridgeEnd(end); |
bd7f731c8e6f
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
392 |
|
8894
1e5b2d4380b8
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz
parents:
8766
diff
changeset
|
393 |
uint length = GetTunnelBridgeLength(start, end); |
1e5b2d4380b8
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz
parents:
8766
diff
changeset
|
394 |
uint num = GetTunnelBridgeLength(ti->tile, start) + 1; |
4159
55c50b91e5b8
(svn r5584) When drawing catenary on a bridge calculate its height only once
tron
parents:
4158
diff
changeset
|
395 |
uint height; |
3445
bd7f731c8e6f
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
396 |
|
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
397 |
const SortableSpriteStruct *sss; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
398 |
Axis axis = GetBridgeAxis(ti->tile); |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
399 |
TLG tlg = GetTLG(ti->tile); |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
400 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
401 |
CatenarySprite offset = (CatenarySprite)(axis == AXIS_X ? 0 : WIRE_Y_FLAT_BOTH - WIRE_X_FLAT_BOTH); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
402 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
403 |
if ((length % 2) && num == length) { |
3445
bd7f731c8e6f
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
404 |
/* Draw the "short" wire on the southern end of the bridge |
bd7f731c8e6f
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
405 |
* only needed if the length of the bridge is odd */ |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
406 |
sss = &CatenarySpriteData[WIRE_X_FLAT_BOTH + offset]; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
407 |
} else { |
3445
bd7f731c8e6f
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
408 |
/* Draw "long" wires on all other tiles of the bridge (one pylon every two tiles) */ |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
409 |
sss = &CatenarySpriteData[WIRE_X_FLAT_SW + (num % 2) + offset]; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
410 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
411 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
412 |
height = GetBridgeHeight(end); |
4159
55c50b91e5b8
(svn r5584) When drawing catenary on a bridge calculate its height only once
tron
parents:
4158
diff
changeset
|
413 |
|
7829
88883899c9e6
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium
parents:
7516
diff
changeset
|
414 |
AddSortableSpriteToDraw(sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset, |
88883899c9e6
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium
parents:
7516
diff
changeset
|
415 |
sss->x_size, sss->y_size, sss->z_size, height + sss->z_offset, |
9024
85bc26dd4935
(svn r12103) -Feature(tte): separate catenary transparency settings from building transparency settings
smatz
parents:
8909
diff
changeset
|
416 |
IsTransparencySet(TO_CATENARY) |
4159
55c50b91e5b8
(svn r5584) When drawing catenary on a bridge calculate its height only once
tron
parents:
4158
diff
changeset
|
417 |
); |
3445
bd7f731c8e6f
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
418 |
|
bd7f731c8e6f
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
419 |
/* Finished with wires, draw pylons */ |
bd7f731c8e6f
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
420 |
/* every other tile needs a pylon on the northern end */ |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
421 |
if (num % 2) { |
8030
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
422 |
DiagDirection PCPpos = (axis == AXIS_X ? DIAGDIR_NE : DIAGDIR_NW); |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
423 |
Direction PPPpos = (axis == AXIS_X ? DIR_NW : DIR_NE); |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8345
diff
changeset
|
424 |
if (HasBit(tlg, (axis == AXIS_X ? 0 : 1))) PPPpos = ReverseDir(PPPpos); |
8030
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
425 |
uint x = ti->x + x_pcp_offsets[PCPpos] + x_ppp_offsets[PPPpos]; |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
426 |
uint y = ti->y + y_pcp_offsets[PCPpos] + y_ppp_offsets[PPPpos]; |
9024
85bc26dd4935
(svn r12103) -Feature(tte): separate catenary transparency settings from building transparency settings
smatz
parents:
8909
diff
changeset
|
427 |
AddSortableSpriteToDraw(pylon_sprites[PPPpos], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, height, IsTransparencySet(TO_CATENARY), -1, -1); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
428 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
429 |
|
3445
bd7f731c8e6f
(svn r4276) -Codechange: Cleaned DrawCatenaryOnBridge a bit (requested by Tron)
celestar
parents:
3405
diff
changeset
|
430 |
/* need a pylon on the southern end of the bridge */ |
8894
1e5b2d4380b8
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz
parents:
8766
diff
changeset
|
431 |
if (GetTunnelBridgeLength(ti->tile, start) + 1 == length) { |
8030
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
432 |
DiagDirection PCPpos = (axis == AXIS_X ? DIAGDIR_SW : DIAGDIR_SE); |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
433 |
Direction PPPpos = (axis == AXIS_X ? DIR_NW : DIR_NE); |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8345
diff
changeset
|
434 |
if (HasBit(tlg, (axis == AXIS_X ? 0 : 1))) PPPpos = ReverseDir(PPPpos); |
8030
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
435 |
uint x = ti->x + x_pcp_offsets[PCPpos] + x_ppp_offsets[PPPpos]; |
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
436 |
uint y = ti->y + y_pcp_offsets[PCPpos] + y_ppp_offsets[PPPpos]; |
9024
85bc26dd4935
(svn r12103) -Feature(tte): separate catenary transparency settings from building transparency settings
smatz
parents:
8909
diff
changeset
|
437 |
AddSortableSpriteToDraw(pylon_sprites[PPPpos], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, height, IsTransparencySet(TO_CATENARY), -1, -1); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
438 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
439 |
} |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
440 |
|
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
441 |
void DrawCatenary(const TileInfo *ti) |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
442 |
{ |
7516
2bf76064ac32
(svn r10283) -Fix [FS#913]: catenary was drawn on bridges when elrail was disabled. Patch by B. N. SmatZ!.
rubidium
parents:
7195
diff
changeset
|
443 |
if (_patches.disable_elrails) return; |
2bf76064ac32
(svn r10283) -Fix [FS#913]: catenary was drawn on bridges when elrail was disabled. Patch by B. N. SmatZ!.
rubidium
parents:
7195
diff
changeset
|
444 |
|
9302
4aa3c4a44b16
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
9282
diff
changeset
|
445 |
/* Do not draw catenary if it is invisible */ |
4aa3c4a44b16
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
9282
diff
changeset
|
446 |
if (IsInvisibilitySet(TO_CATENARY)) return; |
4aa3c4a44b16
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
9282
diff
changeset
|
447 |
|
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
448 |
switch (GetTileType(ti->tile)) { |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
449 |
case MP_RAILWAY: |
6595 | 450 |
if (IsRailDepot(ti->tile)) { |
451 |
const SortableSpriteStruct *sss = &CatenarySpriteData_Depot[GetRailDepotDirection(ti->tile)]; |
|
4470 | 452 |
|
8030
4871f518c0df
(svn r11054) -Fix [FS#944]: mismatch between TTDP's and OTTD's placement of catenary, creating graphical glitches when loading a catenary replacement. Patch by frosch.
rubidium
parents:
7968
diff
changeset
|
453 |
/* This wire is not visible with the default depot sprites */ |
4470 | 454 |
AddSortableSpriteToDraw( |
7829
88883899c9e6
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium
parents:
7516
diff
changeset
|
455 |
sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset, |
4470 | 456 |
sss->x_size, sss->y_size, sss->z_size, |
7829
88883899c9e6
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium
parents:
7516
diff
changeset
|
457 |
GetTileMaxZ(ti->tile) + sss->z_offset, |
9024
85bc26dd4935
(svn r12103) -Feature(tte): separate catenary transparency settings from building transparency settings
smatz
parents:
8909
diff
changeset
|
458 |
IsTransparencySet(TO_CATENARY) |
4470 | 459 |
); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
460 |
return; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
461 |
} |
3995
3a2d054689d6
(svn r5198) Fix some strange control flow: the case for MP_RAILWAY fell through the case for MP_TUNNELBRIDGE
tron
parents:
3977
diff
changeset
|
462 |
break; |
3a2d054689d6
(svn r5198) Fix some strange control flow: the case for MP_RAILWAY fell through the case for MP_TUNNELBRIDGE
tron
parents:
3977
diff
changeset
|
463 |
|
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
464 |
case MP_TUNNELBRIDGE: |
7866
e19fda04e8d3
(svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium
parents:
7831
diff
changeset
|
465 |
case MP_ROAD: |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5314
diff
changeset
|
466 |
case MP_STATION: |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
467 |
break; |
3995
3a2d054689d6
(svn r5198) Fix some strange control flow: the case for MP_RAILWAY fell through the case for MP_TUNNELBRIDGE
tron
parents:
3977
diff
changeset
|
468 |
|
3a2d054689d6
(svn r5198) Fix some strange control flow: the case for MP_RAILWAY fell through the case for MP_TUNNELBRIDGE
tron
parents:
3977
diff
changeset
|
469 |
default: return; |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
470 |
} |
3995
3a2d054689d6
(svn r5198) Fix some strange control flow: the case for MP_RAILWAY fell through the case for MP_TUNNELBRIDGE
tron
parents:
3977
diff
changeset
|
471 |
DrawCatenaryRailway(ti); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
diff
changeset
|
472 |
} |
5116
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
473 |
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
474 |
int32 SettingsDisableElrail(int32 p1) |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
475 |
{ |
6595 | 476 |
Vehicle *v; |
5116
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
477 |
Player *p; |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
478 |
bool disable = (p1 != 0); |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
479 |
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
480 |
/* we will now walk through all electric train engines and change their railtypes if it is the wrong one*/ |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
481 |
const RailType old_railtype = disable ? RAILTYPE_ELECTRIC : RAILTYPE_RAIL; |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
482 |
const RailType new_railtype = disable ? RAILTYPE_RAIL : RAILTYPE_ELECTRIC; |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
483 |
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
484 |
/* walk through all train engines */ |
10382
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10313
diff
changeset
|
485 |
Engine *e; |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10313
diff
changeset
|
486 |
FOR_ALL_ENGINES_OF_TYPE(e, VEH_TRAIN) { |
d1d4452acbfc
(svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents:
10313
diff
changeset
|
487 |
RailVehicleInfo *rv_info = &e->u.rail; |
5116
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
488 |
/* if it is an electric rail engine and its railtype is the wrong one */ |
6074 | 489 |
if (rv_info->engclass == 2 && rv_info->railtype == old_railtype) { |
5116
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
490 |
/* change it to the proper one */ |
6074 | 491 |
rv_info->railtype = new_railtype; |
5116
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
492 |
} |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
493 |
} |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
494 |
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
495 |
/* when disabling elrails, make sure that all existing trains can run on |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
496 |
* normal rail too */ |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
497 |
if (disable) { |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
498 |
FOR_ALL_VEHICLES(v) { |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6498
diff
changeset
|
499 |
if (v->type == VEH_TRAIN && v->u.rail.railtype == RAILTYPE_ELECTRIC) { |
5116
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
500 |
/* this railroad vehicle is now compatible only with elrail, |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
501 |
* so add there also normal rail compatibility */ |
8732
b18f578f7c16
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8720
diff
changeset
|
502 |
v->u.rail.compatible_railtypes |= RAILTYPES_RAIL; |
5116
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
503 |
v->u.rail.railtype = RAILTYPE_RAIL; |
8427
143b0be22af1
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents:
8425
diff
changeset
|
504 |
SetBit(v->u.rail.flags, VRF_EL_ENGINE_ALLOWED_NORMAL_RAIL); |
5116
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
505 |
} |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
506 |
} |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
507 |
} |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
508 |
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
509 |
/* setup total power for trains */ |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
510 |
FOR_ALL_VEHICLES(v) { |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
511 |
/* power is cached only for front engines */ |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6498
diff
changeset
|
512 |
if (v->type == VEH_TRAIN && IsFrontEngine(v)) TrainPowerChanged(v); |
5116
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
513 |
} |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
514 |
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
515 |
FOR_ALL_PLAYERS(p) p->avail_railtypes = GetPlayerRailtypes(p->index); |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
516 |
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
517 |
/* This resets the _last_built_railtype, which will be invalid for electric |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
518 |
* rails. It may have unintended consequences if that function is ever |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
519 |
* extended, though. */ |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
520 |
ReinitGuiAfterToggleElrail(disable); |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
521 |
return 0; |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4559
diff
changeset
|
522 |
} |