Mercurial > hg > openttd
annotate src/tunnelbridge_cmd.cpp @ 11635:858d735ef724 draft
(svn r16015) -Codechange: Completing the TransparencyToolbarWidgets enum.
author | alberth <alberth@openttd.org> |
---|---|
date | Fri, 10 Apr 2009 16:20:54 +0000 |
parents | 82c90cd591ab |
children | a39da1e4c1f5 |
rev | line source |
---|---|
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1 /* $Id$ */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2 |
6117
6def6ecb1bf7
(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 <belugas@openttd.org>
parents:
6106
diff
changeset
|
3 /** @file tunnelbridge_cmd.cpp |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
4 * This file deals with tunnels and bridges (non-gui stuff) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
5 * @todo seperate this file into two |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
6 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
7 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
8 #include "stdafx.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
9 #include "openttd.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
10 #include "rail_map.h" |
6343
f75b72d9fc98
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros <maedhros@openttd.org>
parents:
6259
diff
changeset
|
11 #include "landscape.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
12 #include "unmovable_map.h" |
8224
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8204
diff
changeset
|
13 #include "viewport_func.h" |
8116
9cc845deddfe
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium <rubidium@openttd.org>
parents:
8114
diff
changeset
|
14 #include "command_func.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
15 #include "town.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
16 #include "variables.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
17 #include "train.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
18 #include "water_map.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
19 #include "yapf/yapf.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
20 #include "newgrf_sound.h" |
7582
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7548
diff
changeset
|
21 #include "autoslope.h" |
8083
e02014b06c7f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
8081
diff
changeset
|
22 #include "tunnelbridge_map.h" |
8114
2d6af5d7a142
(svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
8108
diff
changeset
|
23 #include "strings_func.h" |
8140
fb8a05d579da
(svn r11702) -Codechange: move all date related stuff to date*.
rubidium <rubidium@openttd.org>
parents:
8139
diff
changeset
|
24 #include "date_func.h" |
8131
e300ac8001ae
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium <rubidium@openttd.org>
parents:
8119
diff
changeset
|
25 #include "functions.h" |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
8140
diff
changeset
|
26 #include "vehicle_func.h" |
8157
019833e42fda
(svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
27 #include "sound_func.h" |
8398
a6304b304752
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz <smatz@openttd.org>
parents:
8390
diff
changeset
|
28 #include "tunnelbridge.h" |
9070
11b5b3f4175d
(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 <peter1138@openttd.org>
parents:
9034
diff
changeset
|
29 #include "engine_base.h" |
10960
a4e5b5d2837c
(svn r15299) -Cleanup: remove many redundant includes
smatz <smatz@openttd.org>
parents:
10855
diff
changeset
|
30 #include "cheat_type.h" |
9154
046d0b6e0218
(svn r13016) -Codechange: unify the detection if rail catenary should be drawn
smatz <smatz@openttd.org>
parents:
9126
diff
changeset
|
31 #include "elrail_func.h" |
9126
8c450e1754e2
(svn r12986) -Codechange: move the landscape and transport related types from openttd.h to their own headers.
rubidium <rubidium@openttd.org>
parents:
9070
diff
changeset
|
32 #include "landscape_type.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
33 |
8264
2495310e220f
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents:
8254
diff
changeset
|
34 #include "table/sprites.h" |
2495310e220f
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents:
8254
diff
changeset
|
35 #include "table/strings.h" |
2495310e220f
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents:
8254
diff
changeset
|
36 #include "table/bridge_land.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
37 |
8535
c026695bee6c
(svn r12111) -Codechange: Rename Bridge to BridgeSpec, out of consistensy with other Specs in used.
belugas <belugas@openttd.org>
parents:
8532
diff
changeset
|
38 BridgeSpec _bridge[MAX_BRIDGES]; |
8973
f8dda7737158
(svn r12765) -Codechange: move some stuff out of variables.h that required including other headers in variables.h.
rubidium <rubidium@openttd.org>
parents:
8965
diff
changeset
|
39 TileIndex _build_tunnel_endtile; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
40 |
8489
bcc7ea0c669d
(svn r12064) -Codechange : Give grf bridges their own ResetBridges function, and put bridge spec in table/bridge_land.h, where it should be.
belugas <belugas@openttd.org>
parents:
8475
diff
changeset
|
41 /** Reset the data been eventually changed by the grf loaded. */ |
bcc7ea0c669d
(svn r12064) -Codechange : Give grf bridges their own ResetBridges function, and put bridge spec in table/bridge_land.h, where it should be.
belugas <belugas@openttd.org>
parents:
8475
diff
changeset
|
42 void ResetBridges() |
bcc7ea0c669d
(svn r12064) -Codechange : Give grf bridges their own ResetBridges function, and put bridge spec in table/bridge_land.h, where it should be.
belugas <belugas@openttd.org>
parents:
8475
diff
changeset
|
43 { |
bcc7ea0c669d
(svn r12064) -Codechange : Give grf bridges their own ResetBridges function, and put bridge spec in table/bridge_land.h, where it should be.
belugas <belugas@openttd.org>
parents:
8475
diff
changeset
|
44 /* First, free sprite table data */ |
8532
b3bd4f1ed981
(svn r12107) -Codechange: Add and use the typedef BridgeType
belugas <belugas@openttd.org>
parents:
8531
diff
changeset
|
45 for (BridgeType i = 0; i < MAX_BRIDGES; i++) { |
8489
bcc7ea0c669d
(svn r12064) -Codechange : Give grf bridges their own ResetBridges function, and put bridge spec in table/bridge_land.h, where it should be.
belugas <belugas@openttd.org>
parents:
8475
diff
changeset
|
46 if (_bridge[i].sprite_table != NULL) { |
9642
b4caf5c04b2f
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas <belugas@openttd.org>
parents:
9596
diff
changeset
|
47 for (BridgePieces j = BRIDGE_PIECE_NORTH; j < BRIDGE_PIECE_INVALID; j++) free(_bridge[i].sprite_table[j]); |
8489
bcc7ea0c669d
(svn r12064) -Codechange : Give grf bridges their own ResetBridges function, and put bridge spec in table/bridge_land.h, where it should be.
belugas <belugas@openttd.org>
parents:
8475
diff
changeset
|
48 free(_bridge[i].sprite_table); |
bcc7ea0c669d
(svn r12064) -Codechange : Give grf bridges their own ResetBridges function, and put bridge spec in table/bridge_land.h, where it should be.
belugas <belugas@openttd.org>
parents:
8475
diff
changeset
|
49 } |
bcc7ea0c669d
(svn r12064) -Codechange : Give grf bridges their own ResetBridges function, and put bridge spec in table/bridge_land.h, where it should be.
belugas <belugas@openttd.org>
parents:
8475
diff
changeset
|
50 } |
bcc7ea0c669d
(svn r12064) -Codechange : Give grf bridges their own ResetBridges function, and put bridge spec in table/bridge_land.h, where it should be.
belugas <belugas@openttd.org>
parents:
8475
diff
changeset
|
51 |
bcc7ea0c669d
(svn r12064) -Codechange : Give grf bridges their own ResetBridges function, and put bridge spec in table/bridge_land.h, where it should be.
belugas <belugas@openttd.org>
parents:
8475
diff
changeset
|
52 /* Then, wipe out current bidges */ |
bcc7ea0c669d
(svn r12064) -Codechange : Give grf bridges their own ResetBridges function, and put bridge spec in table/bridge_land.h, where it should be.
belugas <belugas@openttd.org>
parents:
8475
diff
changeset
|
53 memset(&_bridge, 0, sizeof(_bridge)); |
bcc7ea0c669d
(svn r12064) -Codechange : Give grf bridges their own ResetBridges function, and put bridge spec in table/bridge_land.h, where it should be.
belugas <belugas@openttd.org>
parents:
8475
diff
changeset
|
54 /* And finally, reinstall default data */ |
bcc7ea0c669d
(svn r12064) -Codechange : Give grf bridges their own ResetBridges function, and put bridge spec in table/bridge_land.h, where it should be.
belugas <belugas@openttd.org>
parents:
8475
diff
changeset
|
55 memcpy(&_bridge, &_orig_bridge, sizeof(_orig_bridge)); |
bcc7ea0c669d
(svn r12064) -Codechange : Give grf bridges their own ResetBridges function, and put bridge spec in table/bridge_land.h, where it should be.
belugas <belugas@openttd.org>
parents:
8475
diff
changeset
|
56 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
57 |
6422
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
58 /** calculate the price factor for building a long bridge. |
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
59 * basically the cost delta is 1,1, 1, 2,2, 3,3,3, 4,4,4,4, 5,5,5,5,5, 6,6,6,6,6,6, 7,7,7,7,7,7,7, 8,8,8,8,8,8,8,8, |
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
60 */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
61 int CalcBridgeLenCostFactor(int x) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
62 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
63 int n; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
64 int r; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
65 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
66 if (x < 2) return x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
67 x -= 2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
68 for (n = 0, r = 2;; n++) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
69 if (x <= n) return r + x * n; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
70 r += n * n; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
71 x -= n; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
72 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
73 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
74 |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
75 Foundation GetBridgeFoundation(Slope tileh, Axis axis) |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
76 { |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
77 if ((tileh == SLOPE_FLAT) || |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
78 (((tileh == SLOPE_NE) || (tileh == SLOPE_SW)) && (axis == AXIS_X)) || |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
79 (((tileh == SLOPE_NW) || (tileh == SLOPE_SE)) && (axis == AXIS_Y))) return FOUNDATION_NONE; |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
80 |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
81 return (HasSlopeHighestCorner(tileh) ? InclinedFoundation(axis) : FlatteningFoundation(tileh)); |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
82 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
83 |
8379
bf751c81fa2f
(svn r11946) -Fix: slope detection of bridge ramps.
frosch <frosch@openttd.org>
parents:
8371
diff
changeset
|
84 /** |
bf751c81fa2f
(svn r11946) -Fix: slope detection of bridge ramps.
frosch <frosch@openttd.org>
parents:
8371
diff
changeset
|
85 * Determines if the track on a bridge ramp is flat or goes up/down. |
bf751c81fa2f
(svn r11946) -Fix: slope detection of bridge ramps.
frosch <frosch@openttd.org>
parents:
8371
diff
changeset
|
86 * |
bf751c81fa2f
(svn r11946) -Fix: slope detection of bridge ramps.
frosch <frosch@openttd.org>
parents:
8371
diff
changeset
|
87 * @param tileh Slope of the tile under the bridge head |
bf751c81fa2f
(svn r11946) -Fix: slope detection of bridge ramps.
frosch <frosch@openttd.org>
parents:
8371
diff
changeset
|
88 * @param axis Orientation of bridge |
bf751c81fa2f
(svn r11946) -Fix: slope detection of bridge ramps.
frosch <frosch@openttd.org>
parents:
8371
diff
changeset
|
89 * @return true iff the track is flat. |
bf751c81fa2f
(svn r11946) -Fix: slope detection of bridge ramps.
frosch <frosch@openttd.org>
parents:
8371
diff
changeset
|
90 */ |
bf751c81fa2f
(svn r11946) -Fix: slope detection of bridge ramps.
frosch <frosch@openttd.org>
parents:
8371
diff
changeset
|
91 bool HasBridgeFlatRamp(Slope tileh, Axis axis) |
bf751c81fa2f
(svn r11946) -Fix: slope detection of bridge ramps.
frosch <frosch@openttd.org>
parents:
8371
diff
changeset
|
92 { |
bf751c81fa2f
(svn r11946) -Fix: slope detection of bridge ramps.
frosch <frosch@openttd.org>
parents:
8371
diff
changeset
|
93 ApplyFoundationToSlope(GetBridgeFoundation(tileh, axis), &tileh); |
bf751c81fa2f
(svn r11946) -Fix: slope detection of bridge ramps.
frosch <frosch@openttd.org>
parents:
8371
diff
changeset
|
94 /* If the foundation slope is flat the bridge has a non-flat ramp and vice versa. */ |
bf751c81fa2f
(svn r11946) -Fix: slope detection of bridge ramps.
frosch <frosch@openttd.org>
parents:
8371
diff
changeset
|
95 return (tileh != SLOPE_FLAT); |
bf751c81fa2f
(svn r11946) -Fix: slope detection of bridge ramps.
frosch <frosch@openttd.org>
parents:
8371
diff
changeset
|
96 } |
bf751c81fa2f
(svn r11946) -Fix: slope detection of bridge ramps.
frosch <frosch@openttd.org>
parents:
8371
diff
changeset
|
97 |
9642
b4caf5c04b2f
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas <belugas@openttd.org>
parents:
9596
diff
changeset
|
98 static inline const PalSpriteID *GetBridgeSpriteTable(int index, BridgePieces table) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
99 { |
8535
c026695bee6c
(svn r12111) -Codechange: Rename Bridge to BridgeSpec, out of consistensy with other Specs in used.
belugas <belugas@openttd.org>
parents:
8532
diff
changeset
|
100 const BridgeSpec *bridge = GetBridgeSpec(index); |
9642
b4caf5c04b2f
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas <belugas@openttd.org>
parents:
9596
diff
changeset
|
101 assert(table < BRIDGE_PIECE_INVALID); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
102 if (bridge->sprite_table == NULL || bridge->sprite_table[table] == NULL) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
103 return _bridge_sprite_table[index][table]; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
104 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
105 return bridge->sprite_table[table]; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
106 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
107 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
108 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
109 |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
110 /** |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
111 * Determines the foundation for the north bridge head, and tests if the resulting slope is valid. |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
112 * |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
113 * @param axis Axis of the bridge |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
114 * @param tileh Slope of the tile under the north bridge head; returns slope on top of foundation |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
115 * @param z TileZ corresponding to tileh, gets modified as well |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
116 * @return Error or cost for bridge foundation |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
117 */ |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
118 static CommandCost CheckBridgeSlopeNorth(Axis axis, Slope *tileh, uint *z) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
119 { |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
120 Foundation f = GetBridgeFoundation(*tileh, axis); |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
121 *z += ApplyFoundationToSlope(f, tileh); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
122 |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
123 Slope valid_inclined = (axis == AXIS_X ? SLOPE_NE : SLOPE_NW); |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
124 if ((*tileh != SLOPE_FLAT) && (*tileh != valid_inclined)) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
125 |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
126 if (f == FOUNDATION_NONE) return CommandCost(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
127 |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
128 return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
129 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
130 |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
131 /** |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
132 * Determines the foundation for the south bridge head, and tests if the resulting slope is valid. |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
133 * |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
134 * @param axis Axis of the bridge |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
135 * @param tileh Slope of the tile under the south bridge head; returns slope on top of foundation |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
136 * @param z TileZ corresponding to tileh, gets modified as well |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
137 * @return Error or cost for bridge foundation |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
138 */ |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
139 static CommandCost CheckBridgeSlopeSouth(Axis axis, Slope *tileh, uint *z) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
140 { |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
141 Foundation f = GetBridgeFoundation(*tileh, axis); |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
142 *z += ApplyFoundationToSlope(f, tileh); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
143 |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
144 Slope valid_inclined = (axis == AXIS_X ? SLOPE_SW : SLOPE_SE); |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
145 if ((*tileh != SLOPE_FLAT) && (*tileh != valid_inclined)) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
146 |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
147 if (f == FOUNDATION_NONE) return CommandCost(); |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
148 |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
149 return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
150 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
151 |
11090
df23c4e04638
(svn r15434) -Codechange: bit of type safety for the DC_xxx flags.
rubidium <rubidium@openttd.org>
parents:
11069
diff
changeset
|
152 bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len, DoCommandFlag flags) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
153 { |
9578
b455ef88d6fe
(svn r13611) -Fix [FS#2100]: if the first bridge can't be build for a given length, then none of the other bridges can. Effectively meaning that if someone replaces the first bridge with a bridge that can be only 3 tiles longs then only other bridges that can be 3 tiles long will be buildable, but only if they are 3 tiles long.
rubidium <rubidium@openttd.org>
parents:
9498
diff
changeset
|
154 if (flags & DC_QUERY_COST) { |
9596
e8131252acfc
(svn r13638) -Fix: signed/unsigned warning for MSVC9 and gcc2
smatz <smatz@openttd.org>
parents:
9578
diff
changeset
|
155 return bridge_len <= (_settings_game.construction.longbridges ? 100U : 16U); |
9578
b455ef88d6fe
(svn r13611) -Fix [FS#2100]: if the first bridge can't be build for a given length, then none of the other bridges can. Effectively meaning that if someone replaces the first bridge with a bridge that can be only 3 tiles longs then only other bridges that can be 3 tiles long will be buildable, but only if they are 3 tiles long.
rubidium <rubidium@openttd.org>
parents:
9498
diff
changeset
|
156 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
157 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
158 if (bridge_type >= MAX_BRIDGES) return false; |
9578
b455ef88d6fe
(svn r13611) -Fix [FS#2100]: if the first bridge can't be build for a given length, then none of the other bridges can. Effectively meaning that if someone replaces the first bridge with a bridge that can be only 3 tiles longs then only other bridges that can be 3 tiles long will be buildable, but only if they are 3 tiles long.
rubidium <rubidium@openttd.org>
parents:
9498
diff
changeset
|
159 |
b455ef88d6fe
(svn r13611) -Fix [FS#2100]: if the first bridge can't be build for a given length, then none of the other bridges can. Effectively meaning that if someone replaces the first bridge with a bridge that can be only 3 tiles longs then only other bridges that can be 3 tiles long will be buildable, but only if they are 3 tiles long.
rubidium <rubidium@openttd.org>
parents:
9498
diff
changeset
|
160 const BridgeSpec *b = GetBridgeSpec(bridge_type); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
161 if (b->avail_year > _cur_year) return false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
162 |
9578
b455ef88d6fe
(svn r13611) -Fix [FS#2100]: if the first bridge can't be build for a given length, then none of the other bridges can. Effectively meaning that if someone replaces the first bridge with a bridge that can be only 3 tiles longs then only other bridges that can be 3 tiles long will be buildable, but only if they are 3 tiles long.
rubidium <rubidium@openttd.org>
parents:
9498
diff
changeset
|
163 uint max = b->max_length; |
9413
512ea64da840
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
164 if (max >= 16 && _settings_game.construction.longbridges) max = 100; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
165 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
166 return b->min_length <= bridge_len && bridge_len <= max; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
167 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
168 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
169 /** Build a Bridge |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
170 * @param end_tile end tile |
6422
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
171 * @param flags type of operation |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
172 * @param p1 packed start tile coords (~ dx) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
173 * @param p2 various bitstuffed elements |
10140
0457f19e2a68
(svn r14326) -Fix: some wrong comments (Yexo)
rubidium <rubidium@openttd.org>
parents:
10109
diff
changeset
|
174 * - p2 = (bit 0- 7) - bridge type (hi bh) |
0457f19e2a68
(svn r14326) -Fix: some wrong comments (Yexo)
rubidium <rubidium@openttd.org>
parents:
10109
diff
changeset
|
175 * - p2 = (bit 8-14) - rail type or road types. |
0457f19e2a68
(svn r14326) -Fix: some wrong comments (Yexo)
rubidium <rubidium@openttd.org>
parents:
10109
diff
changeset
|
176 * - p2 = (bit 15-16) - transport type. |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
177 */ |
11090
df23c4e04638
(svn r15434) -Codechange: bit of type safety for the DC_xxx flags.
rubidium <rubidium@openttd.org>
parents:
11069
diff
changeset
|
178 CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
179 { |
8532
b3bd4f1ed981
(svn r12107) -Codechange: Add and use the typedef BridgeType
belugas <belugas@openttd.org>
parents:
8531
diff
changeset
|
180 BridgeType bridge_type; |
8530
6a0cdc5bc1b1
(svn r12105) -Codechange: Use TransportType instead of guessing what kind of bridge we are preparing to build
belugas <belugas@openttd.org>
parents:
8528
diff
changeset
|
181 RailType railtype = INVALID_RAILTYPE; |
6a0cdc5bc1b1
(svn r12105) -Codechange: Use TransportType instead of guessing what kind of bridge we are preparing to build
belugas <belugas@openttd.org>
parents:
8528
diff
changeset
|
182 RoadTypes roadtypes = ROADTYPES_NONE; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
183 uint x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
184 uint y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
185 uint sx; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
186 uint sy; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
187 TileIndex tile_start; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
188 TileIndex tile_end; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
189 Slope tileh_start; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
190 Slope tileh_end; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
191 uint z_start; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
192 uint z_end; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
193 TileIndex tile; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
194 TileIndexDiff delta; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
195 uint bridge_len; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
196 Axis direction; |
8230
5b61305fcdd4
(svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium <rubidium@openttd.org>
parents:
8224
diff
changeset
|
197 CommandCost cost(EXPENSES_CONSTRUCTION); |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
198 CommandCost ret; |
5930
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
199 bool replace_bridge = false; |
8532
b3bd4f1ed981
(svn r12107) -Codechange: Add and use the typedef BridgeType
belugas <belugas@openttd.org>
parents:
8531
diff
changeset
|
200 BridgeType replaced_bridge_type; |
8530
6a0cdc5bc1b1
(svn r12105) -Codechange: Use TransportType instead of guessing what kind of bridge we are preparing to build
belugas <belugas@openttd.org>
parents:
8528
diff
changeset
|
201 TransportType transport_type; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
202 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
203 /* unpack parameters */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
204 bridge_type = GB(p2, 0, 8); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
205 |
8531
e1f4b0ce4884
(svn r12106) -Fix(r12105): Kill warnings and raise an error when the transport type is not supported
belugas <belugas@openttd.org>
parents:
8530
diff
changeset
|
206 if (p1 >= MapSize()) return CMD_ERROR; |
e1f4b0ce4884
(svn r12106) -Fix(r12105): Kill warnings and raise an error when the transport type is not supported
belugas <belugas@openttd.org>
parents:
8530
diff
changeset
|
207 |
8530
6a0cdc5bc1b1
(svn r12105) -Codechange: Use TransportType instead of guessing what kind of bridge we are preparing to build
belugas <belugas@openttd.org>
parents:
8528
diff
changeset
|
208 transport_type = (TransportType)GB(p2, 15, 2); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
209 |
6422
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
210 /* type of bridge */ |
8530
6a0cdc5bc1b1
(svn r12105) -Codechange: Use TransportType instead of guessing what kind of bridge we are preparing to build
belugas <belugas@openttd.org>
parents:
8528
diff
changeset
|
211 switch (transport_type) { |
6a0cdc5bc1b1
(svn r12105) -Codechange: Use TransportType instead of guessing what kind of bridge we are preparing to build
belugas <belugas@openttd.org>
parents:
8528
diff
changeset
|
212 case TRANSPORT_ROAD: |
11252
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
213 roadtypes = (RoadTypes)GB(p2, 8, 2); |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10140
diff
changeset
|
214 if (!AreValidRoadTypes(roadtypes) || !HasRoadTypesAvail(_current_company, roadtypes)) return CMD_ERROR; |
8530
6a0cdc5bc1b1
(svn r12105) -Codechange: Use TransportType instead of guessing what kind of bridge we are preparing to build
belugas <belugas@openttd.org>
parents:
8528
diff
changeset
|
215 break; |
6a0cdc5bc1b1
(svn r12105) -Codechange: Use TransportType instead of guessing what kind of bridge we are preparing to build
belugas <belugas@openttd.org>
parents:
8528
diff
changeset
|
216 |
6a0cdc5bc1b1
(svn r12105) -Codechange: Use TransportType instead of guessing what kind of bridge we are preparing to build
belugas <belugas@openttd.org>
parents:
8528
diff
changeset
|
217 case TRANSPORT_RAIL: |
10140
0457f19e2a68
(svn r14326) -Fix: some wrong comments (Yexo)
rubidium <rubidium@openttd.org>
parents:
10109
diff
changeset
|
218 railtype = (RailType)GB(p2, 8, 7); |
8530
6a0cdc5bc1b1
(svn r12105) -Codechange: Use TransportType instead of guessing what kind of bridge we are preparing to build
belugas <belugas@openttd.org>
parents:
8528
diff
changeset
|
219 if (!ValParamRailtype(railtype)) return CMD_ERROR; |
6a0cdc5bc1b1
(svn r12105) -Codechange: Use TransportType instead of guessing what kind of bridge we are preparing to build
belugas <belugas@openttd.org>
parents:
8528
diff
changeset
|
220 break; |
8531
e1f4b0ce4884
(svn r12106) -Fix(r12105): Kill warnings and raise an error when the transport type is not supported
belugas <belugas@openttd.org>
parents:
8530
diff
changeset
|
221 |
9490
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
222 case TRANSPORT_WATER: |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
223 break; |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
224 |
8531
e1f4b0ce4884
(svn r12106) -Fix(r12105): Kill warnings and raise an error when the transport type is not supported
belugas <belugas@openttd.org>
parents:
8530
diff
changeset
|
225 default: |
9490
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
226 /* Airports don't have tunnels. */ |
8531
e1f4b0ce4884
(svn r12106) -Fix(r12105): Kill warnings and raise an error when the transport type is not supported
belugas <belugas@openttd.org>
parents:
8530
diff
changeset
|
227 return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
228 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
229 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
230 x = TileX(end_tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
231 y = TileY(end_tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
232 sx = TileX(p1); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
233 sy = TileY(p1); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
234 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
235 /* check if valid, and make sure that (x,y) are smaller than (sx,sy) */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
236 if (x == sx) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
237 if (y == sy) return_cmd_error(STR_5008_CANNOT_START_AND_END_ON); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
238 direction = AXIS_Y; |
6106 | 239 if (y > sy) Swap(y, sy); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
240 } else if (y == sy) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
241 direction = AXIS_X; |
6106 | 242 if (x > sx) Swap(x, sx); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
243 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
244 return_cmd_error(STR_500A_START_AND_END_MUST_BE_IN); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
245 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
246 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
247 bridge_len = sx + sy - x - y - 1; |
9490
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
248 if (transport_type != TRANSPORT_WATER) { |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
249 /* set and test bridge length, availability */ |
9578
b455ef88d6fe
(svn r13611) -Fix [FS#2100]: if the first bridge can't be build for a given length, then none of the other bridges can. Effectively meaning that if someone replaces the first bridge with a bridge that can be only 3 tiles longs then only other bridges that can be 3 tiles long will be buildable, but only if they are 3 tiles long.
rubidium <rubidium@openttd.org>
parents:
9498
diff
changeset
|
250 if (!CheckBridge_Stuff(bridge_type, bridge_len, flags)) return_cmd_error(STR_5015_CAN_T_BUILD_BRIDGE_HERE); |
9490
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
251 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
252 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
253 /* retrieve landscape height and ensure it's on land */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
254 tile_start = TileXY(x, y); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
255 tile_end = TileXY(sx, sy); |
8471
1e4ea519bfaf
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138 <peter1138@openttd.org>
parents:
8413
diff
changeset
|
256 if (IsWaterTile(tile_start) || IsWaterTile(tile_end)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
257 return_cmd_error(STR_02A0_ENDS_OF_BRIDGE_MUST_BOTH); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
258 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
259 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
260 tileh_start = GetTileSlope(tile_start, &z_start); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
261 tileh_end = GetTileSlope(tile_end, &z_end); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
262 |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
263 CommandCost terraform_cost_north = CheckBridgeSlopeNorth(direction, &tileh_start, &z_start); |
8625
0edb93b9e261
(svn r12208) -Codechange: Alignment of params makes the code easier to read.
belugas <belugas@openttd.org>
parents:
8616
diff
changeset
|
264 CommandCost terraform_cost_south = CheckBridgeSlopeSouth(direction, &tileh_end, &z_end); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
265 |
7682
166e9289116a
(svn r11213) -Fix [FS#1298]: confusing messages when trying to build a bridge.
rubidium <rubidium@openttd.org>
parents:
7677
diff
changeset
|
266 if (z_start != z_end) return_cmd_error(STR_BRIDGEHEADS_NOT_SAME_HEIGHT); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
267 |
5930
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
268 if (IsBridgeTile(tile_start) && IsBridgeTile(tile_end) && |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
269 GetOtherBridgeEnd(tile_start) == tile_end && |
8083
e02014b06c7f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
8081
diff
changeset
|
270 GetTunnelBridgeTransportType(tile_start) == transport_type) { |
5930
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
271 /* Replace a current bridge. */ |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
272 |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
273 /* If this is a railway bridge, make sure the railtypes match. */ |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
274 if (transport_type == TRANSPORT_RAIL && GetRailType(tile_start) != railtype) { |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
275 return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
276 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
277 |
5930
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
278 /* Do not replace town bridges with lower speed bridges. */ |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
279 if (!(flags & DC_QUERY_COST) && IsTileOwner(tile_start, OWNER_TOWN) && |
8491
cf57eb06b4d9
(svn r12066) -Codechange: Rename GetBridge for the more common GetBridgeSpec
belugas <belugas@openttd.org>
parents:
8489
diff
changeset
|
280 GetBridgeSpec(bridge_type)->speed < GetBridgeSpec(GetBridgeType(tile_start))->speed) { |
5930
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
281 Town *t = ClosestTownFromTile(tile_start, UINT_MAX); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
282 |
5930
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
283 if (t == NULL) { |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
284 return CMD_ERROR; |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
285 } else { |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
286 SetDParam(0, t->index); |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
287 return_cmd_error(STR_2009_LOCAL_AUTHORITY_REFUSES); |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
288 } |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
289 } |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
290 |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
291 /* Do not replace the bridge with the same bridge type. */ |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
292 if (!(flags & DC_QUERY_COST) && bridge_type == GetBridgeType(tile_start)) { |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
293 return_cmd_error(STR_1007_ALREADY_BUILT); |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
294 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
295 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10140
diff
changeset
|
296 /* Do not allow replacing another company's bridges. */ |
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10140
diff
changeset
|
297 if (!IsTileOwner(tile_start, _current_company) && !IsTileOwner(tile_start, OWNER_TOWN)) { |
5930
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
298 return_cmd_error(STR_1024_AREA_IS_OWNED_BY_ANOTHER); |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
299 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
300 |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6943
diff
changeset
|
301 cost.AddCost((bridge_len + 1) * _price.clear_bridge); // The cost of clearing the current bridge. |
5930
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
302 replace_bridge = true; |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
303 replaced_bridge_type = GetBridgeType(tile_start); |
6708
c67d99aa2eb2
(svn r9940) -Fix [FS#805]: upgrading a bridge removed roadtypes.
rubidium <rubidium@openttd.org>
parents:
6699
diff
changeset
|
304 |
c67d99aa2eb2
(svn r9940) -Fix [FS#805]: upgrading a bridge removed roadtypes.
rubidium <rubidium@openttd.org>
parents:
6699
diff
changeset
|
305 /* Do not remove road types when upgrading a bridge */ |
c67d99aa2eb2
(svn r9940) -Fix [FS#805]: upgrading a bridge removed roadtypes.
rubidium <rubidium@openttd.org>
parents:
6699
diff
changeset
|
306 roadtypes |= GetRoadTypes(tile_start); |
5930
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
307 } else { |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
308 /* Build a new bridge. */ |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
309 |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10647
diff
changeset
|
310 bool allow_on_slopes = (_settings_game.construction.build_on_slopes && transport_type != TRANSPORT_WATER); |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
311 |
5930
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
312 /* Try and clear the start landscape */ |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
313 ret = DoCommand(tile_start, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
314 if (CmdFailed(ret)) return ret; |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
315 cost = ret; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
316 |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
317 if (CmdFailed(terraform_cost_north) || (terraform_cost_north.GetCost() != 0 && !allow_on_slopes)) |
5930
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
318 return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
319 cost.AddCost(terraform_cost_north); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
320 |
5930
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
321 /* Try and clear the end landscape */ |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
322 ret = DoCommand(tile_end, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
323 if (CmdFailed(ret)) return ret; |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6943
diff
changeset
|
324 cost.AddCost(ret); |
5930
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
325 |
6422
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
326 /* false - end tile slope check */ |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
327 if (CmdFailed(terraform_cost_south) || (terraform_cost_south.GetCost() != 0 && !allow_on_slopes)) |
5930
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
328 return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
329 cost.AddCost(terraform_cost_south); |
9491
0e0d227a56f8
(svn r13466) -Fix (r13464): slope checking got lost during development...
rubidium <rubidium@openttd.org>
parents:
9490
diff
changeset
|
330 |
0e0d227a56f8
(svn r13466) -Fix (r13464): slope checking got lost during development...
rubidium <rubidium@openttd.org>
parents:
9490
diff
changeset
|
331 if (transport_type == TRANSPORT_WATER && (tileh_start == SLOPE_FLAT || tileh_end == SLOPE_FLAT)) return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
5930
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
332 } |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
333 |
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
334 if (!replace_bridge) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
335 TileIndex Heads[] = {tile_start, tile_end}; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
336 int i; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
337 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
338 for (i = 0; i < 2; i++) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
339 if (MayHaveBridgeAbove(Heads[i])) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
340 if (IsBridgeAbove(Heads[i])) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
341 TileIndex north_head = GetNorthernBridgeEnd(Heads[i]); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
342 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
343 if (direction == GetBridgeAxis(Heads[i])) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
344 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
345 if (z_start + TILE_HEIGHT == GetBridgeHeight(north_head)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
346 return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
347 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
348 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
349 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
350 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
351 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
352 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
353 /* do the drill? */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
354 if (flags & DC_EXEC) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
355 DiagDirection dir = AxisToDiagDir(direction); |
11252
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
356 Owner owner = replace_bridge ? GetTileOwner(tile_start) : _current_company; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
357 |
8530
6a0cdc5bc1b1
(svn r12105) -Codechange: Use TransportType instead of guessing what kind of bridge we are preparing to build
belugas <belugas@openttd.org>
parents:
8528
diff
changeset
|
358 switch (transport_type) { |
6a0cdc5bc1b1
(svn r12105) -Codechange: Use TransportType instead of guessing what kind of bridge we are preparing to build
belugas <belugas@openttd.org>
parents:
8528
diff
changeset
|
359 case TRANSPORT_RAIL: |
8625
0edb93b9e261
(svn r12208) -Codechange: Alignment of params makes the code easier to read.
belugas <belugas@openttd.org>
parents:
8616
diff
changeset
|
360 MakeRailBridgeRamp(tile_start, owner, bridge_type, dir, railtype); |
8530
6a0cdc5bc1b1
(svn r12105) -Codechange: Use TransportType instead of guessing what kind of bridge we are preparing to build
belugas <belugas@openttd.org>
parents:
8528
diff
changeset
|
361 MakeRailBridgeRamp(tile_end, owner, bridge_type, ReverseDiagDir(dir), railtype); |
6a0cdc5bc1b1
(svn r12105) -Codechange: Use TransportType instead of guessing what kind of bridge we are preparing to build
belugas <belugas@openttd.org>
parents:
8528
diff
changeset
|
362 break; |
6a0cdc5bc1b1
(svn r12105) -Codechange: Use TransportType instead of guessing what kind of bridge we are preparing to build
belugas <belugas@openttd.org>
parents:
8528
diff
changeset
|
363 |
6a0cdc5bc1b1
(svn r12105) -Codechange: Use TransportType instead of guessing what kind of bridge we are preparing to build
belugas <belugas@openttd.org>
parents:
8528
diff
changeset
|
364 case TRANSPORT_ROAD: |
8625
0edb93b9e261
(svn r12208) -Codechange: Alignment of params makes the code easier to read.
belugas <belugas@openttd.org>
parents:
8616
diff
changeset
|
365 MakeRoadBridgeRamp(tile_start, owner, bridge_type, dir, roadtypes); |
8530
6a0cdc5bc1b1
(svn r12105) -Codechange: Use TransportType instead of guessing what kind of bridge we are preparing to build
belugas <belugas@openttd.org>
parents:
8528
diff
changeset
|
366 MakeRoadBridgeRamp(tile_end, owner, bridge_type, ReverseDiagDir(dir), roadtypes); |
6a0cdc5bc1b1
(svn r12105) -Codechange: Use TransportType instead of guessing what kind of bridge we are preparing to build
belugas <belugas@openttd.org>
parents:
8528
diff
changeset
|
367 break; |
8531
e1f4b0ce4884
(svn r12106) -Fix(r12105): Kill warnings and raise an error when the transport type is not supported
belugas <belugas@openttd.org>
parents:
8530
diff
changeset
|
368 |
9490
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
369 case TRANSPORT_WATER: |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
370 MakeAqueductBridgeRamp(tile_start, owner, dir); |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
371 MakeAqueductBridgeRamp(tile_end, owner, ReverseDiagDir(dir)); |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
372 break; |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
373 |
8531
e1f4b0ce4884
(svn r12106) -Fix(r12105): Kill warnings and raise an error when the transport type is not supported
belugas <belugas@openttd.org>
parents:
8530
diff
changeset
|
374 default: |
e1f4b0ce4884
(svn r12106) -Fix(r12105): Kill warnings and raise an error when the transport type is not supported
belugas <belugas@openttd.org>
parents:
8530
diff
changeset
|
375 NOT_REACHED(); |
e1f4b0ce4884
(svn r12106) -Fix(r12105): Kill warnings and raise an error when the transport type is not supported
belugas <belugas@openttd.org>
parents:
8530
diff
changeset
|
376 break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
377 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
378 MarkTileDirtyByTile(tile_start); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
379 MarkTileDirtyByTile(tile_end); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
380 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
381 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
382 delta = (direction == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1)); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
383 for (tile = tile_start + delta; tile != tile_end; tile += delta) { |
8370
bf2daa4819d0
(svn r11936) -Fix: 'BRIDGE_TOO_LOW_FOR_TERRAIN'-check was wrong for steep slopes.
frosch <frosch@openttd.org>
parents:
8360
diff
changeset
|
384 if (GetTileMaxZ(tile) > z_start) return_cmd_error(STR_BRIDGE_TOO_LOW_FOR_TERRAIN); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
385 |
5930
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
386 if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile) && !replace_bridge) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
387 /* Disallow crossing bridges for the time being */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
388 return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
389 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
390 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
391 switch (GetTileType(tile)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
392 case MP_WATER: |
8471
1e4ea519bfaf
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138 <peter1138@openttd.org>
parents:
8413
diff
changeset
|
393 if (!IsWater(tile) && !IsCoast(tile)) goto not_valid_below; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
394 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
395 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
396 case MP_RAILWAY: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
397 if (!IsPlainRailTile(tile)) goto not_valid_below; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
398 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
399 |
7370
fba35a9abf79
(svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium <rubidium@openttd.org>
parents:
7335
diff
changeset
|
400 case MP_ROAD: |
8563
992fa65afba1
(svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents:
8549
diff
changeset
|
401 if (IsRoadDepot(tile)) goto not_valid_below; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
402 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
403 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
404 case MP_TUNNELBRIDGE: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
405 if (IsTunnel(tile)) break; |
5930
a1fddb50c05c
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros <maedhros@openttd.org>
parents:
5852
diff
changeset
|
406 if (replace_bridge) break; |
8083
e02014b06c7f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
8081
diff
changeset
|
407 if (direction == DiagDirToAxis(GetTunnelBridgeDirection(tile))) goto not_valid_below; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
408 if (z_start < GetBridgeHeight(tile)) goto not_valid_below; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
409 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
410 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
411 case MP_UNMOVABLE: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
412 if (!IsOwnedLand(tile)) goto not_valid_below; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
413 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
414 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
415 case MP_CLEAR: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
416 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
417 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
418 default: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
419 not_valid_below:; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
420 /* try and clear the middle landscape */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
421 ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
422 if (CmdFailed(ret)) return ret; |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6943
diff
changeset
|
423 cost.AddCost(ret); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
424 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
425 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
426 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
427 if (flags & DC_EXEC) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
428 SetBridgeMiddle(tile, direction); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
429 MarkTileDirtyByTile(tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
430 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
431 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
432 |
8530
6a0cdc5bc1b1
(svn r12105) -Codechange: Use TransportType instead of guessing what kind of bridge we are preparing to build
belugas <belugas@openttd.org>
parents:
8528
diff
changeset
|
433 if (flags & DC_EXEC && transport_type == TRANSPORT_RAIL) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
434 Track track = AxisToTrack(direction); |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10140
diff
changeset
|
435 AddSideToSignalBuffer(tile_start, INVALID_DIAGDIR, _current_company); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
436 YapfNotifyTrackLayoutChange(tile_start, track); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
437 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
438 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
439 /* for human player that builds the bridge he gets a selection to choose from bridges (DC_QUERY_COST) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
440 * It's unnecessary to execute this command every time for every bridge. So it is done only |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
441 * and cost is computed in "bridge_gui.c". For AI, Towns this has to be of course calculated |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
442 */ |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10140
diff
changeset
|
443 if (!(flags & DC_QUERY_COST) || (IsValidCompanyID(_current_company) && GetCompany(_current_company)->is_ai)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
444 bridge_len += 2; // begin and end tiles/ramps |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
445 |
10696
7edccbb67398
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
truebrain <truebrain@openttd.org>
parents:
10647
diff
changeset
|
446 if (IsValidCompanyID(_current_company)) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
447 bridge_len = CalcBridgeLenCostFactor(bridge_len); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
448 |
8491
cf57eb06b4d9
(svn r12066) -Codechange: Rename GetBridge for the more common GetBridgeSpec
belugas <belugas@openttd.org>
parents:
8489
diff
changeset
|
449 cost.AddCost((int64)bridge_len * _price.build_bridge * GetBridgeSpec(bridge_type)->price >> 8); |
9492
d68dd1843f67
(svn r13468) -Fix: make aqueducts a little more expensive than normal bridges and disable terraforming of aqueduct bridgeheads; one can't terraform normal canal tiles either.
rubidium <rubidium@openttd.org>
parents:
9491
diff
changeset
|
450 |
d68dd1843f67
(svn r13468) -Fix: make aqueducts a little more expensive than normal bridges and disable terraforming of aqueduct bridgeheads; one can't terraform normal canal tiles either.
rubidium <rubidium@openttd.org>
parents:
9491
diff
changeset
|
451 /* Aqueducts are a little more expensive. */ |
d68dd1843f67
(svn r13468) -Fix: make aqueducts a little more expensive than normal bridges and disable terraforming of aqueduct bridgeheads; one can't terraform normal canal tiles either.
rubidium <rubidium@openttd.org>
parents:
9491
diff
changeset
|
452 if (transport_type == TRANSPORT_WATER) cost.AddCost((int64)bridge_len * _price.clear_water); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
453 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
454 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
455 return cost; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
456 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
457 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
458 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
459 /** Build Tunnel. |
6484
17fdaec13730
(svn r9665) -Documentation: Doxygen corrections,errors, corrections of corrections...
belugas <belugas@openttd.org>
parents:
6427
diff
changeset
|
460 * @param start_tile start tile of tunnel |
6422
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
461 * @param flags type of operation |
6661
5850ac8865e8
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents:
6537
diff
changeset
|
462 * @param p1 railtype or roadtypes. bit 9 set means road tunnel |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
463 * @param p2 unused |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
464 */ |
11090
df23c4e04638
(svn r15434) -Codechange: bit of type safety for the DC_xxx flags.
rubidium <rubidium@openttd.org>
parents:
11069
diff
changeset
|
465 CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
466 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
467 TileIndexDiff delta; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
468 TileIndex end_tile; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
469 DiagDirection direction; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
470 Slope start_tileh; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
471 Slope end_tileh; |
8549
24eb7d2b8315
(svn r12127) -Codechange: Use a variable instead of calling the same function a few times. Again. Just a different value.
belugas <belugas@openttd.org>
parents:
8548
diff
changeset
|
472 TransportType transport_type = (TransportType)GB(p1, 9, 1); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
473 uint start_z; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
474 uint end_z; |
8230
5b61305fcdd4
(svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium <rubidium@openttd.org>
parents:
8224
diff
changeset
|
475 CommandCost cost(EXPENSES_CONSTRUCTION); |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6857
diff
changeset
|
476 CommandCost ret; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
477 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
478 _build_tunnel_endtile = 0; |
8549
24eb7d2b8315
(svn r12127) -Codechange: Use a variable instead of calling the same function a few times. Again. Just a different value.
belugas <belugas@openttd.org>
parents:
8548
diff
changeset
|
479 if (transport_type == TRANSPORT_RAIL) { |
8236
d1191295967a
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium <rubidium@openttd.org>
parents:
8232
diff
changeset
|
480 if (!ValParamRailtype((RailType)p1)) return CMD_ERROR; |
7857
707c26c48f4e
(svn r11407) -Fix: do not allow building of tram-tracks when they are not available (SmatZ)
truelight <truelight@openttd.org>
parents:
7849
diff
changeset
|
481 } else { |
11252
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
482 const RoadTypes rts = (RoadTypes)GB(p1, 0, 2); |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10140
diff
changeset
|
483 if (!AreValidRoadTypes(rts) || !HasRoadTypesAvail(_current_company, rts)) return CMD_ERROR; |
6661
5850ac8865e8
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents:
6537
diff
changeset
|
484 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
485 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
486 start_tileh = GetTileSlope(start_tile, &start_z); |
8413
5c456105e68a
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch <frosch@openttd.org>
parents:
8398
diff
changeset
|
487 direction = GetInclinedSlopeDirection(start_tileh); |
5c456105e68a
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch <frosch@openttd.org>
parents:
8398
diff
changeset
|
488 if (direction == INVALID_DIAGDIR) return_cmd_error(STR_500B_SITE_UNSUITABLE_FOR_TUNNEL); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
489 |
8471
1e4ea519bfaf
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138 <peter1138@openttd.org>
parents:
8413
diff
changeset
|
490 if (IsWaterTile(start_tile)) return_cmd_error(STR_3807_CAN_T_BUILD_ON_WATER); |
8385
df9c00eb5699
(svn r11955) -Fix (r11926): Prevent bridge and tunnel ends being placed on rivers.
peter1138 <peter1138@openttd.org>
parents:
8379
diff
changeset
|
491 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
492 ret = DoCommand(start_tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
493 if (CmdFailed(ret)) return ret; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
494 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
495 /* XXX - do NOT change 'ret' in the loop, as it is used as the price |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
496 * for the clearing of the entrance of the tunnel. Assigning it to |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
497 * cost before the loop will yield different costs depending on start- |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
498 * position, because of increased-cost-by-length: 'cost += cost >> 3' */ |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6943
diff
changeset
|
499 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
500 delta = TileOffsByDiagDir(direction); |
7002
fa75522e0249
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium <rubidium@openttd.org>
parents:
6992
diff
changeset
|
501 DiagDirection tunnel_in_way_dir; |
9224
c8a0fa0e208a
(svn r13090) -Codechange: add functions for direct conversion from DiagDirection to Track and Trackbits
smatz <smatz@openttd.org>
parents:
9154
diff
changeset
|
502 if (DiagDirToAxis(direction) == AXIS_Y) { |
7002
fa75522e0249
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium <rubidium@openttd.org>
parents:
6992
diff
changeset
|
503 tunnel_in_way_dir = (TileX(start_tile) < (MapMaxX() / 2)) ? DIAGDIR_SW : DIAGDIR_NE; |
fa75522e0249
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium <rubidium@openttd.org>
parents:
6992
diff
changeset
|
504 } else { |
fa75522e0249
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium <rubidium@openttd.org>
parents:
6992
diff
changeset
|
505 tunnel_in_way_dir = (TileY(start_tile) < (MapMaxX() / 2)) ? DIAGDIR_SE : DIAGDIR_NW; |
fa75522e0249
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium <rubidium@openttd.org>
parents:
6992
diff
changeset
|
506 } |
fa75522e0249
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium <rubidium@openttd.org>
parents:
6992
diff
changeset
|
507 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
508 end_tile = start_tile; |
7095
cfd4d752ab7f
(svn r10362) -Codechange: make tunnel costs less exponential for (very) long tunnels.
rubidium <rubidium@openttd.org>
parents:
7044
diff
changeset
|
509 |
cfd4d752ab7f
(svn r10362) -Codechange: make tunnel costs less exponential for (very) long tunnels.
rubidium <rubidium@openttd.org>
parents:
7044
diff
changeset
|
510 /** Tile shift coeficient. Will decrease for very long tunnels to avoid exponential growth of price*/ |
cfd4d752ab7f
(svn r10362) -Codechange: make tunnel costs less exponential for (very) long tunnels.
rubidium <rubidium@openttd.org>
parents:
7044
diff
changeset
|
511 int tiles_coef = 3; |
cfd4d752ab7f
(svn r10362) -Codechange: make tunnel costs less exponential for (very) long tunnels.
rubidium <rubidium@openttd.org>
parents:
7044
diff
changeset
|
512 /** Number of tiles from start of tunnel */ |
cfd4d752ab7f
(svn r10362) -Codechange: make tunnel costs less exponential for (very) long tunnels.
rubidium <rubidium@openttd.org>
parents:
7044
diff
changeset
|
513 int tiles = 0; |
7308
45a7fdc97647
(svn r10660) -Codechange: simplified tunnel cost algorithm (bilbo)
truelight <truelight@openttd.org>
parents:
7266
diff
changeset
|
514 /** Number of tiles at which the cost increase coefficient per tile is halved */ |
45a7fdc97647
(svn r10660) -Codechange: simplified tunnel cost algorithm (bilbo)
truelight <truelight@openttd.org>
parents:
7266
diff
changeset
|
515 int tiles_bump = 25; |
7095
cfd4d752ab7f
(svn r10362) -Codechange: make tunnel costs less exponential for (very) long tunnels.
rubidium <rubidium@openttd.org>
parents:
7044
diff
changeset
|
516 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
517 for (;;) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
518 end_tile += delta; |
10855
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10696
diff
changeset
|
519 if (!IsValidTile(end_tile)) return_cmd_error(STR_TUNNEL_THROUGH_MAP_BORDER); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
520 end_tileh = GetTileSlope(end_tile, &end_z); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
521 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
522 if (start_z == end_z) break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
523 |
7002
fa75522e0249
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium <rubidium@openttd.org>
parents:
6992
diff
changeset
|
524 if (!_cheats.crossing_tunnels.value && IsTunnelInWayDir(end_tile, start_z, tunnel_in_way_dir)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
525 return_cmd_error(STR_5003_ANOTHER_TUNNEL_IN_THE_WAY); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
526 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
527 |
7095
cfd4d752ab7f
(svn r10362) -Codechange: make tunnel costs less exponential for (very) long tunnels.
rubidium <rubidium@openttd.org>
parents:
7044
diff
changeset
|
528 tiles++; |
7308
45a7fdc97647
(svn r10660) -Codechange: simplified tunnel cost algorithm (bilbo)
truelight <truelight@openttd.org>
parents:
7266
diff
changeset
|
529 if (tiles == tiles_bump) { |
45a7fdc97647
(svn r10660) -Codechange: simplified tunnel cost algorithm (bilbo)
truelight <truelight@openttd.org>
parents:
7266
diff
changeset
|
530 tiles_coef++; |
45a7fdc97647
(svn r10660) -Codechange: simplified tunnel cost algorithm (bilbo)
truelight <truelight@openttd.org>
parents:
7266
diff
changeset
|
531 tiles_bump *= 2; |
45a7fdc97647
(svn r10660) -Codechange: simplified tunnel cost algorithm (bilbo)
truelight <truelight@openttd.org>
parents:
7266
diff
changeset
|
532 } |
7095
cfd4d752ab7f
(svn r10362) -Codechange: make tunnel costs less exponential for (very) long tunnels.
rubidium <rubidium@openttd.org>
parents:
7044
diff
changeset
|
533 |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6943
diff
changeset
|
534 cost.AddCost(_price.build_tunnel); |
7095
cfd4d752ab7f
(svn r10362) -Codechange: make tunnel costs less exponential for (very) long tunnels.
rubidium <rubidium@openttd.org>
parents:
7044
diff
changeset
|
535 cost.AddCost(cost.GetCost() >> tiles_coef); // add a multiplier for longer tunnels |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
536 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
537 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
538 /* Add the cost of the entrance */ |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6943
diff
changeset
|
539 cost.AddCost(_price.build_tunnel); |
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6943
diff
changeset
|
540 cost.AddCost(ret); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
541 |
6422
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
542 /* if the command fails from here on we want the end tile to be highlighted */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
543 _build_tunnel_endtile = end_tile; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
544 |
8471
1e4ea519bfaf
(svn r12042) -Fix [FS#1676]: Reimplement how rivers and canals are stored in the map, allowing the sea/river/canal status to also be
peter1138 <peter1138@openttd.org>
parents:
8413
diff
changeset
|
545 if (IsWaterTile(end_tile)) return_cmd_error(STR_3807_CAN_T_BUILD_ON_WATER); |
8385
df9c00eb5699
(svn r11955) -Fix (r11926): Prevent bridge and tunnel ends being placed on rivers.
peter1138 <peter1138@openttd.org>
parents:
8379
diff
changeset
|
546 |
6422
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
547 /* slope of end tile must be complementary to the slope of the start tile */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
548 if (end_tileh != ComplementSlope(start_tileh)) { |
10362
bc96789f4e9c
(svn r14613) -Fix [FS#2420]: When building industries, clear the tiles as OWNER_TOWN instead of the founder to take care of protected buildings and to not get stressed by town ratings.
frosch <frosch@openttd.org>
parents:
10236
diff
changeset
|
549 /* Check if there is a structure on the terraformed tile. Do not add the cost, that will be done by the terraforming |
bc96789f4e9c
(svn r14613) -Fix [FS#2420]: When building industries, clear the tiles as OWNER_TOWN instead of the founder to take care of protected buildings and to not get stressed by town ratings.
frosch <frosch@openttd.org>
parents:
10236
diff
changeset
|
550 * Note: Currently the town rating is also affected by this clearing-test. So effectivly the player is punished twice for clearing |
bc96789f4e9c
(svn r14613) -Fix [FS#2420]: When building industries, clear the tiles as OWNER_TOWN instead of the founder to take care of protected buildings and to not get stressed by town ratings.
frosch <frosch@openttd.org>
parents:
10236
diff
changeset
|
551 * the tree on end_tile. |
bc96789f4e9c
(svn r14613) -Fix [FS#2420]: When building industries, clear the tiles as OWNER_TOWN instead of the founder to take care of protected buildings and to not get stressed by town ratings.
frosch <frosch@openttd.org>
parents:
10236
diff
changeset
|
552 */ |
7677
27b41a7a9258
(svn r11208) -Fix [FS#1300]: tunnel excavation could disown somebody elses owned land. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
553 ret = DoCommand(end_tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR); |
27b41a7a9258
(svn r11208) -Fix [FS#1300]: tunnel excavation could disown somebody elses owned land. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
554 if (CmdFailed(ret)) return_cmd_error(STR_5005_UNABLE_TO_EXCAVATE_LAND); |
7042
6ce0b3b18d8e
(svn r10306) -Fix [FS#890]: the fix in r10219 was not enough to stop this bug from happening.
rubidium <rubidium@openttd.org>
parents:
7003
diff
changeset
|
555 |
7677
27b41a7a9258
(svn r11208) -Fix [FS#1300]: tunnel excavation could disown somebody elses owned land. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
556 ret = DoCommand(end_tile, end_tileh & start_tileh, 0, flags, CMD_TERRAFORM_LAND); |
27b41a7a9258
(svn r11208) -Fix [FS#1300]: tunnel excavation could disown somebody elses owned land. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
557 if (CmdFailed(ret)) return_cmd_error(STR_5005_UNABLE_TO_EXCAVATE_LAND); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
558 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
559 ret = DoCommand(end_tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
560 if (CmdFailed(ret)) return ret; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
561 } |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6943
diff
changeset
|
562 cost.AddCost(_price.build_tunnel); |
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6943
diff
changeset
|
563 cost.AddCost(ret); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
564 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
565 if (flags & DC_EXEC) { |
8549
24eb7d2b8315
(svn r12127) -Codechange: Use a variable instead of calling the same function a few times. Again. Just a different value.
belugas <belugas@openttd.org>
parents:
8548
diff
changeset
|
566 if (transport_type == TRANSPORT_RAIL) { |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10140
diff
changeset
|
567 MakeRailTunnel(start_tile, _current_company, direction, (RailType)GB(p1, 0, 4)); |
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10140
diff
changeset
|
568 MakeRailTunnel(end_tile, _current_company, ReverseDiagDir(direction), (RailType)GB(p1, 0, 4)); |
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10140
diff
changeset
|
569 AddSideToSignalBuffer(start_tile, INVALID_DIAGDIR, _current_company); |
9224
c8a0fa0e208a
(svn r13090) -Codechange: add functions for direct conversion from DiagDirection to Track and Trackbits
smatz <smatz@openttd.org>
parents:
9154
diff
changeset
|
570 YapfNotifyTrackLayoutChange(start_tile, DiagDirToDiagTrack(direction)); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
571 } else { |
11252
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
572 MakeRoadTunnel(start_tile, _current_company, direction, (RoadTypes)GB(p1, 0, 2)); |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
573 MakeRoadTunnel(end_tile, _current_company, ReverseDiagDir(direction), (RoadTypes)GB(p1, 0, 2)); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
574 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
575 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
576 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
577 return cost; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
578 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
579 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
580 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
581 static inline bool CheckAllowRemoveTunnelBridge(TileIndex tile) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
582 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
583 /* Floods can remove anything as well as the scenario editor */ |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10140
diff
changeset
|
584 if (_current_company == OWNER_WATER || _game_mode == GM_EDITOR) return true; |
11252
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
585 |
11317
b1f20aa98ab3
(svn r15667) -Fix (r15601)[FS#2718]: It was possible to remove rail tunnels/bridges and aqueducts build by rival companies.
yexo <yexo@openttd.org>
parents:
11252
diff
changeset
|
586 switch (GetTunnelBridgeTransportType(tile)) { |
b1f20aa98ab3
(svn r15667) -Fix (r15601)[FS#2718]: It was possible to remove rail tunnels/bridges and aqueducts build by rival companies.
yexo <yexo@openttd.org>
parents:
11252
diff
changeset
|
587 case TRANSPORT_ROAD: { |
b1f20aa98ab3
(svn r15667) -Fix (r15601)[FS#2718]: It was possible to remove rail tunnels/bridges and aqueducts build by rival companies.
yexo <yexo@openttd.org>
parents:
11252
diff
changeset
|
588 RoadTypes rts = GetRoadTypes(tile); |
b1f20aa98ab3
(svn r15667) -Fix (r15601)[FS#2718]: It was possible to remove rail tunnels/bridges and aqueducts build by rival companies.
yexo <yexo@openttd.org>
parents:
11252
diff
changeset
|
589 Owner road_owner = _current_company; |
b1f20aa98ab3
(svn r15667) -Fix (r15601)[FS#2718]: It was possible to remove rail tunnels/bridges and aqueducts build by rival companies.
yexo <yexo@openttd.org>
parents:
11252
diff
changeset
|
590 Owner tram_owner = _current_company; |
b1f20aa98ab3
(svn r15667) -Fix (r15601)[FS#2718]: It was possible to remove rail tunnels/bridges and aqueducts build by rival companies.
yexo <yexo@openttd.org>
parents:
11252
diff
changeset
|
591 |
b1f20aa98ab3
(svn r15667) -Fix (r15601)[FS#2718]: It was possible to remove rail tunnels/bridges and aqueducts build by rival companies.
yexo <yexo@openttd.org>
parents:
11252
diff
changeset
|
592 if (HasBit(rts, ROADTYPE_ROAD)) road_owner = GetRoadOwner(tile, ROADTYPE_ROAD); |
b1f20aa98ab3
(svn r15667) -Fix (r15601)[FS#2718]: It was possible to remove rail tunnels/bridges and aqueducts build by rival companies.
yexo <yexo@openttd.org>
parents:
11252
diff
changeset
|
593 if (HasBit(rts, ROADTYPE_TRAM)) tram_owner = GetRoadOwner(tile, ROADTYPE_TRAM); |
11252
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
594 |
11317
b1f20aa98ab3
(svn r15667) -Fix (r15601)[FS#2718]: It was possible to remove rail tunnels/bridges and aqueducts build by rival companies.
yexo <yexo@openttd.org>
parents:
11252
diff
changeset
|
595 /* We can remove unowned road and if the town allows it */ |
11333
a888a90f770c
(svn r15683) -Fix (r15670): Removing town-owned bridges was no longer possible.
yexo <yexo@openttd.org>
parents:
11320
diff
changeset
|
596 if (road_owner == OWNER_TOWN && !(_settings_game.construction.extra_dynamite || _cheats.magic_bulldozer.value)) return CheckTileOwnership(tile); |
a888a90f770c
(svn r15683) -Fix (r15670): Removing town-owned bridges was no longer possible.
yexo <yexo@openttd.org>
parents:
11320
diff
changeset
|
597 if (road_owner == OWNER_NONE || road_owner == OWNER_TOWN) road_owner = _current_company; |
11317
b1f20aa98ab3
(svn r15667) -Fix (r15601)[FS#2718]: It was possible to remove rail tunnels/bridges and aqueducts build by rival companies.
yexo <yexo@openttd.org>
parents:
11252
diff
changeset
|
598 if (tram_owner == OWNER_NONE) tram_owner = _current_company; |
b1f20aa98ab3
(svn r15667) -Fix (r15601)[FS#2718]: It was possible to remove rail tunnels/bridges and aqueducts build by rival companies.
yexo <yexo@openttd.org>
parents:
11252
diff
changeset
|
599 |
11333
a888a90f770c
(svn r15683) -Fix (r15670): Removing town-owned bridges was no longer possible.
yexo <yexo@openttd.org>
parents:
11320
diff
changeset
|
600 return CheckOwnership(road_owner) && CheckOwnership(tram_owner); |
11317
b1f20aa98ab3
(svn r15667) -Fix (r15601)[FS#2718]: It was possible to remove rail tunnels/bridges and aqueducts build by rival companies.
yexo <yexo@openttd.org>
parents:
11252
diff
changeset
|
601 } |
11252
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
602 |
11317
b1f20aa98ab3
(svn r15667) -Fix (r15601)[FS#2718]: It was possible to remove rail tunnels/bridges and aqueducts build by rival companies.
yexo <yexo@openttd.org>
parents:
11252
diff
changeset
|
603 case TRANSPORT_RAIL: |
b1f20aa98ab3
(svn r15667) -Fix (r15601)[FS#2718]: It was possible to remove rail tunnels/bridges and aqueducts build by rival companies.
yexo <yexo@openttd.org>
parents:
11252
diff
changeset
|
604 case TRANSPORT_WATER: |
b1f20aa98ab3
(svn r15667) -Fix (r15601)[FS#2718]: It was possible to remove rail tunnels/bridges and aqueducts build by rival companies.
yexo <yexo@openttd.org>
parents:
11252
diff
changeset
|
605 return CheckOwnership(GetTileOwner(tile)); |
11252
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
606 |
11317
b1f20aa98ab3
(svn r15667) -Fix (r15601)[FS#2718]: It was possible to remove rail tunnels/bridges and aqueducts build by rival companies.
yexo <yexo@openttd.org>
parents:
11252
diff
changeset
|
607 default: NOT_REACHED(); |
b1f20aa98ab3
(svn r15667) -Fix (r15601)[FS#2718]: It was possible to remove rail tunnels/bridges and aqueducts build by rival companies.
yexo <yexo@openttd.org>
parents:
11252
diff
changeset
|
608 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
609 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
610 |
11090
df23c4e04638
(svn r15434) -Codechange: bit of type safety for the DC_xxx flags.
rubidium <rubidium@openttd.org>
parents:
11069
diff
changeset
|
611 static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
612 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
613 Town *t = NULL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
614 TileIndex endtile; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
615 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
616 if (!CheckAllowRemoveTunnelBridge(tile)) return CMD_ERROR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
617 |
8072
0cba7093ca14
(svn r11633) -Codechange: merge CheckTunnelEmpty and IsVehicleOnBridge into GetVehicleTunnelBridge
smatz <smatz@openttd.org>
parents:
8043
diff
changeset
|
618 endtile = GetOtherTunnelEnd(tile); |
0cba7093ca14
(svn r11633) -Codechange: merge CheckTunnelEmpty and IsVehicleOnBridge into GetVehicleTunnelBridge
smatz <smatz@openttd.org>
parents:
8043
diff
changeset
|
619 |
10083
4923bdc50041
(svn r14258) -Codechange: rework the way to query the vehicle hash to make sure it always results in the same irregardless of the order of the hash-linked-list.
rubidium <rubidium@openttd.org>
parents:
10017
diff
changeset
|
620 if (HasVehicleOnTunnelBridge(tile, endtile)) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
621 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
622 _build_tunnel_endtile = endtile; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
623 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
624 if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) { |
10236
59398a628f10
(svn r14464) -Codechange: replace (uint)-1 with UINT_MAX (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10208
diff
changeset
|
625 t = ClosestTownFromTile(tile, UINT_MAX); // town penalty rating |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
626 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
627 /* Check if you are allowed to remove the tunnel owned by a town |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
628 * Removal depends on difficulty settings */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
629 if (!CheckforTownRating(flags, t, TUNNELBRIDGE_REMOVE)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
630 SetDParam(0, t->index); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
631 return_cmd_error(STR_2009_LOCAL_AUTHORITY_REFUSES); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
632 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
633 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
634 |
8232
cca79a4335e0
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx <glx@openttd.org>
parents:
8230
diff
changeset
|
635 /* checks if the owner is town then decrease town rating by RATING_TUNNEL_BRIDGE_DOWN_STEP until |
cca79a4335e0
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx <glx@openttd.org>
parents:
8230
diff
changeset
|
636 * you have a "Poor" (0) town rating */ |
cca79a4335e0
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx <glx@openttd.org>
parents:
8230
diff
changeset
|
637 if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) { |
11106
ada4c4d48050
(svn r15452) -Codechange: Add DC_NO_MODIFY_TOWN_RATING.
frosch <frosch@openttd.org>
parents:
11090
diff
changeset
|
638 ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM, flags); |
8232
cca79a4335e0
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx <glx@openttd.org>
parents:
8230
diff
changeset
|
639 } |
cca79a4335e0
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx <glx@openttd.org>
parents:
8230
diff
changeset
|
640 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
641 if (flags & DC_EXEC) { |
8300
ae1baac75172
(svn r11864) -Codechange: pass owner whose signals we will update instead of complex detection later
smatz <smatz@openttd.org>
parents:
8297
diff
changeset
|
642 if (GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) { |
ae1baac75172
(svn r11864) -Codechange: pass owner whose signals we will update instead of complex detection later
smatz <smatz@openttd.org>
parents:
8297
diff
changeset
|
643 /* We first need to request values before calling DoClearSquare */ |
ae1baac75172
(svn r11864) -Codechange: pass owner whose signals we will update instead of complex detection later
smatz <smatz@openttd.org>
parents:
8297
diff
changeset
|
644 DiagDirection dir = GetTunnelBridgeDirection(tile); |
9815
108e72c7bb36
(svn r13957) -Codechange [YAPP]: Free the old path reservation on removing some tracks and reroute trains afterwards. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9785
diff
changeset
|
645 Track track = DiagDirToDiagTrack(dir); |
8300
ae1baac75172
(svn r11864) -Codechange: pass owner whose signals we will update instead of complex detection later
smatz <smatz@openttd.org>
parents:
8297
diff
changeset
|
646 Owner owner = GetTileOwner(tile); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
647 |
9815
108e72c7bb36
(svn r13957) -Codechange [YAPP]: Free the old path reservation on removing some tracks and reroute trains afterwards. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9785
diff
changeset
|
648 Vehicle *v = NULL; |
108e72c7bb36
(svn r13957) -Codechange [YAPP]: Free the old path reservation on removing some tracks and reroute trains afterwards. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9785
diff
changeset
|
649 if (GetTunnelBridgeReservation(tile)) { |
108e72c7bb36
(svn r13957) -Codechange [YAPP]: Free the old path reservation on removing some tracks and reroute trains afterwards. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9785
diff
changeset
|
650 v = GetTrainForReservation(tile, track); |
108e72c7bb36
(svn r13957) -Codechange [YAPP]: Free the old path reservation on removing some tracks and reroute trains afterwards. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9785
diff
changeset
|
651 if (v != NULL) FreeTrainTrackReservation(v); |
108e72c7bb36
(svn r13957) -Codechange [YAPP]: Free the old path reservation on removing some tracks and reroute trains afterwards. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9785
diff
changeset
|
652 } |
108e72c7bb36
(svn r13957) -Codechange [YAPP]: Free the old path reservation on removing some tracks and reroute trains afterwards. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9785
diff
changeset
|
653 |
8300
ae1baac75172
(svn r11864) -Codechange: pass owner whose signals we will update instead of complex detection later
smatz <smatz@openttd.org>
parents:
8297
diff
changeset
|
654 DoClearSquare(tile); |
ae1baac75172
(svn r11864) -Codechange: pass owner whose signals we will update instead of complex detection later
smatz <smatz@openttd.org>
parents:
8297
diff
changeset
|
655 DoClearSquare(endtile); |
8297
6556baf1d76d
(svn r11861) -Fix: do not call rail specific functions when removing road tunnel/bridge
smatz <smatz@openttd.org>
parents:
8264
diff
changeset
|
656 |
8300
ae1baac75172
(svn r11864) -Codechange: pass owner whose signals we will update instead of complex detection later
smatz <smatz@openttd.org>
parents:
8297
diff
changeset
|
657 /* cannot use INVALID_DIAGDIR for signal update because the tunnel doesn't exist anymore */ |
8625
0edb93b9e261
(svn r12208) -Codechange: Alignment of params makes the code easier to read.
belugas <belugas@openttd.org>
parents:
8616
diff
changeset
|
658 AddSideToSignalBuffer(tile, ReverseDiagDir(dir), owner); |
0edb93b9e261
(svn r12208) -Codechange: Alignment of params makes the code easier to read.
belugas <belugas@openttd.org>
parents:
8616
diff
changeset
|
659 AddSideToSignalBuffer(endtile, dir, owner); |
8297
6556baf1d76d
(svn r11861) -Fix: do not call rail specific functions when removing road tunnel/bridge
smatz <smatz@openttd.org>
parents:
8264
diff
changeset
|
660 |
8625
0edb93b9e261
(svn r12208) -Codechange: Alignment of params makes the code easier to read.
belugas <belugas@openttd.org>
parents:
8616
diff
changeset
|
661 YapfNotifyTrackLayoutChange(tile, track); |
8297
6556baf1d76d
(svn r11861) -Fix: do not call rail specific functions when removing road tunnel/bridge
smatz <smatz@openttd.org>
parents:
8264
diff
changeset
|
662 YapfNotifyTrackLayoutChange(endtile, track); |
9815
108e72c7bb36
(svn r13957) -Codechange [YAPP]: Free the old path reservation on removing some tracks and reroute trains afterwards. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9785
diff
changeset
|
663 |
108e72c7bb36
(svn r13957) -Codechange [YAPP]: Free the old path reservation on removing some tracks and reroute trains afterwards. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9785
diff
changeset
|
664 if (v != NULL) TryPathReserve(v); |
8300
ae1baac75172
(svn r11864) -Codechange: pass owner whose signals we will update instead of complex detection later
smatz <smatz@openttd.org>
parents:
8297
diff
changeset
|
665 } else { |
ae1baac75172
(svn r11864) -Codechange: pass owner whose signals we will update instead of complex detection later
smatz <smatz@openttd.org>
parents:
8297
diff
changeset
|
666 DoClearSquare(tile); |
ae1baac75172
(svn r11864) -Codechange: pass owner whose signals we will update instead of complex detection later
smatz <smatz@openttd.org>
parents:
8297
diff
changeset
|
667 DoClearSquare(endtile); |
8297
6556baf1d76d
(svn r11861) -Fix: do not call rail specific functions when removing road tunnel/bridge
smatz <smatz@openttd.org>
parents:
8264
diff
changeset
|
668 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
669 } |
8398
a6304b304752
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz <smatz@openttd.org>
parents:
8390
diff
changeset
|
670 return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_tunnel * (GetTunnelBridgeLength(tile, endtile) + 2)); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
671 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
672 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
673 |
11090
df23c4e04638
(svn r15434) -Codechange: bit of type safety for the DC_xxx flags.
rubidium <rubidium@openttd.org>
parents:
11069
diff
changeset
|
674 static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
675 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
676 DiagDirection direction; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
677 TileIndexDiff delta; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
678 TileIndex endtile; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
679 Town *t = NULL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
680 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
681 if (!CheckAllowRemoveTunnelBridge(tile)) return CMD_ERROR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
682 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
683 endtile = GetOtherBridgeEnd(tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
684 |
10083
4923bdc50041
(svn r14258) -Codechange: rework the way to query the vehicle hash to make sure it always results in the same irregardless of the order of the hash-linked-list.
rubidium <rubidium@openttd.org>
parents:
10017
diff
changeset
|
685 if (HasVehicleOnTunnelBridge(tile, endtile)) return CMD_ERROR; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
686 |
8083
e02014b06c7f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
8081
diff
changeset
|
687 direction = GetTunnelBridgeDirection(tile); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
688 delta = TileOffsByDiagDir(direction); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
689 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
690 if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) { |
10236
59398a628f10
(svn r14464) -Codechange: replace (uint)-1 with UINT_MAX (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10208
diff
changeset
|
691 t = ClosestTownFromTile(tile, UINT_MAX); // town penalty rating |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
692 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
693 /* Check if you are allowed to remove the bridge owned by a town |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
694 * Removal depends on difficulty settings */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
695 if (!CheckforTownRating(flags, t, TUNNELBRIDGE_REMOVE)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
696 SetDParam(0, t->index); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
697 return_cmd_error(STR_2009_LOCAL_AUTHORITY_REFUSES); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
698 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
699 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
700 |
8232
cca79a4335e0
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx <glx@openttd.org>
parents:
8230
diff
changeset
|
701 /* checks if the owner is town then decrease town rating by RATING_TUNNEL_BRIDGE_DOWN_STEP until |
cca79a4335e0
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx <glx@openttd.org>
parents:
8230
diff
changeset
|
702 * you have a "Poor" (0) town rating */ |
cca79a4335e0
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx <glx@openttd.org>
parents:
8230
diff
changeset
|
703 if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) { |
11106
ada4c4d48050
(svn r15452) -Codechange: Add DC_NO_MODIFY_TOWN_RATING.
frosch <frosch@openttd.org>
parents:
11090
diff
changeset
|
704 ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM, flags); |
8232
cca79a4335e0
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx <glx@openttd.org>
parents:
8230
diff
changeset
|
705 } |
cca79a4335e0
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx <glx@openttd.org>
parents:
8230
diff
changeset
|
706 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
707 if (flags & DC_EXEC) { |
8297
6556baf1d76d
(svn r11861) -Fix: do not call rail specific functions when removing road tunnel/bridge
smatz <smatz@openttd.org>
parents:
8264
diff
changeset
|
708 /* read this value before actual removal of bridge */ |
6556baf1d76d
(svn r11861) -Fix: do not call rail specific functions when removing road tunnel/bridge
smatz <smatz@openttd.org>
parents:
8264
diff
changeset
|
709 bool rail = GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL; |
8300
ae1baac75172
(svn r11864) -Codechange: pass owner whose signals we will update instead of complex detection later
smatz <smatz@openttd.org>
parents:
8297
diff
changeset
|
710 Owner owner = GetTileOwner(tile); |
8589
86a968000cc9
(svn r12170) -Fix: do not draw trees along road and street lights under low bridges (spotted by _minime_)
smatz <smatz@openttd.org>
parents:
8563
diff
changeset
|
711 uint height = GetBridgeHeight(tile); |
9815
108e72c7bb36
(svn r13957) -Codechange [YAPP]: Free the old path reservation on removing some tracks and reroute trains afterwards. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9785
diff
changeset
|
712 Vehicle *v = NULL; |
108e72c7bb36
(svn r13957) -Codechange [YAPP]: Free the old path reservation on removing some tracks and reroute trains afterwards. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9785
diff
changeset
|
713 |
108e72c7bb36
(svn r13957) -Codechange [YAPP]: Free the old path reservation on removing some tracks and reroute trains afterwards. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9785
diff
changeset
|
714 if (rail && GetTunnelBridgeReservation(tile)) { |
108e72c7bb36
(svn r13957) -Codechange [YAPP]: Free the old path reservation on removing some tracks and reroute trains afterwards. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9785
diff
changeset
|
715 v = GetTrainForReservation(tile, DiagDirToDiagTrack(direction)); |
108e72c7bb36
(svn r13957) -Codechange [YAPP]: Free the old path reservation on removing some tracks and reroute trains afterwards. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9785
diff
changeset
|
716 if (v != NULL) FreeTrainTrackReservation(v); |
108e72c7bb36
(svn r13957) -Codechange [YAPP]: Free the old path reservation on removing some tracks and reroute trains afterwards. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9785
diff
changeset
|
717 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
718 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
719 DoClearSquare(tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
720 DoClearSquare(endtile); |
8297
6556baf1d76d
(svn r11861) -Fix: do not call rail specific functions when removing road tunnel/bridge
smatz <smatz@openttd.org>
parents:
8264
diff
changeset
|
721 for (TileIndex c = tile + delta; c != endtile; c += delta) { |
8589
86a968000cc9
(svn r12170) -Fix: do not draw trees along road and street lights under low bridges (spotted by _minime_)
smatz <smatz@openttd.org>
parents:
8563
diff
changeset
|
722 /* do not let trees appear from 'nowhere' after removing bridge */ |
86a968000cc9
(svn r12170) -Fix: do not draw trees along road and street lights under low bridges (spotted by _minime_)
smatz <smatz@openttd.org>
parents:
8563
diff
changeset
|
723 if (IsNormalRoadTile(c) && GetRoadside(c) == ROADSIDE_TREES) { |
86a968000cc9
(svn r12170) -Fix: do not draw trees along road and street lights under low bridges (spotted by _minime_)
smatz <smatz@openttd.org>
parents:
8563
diff
changeset
|
724 uint minz = GetTileMaxZ(c) + 3 * TILE_HEIGHT; |
86a968000cc9
(svn r12170) -Fix: do not draw trees along road and street lights under low bridges (spotted by _minime_)
smatz <smatz@openttd.org>
parents:
8563
diff
changeset
|
725 if (height < minz) SetRoadside(c, ROADSIDE_PAVED); |
86a968000cc9
(svn r12170) -Fix: do not draw trees along road and street lights under low bridges (spotted by _minime_)
smatz <smatz@openttd.org>
parents:
8563
diff
changeset
|
726 } |
8297
6556baf1d76d
(svn r11861) -Fix: do not call rail specific functions when removing road tunnel/bridge
smatz <smatz@openttd.org>
parents:
8264
diff
changeset
|
727 ClearBridgeMiddle(c); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
728 MarkTileDirtyByTile(c); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
729 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
730 |
8297
6556baf1d76d
(svn r11861) -Fix: do not call rail specific functions when removing road tunnel/bridge
smatz <smatz@openttd.org>
parents:
8264
diff
changeset
|
731 if (rail) { |
8300
ae1baac75172
(svn r11864) -Codechange: pass owner whose signals we will update instead of complex detection later
smatz <smatz@openttd.org>
parents:
8297
diff
changeset
|
732 /* cannot use INVALID_DIAGDIR for signal update because the bridge doesn't exist anymore */ |
8625
0edb93b9e261
(svn r12208) -Codechange: Alignment of params makes the code easier to read.
belugas <belugas@openttd.org>
parents:
8616
diff
changeset
|
733 AddSideToSignalBuffer(tile, ReverseDiagDir(direction), owner); |
0edb93b9e261
(svn r12208) -Codechange: Alignment of params makes the code easier to read.
belugas <belugas@openttd.org>
parents:
8616
diff
changeset
|
734 AddSideToSignalBuffer(endtile, direction, owner); |
8297
6556baf1d76d
(svn r11861) -Fix: do not call rail specific functions when removing road tunnel/bridge
smatz <smatz@openttd.org>
parents:
8264
diff
changeset
|
735 |
9224
c8a0fa0e208a
(svn r13090) -Codechange: add functions for direct conversion from DiagDirection to Track and Trackbits
smatz <smatz@openttd.org>
parents:
9154
diff
changeset
|
736 Track track = DiagDirToDiagTrack(direction); |
8625
0edb93b9e261
(svn r12208) -Codechange: Alignment of params makes the code easier to read.
belugas <belugas@openttd.org>
parents:
8616
diff
changeset
|
737 YapfNotifyTrackLayoutChange(tile, track); |
8297
6556baf1d76d
(svn r11861) -Fix: do not call rail specific functions when removing road tunnel/bridge
smatz <smatz@openttd.org>
parents:
8264
diff
changeset
|
738 YapfNotifyTrackLayoutChange(endtile, track); |
9815
108e72c7bb36
(svn r13957) -Codechange [YAPP]: Free the old path reservation on removing some tracks and reroute trains afterwards. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9785
diff
changeset
|
739 |
108e72c7bb36
(svn r13957) -Codechange [YAPP]: Free the old path reservation on removing some tracks and reroute trains afterwards. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9785
diff
changeset
|
740 if (v != NULL) TryPathReserve(v, true); |
8297
6556baf1d76d
(svn r11861) -Fix: do not call rail specific functions when removing road tunnel/bridge
smatz <smatz@openttd.org>
parents:
8264
diff
changeset
|
741 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
742 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
743 |
8398
a6304b304752
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz <smatz@openttd.org>
parents:
8390
diff
changeset
|
744 return CommandCost(EXPENSES_CONSTRUCTION, (GetTunnelBridgeLength(tile, endtile) + 2) * _price.clear_bridge); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
745 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
746 |
11090
df23c4e04638
(svn r15434) -Codechange: bit of type safety for the DC_xxx flags.
rubidium <rubidium@openttd.org>
parents:
11069
diff
changeset
|
747 static CommandCost ClearTile_TunnelBridge(TileIndex tile, DoCommandFlag flags) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
748 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
749 if (IsTunnel(tile)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
750 if (flags & DC_AUTO) return_cmd_error(STR_5006_MUST_DEMOLISH_TUNNEL_FIRST); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
751 return DoClearTunnel(tile, flags); |
8390
381a22f19287
(svn r11960) -Cleanup: simplify some IsTunnel(Tile) / IsBridge(Tile) conditions
smatz <smatz@openttd.org>
parents:
8385
diff
changeset
|
752 } else { // IsBridge(tile) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
753 if (flags & DC_AUTO) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
754 return DoClearBridge(tile, flags); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
755 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
756 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
757 return CMD_ERROR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
758 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
759 |
6368
4e4f7827e7ed
(svn r9425) -Codechange/Fix (FS#689): Housekeeping in the convert rail functions: Changed the order of error checks to generate more meaningful error messages, added some doxygen comments and replaced bitshifting by proper mathematical operations
celestar <celestar@openttd.org>
parents:
6357
diff
changeset
|
760 /** |
7728
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
761 * Draws the pillars under high bridges. |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
762 * |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
763 * @param psid Image and palette of a bridge pillar. |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
764 * @param ti #TileInfo of current bridge-middle-tile. |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
765 * @param axis Orientation of bridge. |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
766 * @param type Bridge type. |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
767 * @param x Sprite X position of front pillar. |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
768 * @param y Sprite Y position of front pillar. |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
769 * @param z_bridge Absolute height of bridge bottom. |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
770 */ |
10647
592ae9307430
(svn r14949) -Cleanup: pointer coding style
rubidium <rubidium@openttd.org>
parents:
10532
diff
changeset
|
771 static void DrawBridgePillars(const PalSpriteID *psid, const TileInfo *ti, Axis axis, bool drawfarpillar, int x, int y, int z_bridge) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
772 { |
8806
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
773 /* Do not draw bridge pillars if they are invisible */ |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
774 if (IsInvisibilitySet(TO_BRIDGES)) return; |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
775 |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
776 SpriteID image = psid->sprite; |
8806
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
777 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
778 if (image != 0) { |
7728
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
779 /* "side" specifies the side the pillars stand on. |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
780 * The length of the pillars is then set to the height of the bridge over the corners of this edge. |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
781 * |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
782 * axis==AXIS_X axis==AXIS_Y |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
783 * side==false SW NW |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
784 * side==true NE SE |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
785 * |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
786 * I have no clue, why this was done this way. |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
787 */ |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7923
diff
changeset
|
788 bool side = HasBit(image, 0); |
7728
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
789 |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
790 /* "dir" means the edge the pillars stand on */ |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
791 DiagDirection dir = AxisToDiagDir(axis); |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
792 if (side != (axis == AXIS_Y)) dir = ReverseDiagDir(dir); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
793 |
7728
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
794 /* Determine ground height under pillars */ |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
795 int front_height = ti->z; |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
796 int back_height = ti->z; |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
797 GetSlopeZOnEdge(ti->tileh, dir, &front_height, &back_height); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
798 |
7728
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
799 /* x and y size of bounding-box of pillars */ |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
800 int w = (axis == AXIS_X ? 16 : 2); |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
801 int h = (axis == AXIS_X ? 2 : 16); |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
802 /* sprite position of back facing pillar */ |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
803 int x_back = x - (axis == AXIS_X ? 0 : 9); |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
804 int y_back = y - (axis == AXIS_X ? 9 : 0); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
805 |
7728
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
806 for (int cur_z = z_bridge; cur_z >= front_height || cur_z >= back_height; cur_z -= TILE_HEIGHT) { |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
807 /* Draw front facing pillar */ |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
808 if (cur_z >= front_height) { |
7849
e6ee8bfd9045
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas <belugas@openttd.org>
parents:
7845
diff
changeset
|
809 AddSortableSpriteToDraw(image, psid->pal, x, y, w, h, BB_HEIGHT_UNDER_BRIDGE - 5, cur_z, IsTransparencySet(TO_BRIDGES), 0, 0, -5); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
810 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
811 |
7728
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
812 /* Draw back facing pillar, but not the highest part directly under the bridge-floor */ |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
813 if (drawfarpillar && cur_z >= back_height && cur_z < z_bridge - TILE_HEIGHT) { |
7849
e6ee8bfd9045
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas <belugas@openttd.org>
parents:
7845
diff
changeset
|
814 AddSortableSpriteToDraw(image, psid->pal, x_back, y_back, w, h, BB_HEIGHT_UNDER_BRIDGE - 5, cur_z, IsTransparencySet(TO_BRIDGES), 0, 0, -5); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
815 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
816 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
817 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
818 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
819 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
820 /** |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
821 * Draws the trambits over an already drawn (lower end) of a bridge. |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
822 * @param x the x of the bridge |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
823 * @param y the y of the bridge |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
824 * @param z the z of the bridge |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
825 * @param offset number representing whether to level or sloped and the direction |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
826 * @param overlay do we want to still see the road? |
8806
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
827 * @param head are we drawing bridge head? |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
828 */ |
8806
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
829 static void DrawBridgeTramBits(int x, int y, byte z, int offset, bool overlay, bool head) |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
830 { |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
831 static const SpriteID tram_offsets[2][6] = { { 107, 108, 109, 110, 111, 112 }, { 4, 5, 15, 16, 17, 18 } }; |
7249
85c69a7a5aa4
(svn r10549) -Fix [FS#1031]: wrong tram catenary poles drawn in some bridge directions.
rubidium <rubidium@openttd.org>
parents:
7095
diff
changeset
|
832 static const SpriteID back_offsets[6] = { 95, 96, 99, 102, 100, 101 }; |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
833 static const SpriteID front_offsets[6] = { 97, 98, 103, 106, 104, 105 }; |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
834 |
7601
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
835 static const uint size_x[6] = { 1, 16, 16, 1, 16, 1 }; |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
836 static const uint size_y[6] = { 16, 1, 1, 16, 1, 16 }; |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
837 static const uint front_bb_offset_x[6] = { 15, 0, 0, 15, 0, 15 }; |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
838 static const uint front_bb_offset_y[6] = { 0, 15, 15, 0, 15, 0 }; |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
839 |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
840 /* The sprites under the vehicles are drawn as SpriteCombine. StartSpriteCombine() has already been called |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
841 * The bounding boxes here are the same as for bridge front/roof */ |
8806
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
842 if (head || !IsInvisibilitySet(TO_BRIDGES)) { |
8865
f78044f539de
(svn r12632) -Fix (r12547): with invisible catenary, trams were be drawn over a bridge
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
843 AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + tram_offsets[overlay][offset], PAL_NONE, |
f78044f539de
(svn r12632) -Fix (r12547): with invisible catenary, trams were be drawn over a bridge
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
844 x, y, size_x[offset], size_y[offset], 0x28, z, |
f78044f539de
(svn r12632) -Fix (r12547): with invisible catenary, trams were be drawn over a bridge
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
845 !head && IsTransparencySet(TO_BRIDGES)); |
8806
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
846 } |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
847 |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
848 /* Do not draw catenary if it is set invisible */ |
8865
f78044f539de
(svn r12632) -Fix (r12547): with invisible catenary, trams were be drawn over a bridge
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
849 if (!IsInvisibilitySet(TO_CATENARY)) { |
f78044f539de
(svn r12632) -Fix (r12547): with invisible catenary, trams were be drawn over a bridge
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
850 AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + back_offsets[offset], PAL_NONE, |
f78044f539de
(svn r12632) -Fix (r12547): with invisible catenary, trams were be drawn over a bridge
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
851 x, y, size_x[offset], size_y[offset], 0x28, z, |
f78044f539de
(svn r12632) -Fix (r12547): with invisible catenary, trams were be drawn over a bridge
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
852 IsTransparencySet(TO_CATENARY)); |
f78044f539de
(svn r12632) -Fix (r12547): with invisible catenary, trams were be drawn over a bridge
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
853 } |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
854 |
7601
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
855 /* Start a new SpriteCombine for the front part */ |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
856 EndSpriteCombine(); |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
857 StartSpriteCombine(); |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
858 |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
859 /* For sloped sprites the bounding box needs to be higher, as the pylons stop on a higher point */ |
8865
f78044f539de
(svn r12632) -Fix (r12547): with invisible catenary, trams were be drawn over a bridge
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
860 if (!IsInvisibilitySet(TO_CATENARY)) { |
f78044f539de
(svn r12632) -Fix (r12547): with invisible catenary, trams were be drawn over a bridge
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
861 AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + front_offsets[offset], PAL_NONE, |
f78044f539de
(svn r12632) -Fix (r12547): with invisible catenary, trams were be drawn over a bridge
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
862 x, y, size_x[offset] + front_bb_offset_x[offset], size_y[offset] + front_bb_offset_y[offset], 0x28, z, |
f78044f539de
(svn r12632) -Fix (r12547): with invisible catenary, trams were be drawn over a bridge
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
863 IsTransparencySet(TO_CATENARY), front_bb_offset_x[offset], front_bb_offset_y[offset]); |
f78044f539de
(svn r12632) -Fix (r12547): with invisible catenary, trams were be drawn over a bridge
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
864 } |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
865 } |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
866 |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
867 /** |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
868 * Draws a tunnel of bridge tile. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
869 * For tunnels, this is rather simple, as you only needa draw the entrance. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
870 * Bridges are a bit more complex. base_offset is where the sprite selection comes into play |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
871 * and it works a bit like a bitmask.<p> For bridge heads: |
6422
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
872 * @param ti TileInfo of the structure to draw |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
873 * <ul><li>Bit 0: direction</li> |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
874 * <li>Bit 1: northern or southern heads</li> |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
875 * <li>Bit 2: Set if the bridge head is sloped</li> |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
876 * <li>Bit 3 and more: Railtype Specific subset</li> |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
877 * </ul> |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
878 * Please note that in this code, "roads" are treated as railtype 1, whilst the real railtypes are 0, 2 and 3 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
879 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
880 static void DrawTile_TunnelBridge(TileInfo *ti) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
881 { |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
882 SpriteID image; |
8549
24eb7d2b8315
(svn r12127) -Codechange: Use a variable instead of calling the same function a few times. Again. Just a different value.
belugas <belugas@openttd.org>
parents:
8548
diff
changeset
|
883 TransportType transport_type = GetTunnelBridgeTransportType(ti->tile); |
8548
f19f2719271b
(svn r12126) -Codechange: Use a variable instead of calling the same function a few times
belugas <belugas@openttd.org>
parents:
8540
diff
changeset
|
884 DiagDirection tunnelbridge_direction = GetTunnelBridgeDirection(ti->tile); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
885 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
886 if (IsTunnel(ti->tile)) { |
7601
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
887 /* Front view of tunnel bounding boxes: |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
888 * |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
889 * 122223 <- BB_Z_SEPARATOR |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
890 * 1 3 |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
891 * 1 3 1,3 = empty helper BB |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
892 * 1 3 2 = SpriteCombine of tunnel-roof and catenary (tram & elrail) |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
893 * |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
894 */ |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
895 |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
896 static const int _tunnel_BB[4][12] = { |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
897 /* tunnnel-roof | Z-separator | tram-catenary |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
898 * w h bb_x bb_y| x y w h |bb_x bb_y w h */ |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
899 { 1, 0, -15, -14, 0, 15, 16, 1, 0, 1, 16, 15 }, // NE |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
900 { 0, 1, -14, -15, 15, 0, 1, 16, 1, 0, 15, 16 }, // SE |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
901 { 1, 0, -15, -14, 0, 15, 16, 1, 0, 1, 16, 15 }, // SW |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
902 { 0, 1, -14, -15, 15, 0, 1, 16, 1, 0, 15, 16 }, // NW |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
903 }; |
8548
f19f2719271b
(svn r12126) -Codechange: Use a variable instead of calling the same function a few times
belugas <belugas@openttd.org>
parents:
8540
diff
changeset
|
904 const int *BB_data = _tunnel_BB[tunnelbridge_direction]; |
7601
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
905 |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
906 bool catenary = false; |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
907 |
8549
24eb7d2b8315
(svn r12127) -Codechange: Use a variable instead of calling the same function a few times. Again. Just a different value.
belugas <belugas@openttd.org>
parents:
8548
diff
changeset
|
908 if (transport_type == TRANSPORT_RAIL) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
909 image = GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.tunnel; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
910 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
911 image = SPR_TUNNEL_ENTRY_REAR_ROAD; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
912 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
913 |
8083
e02014b06c7f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
8081
diff
changeset
|
914 if (HasTunnelBridgeSnowOrDesert(ti->tile)) image += 32; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
915 |
8548
f19f2719271b
(svn r12126) -Codechange: Use a variable instead of calling the same function a few times
belugas <belugas@openttd.org>
parents:
8540
diff
changeset
|
916 image += tunnelbridge_direction * 2; |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
917 DrawGroundSprite(image, PAL_NONE); |
9785
09b970522eb5
(svn r13927) -Add [YAPP]: Draw reserved tracks darker, toggeld by a patch setting. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9689
diff
changeset
|
918 |
09b970522eb5
(svn r13927) -Add [YAPP]: Draw reserved tracks darker, toggeld by a patch setting. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9689
diff
changeset
|
919 /* PBS debugging, draw reserved tracks darker */ |
10109
ef2f235f4ef4
(svn r14293) -Change: do not show PBS track reservation in the intro game
smatz <smatz@openttd.org>
parents:
10107
diff
changeset
|
920 if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && (transport_type == TRANSPORT_RAIL && GetTunnelBridgeReservation(ti->tile))) { |
9785
09b970522eb5
(svn r13927) -Add [YAPP]: Draw reserved tracks darker, toggeld by a patch setting. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9689
diff
changeset
|
921 const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile)); |
09b970522eb5
(svn r13927) -Add [YAPP]: Draw reserved tracks darker, toggeld by a patch setting. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9689
diff
changeset
|
922 DrawGroundSprite(DiagDirToAxis(tunnelbridge_direction) == AXIS_X ? rti->base_sprites.single_y : rti->base_sprites.single_x, PALETTE_CRASH); |
09b970522eb5
(svn r13927) -Add [YAPP]: Draw reserved tracks darker, toggeld by a patch setting. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9689
diff
changeset
|
923 } |
09b970522eb5
(svn r13927) -Add [YAPP]: Draw reserved tracks darker, toggeld by a patch setting. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9689
diff
changeset
|
924 |
8549
24eb7d2b8315
(svn r12127) -Codechange: Use a variable instead of calling the same function a few times. Again. Just a different value.
belugas <belugas@openttd.org>
parents:
8548
diff
changeset
|
925 if (transport_type == TRANSPORT_ROAD) { |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
926 RoadTypes rts = GetRoadTypes(ti->tile); |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
927 |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7923
diff
changeset
|
928 if (HasBit(rts, ROADTYPE_TRAM)) { |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
929 static const SpriteID tunnel_sprites[2][4] = { { 28, 78, 79, 27 }, { 5, 76, 77, 4 } }; |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
930 |
8548
f19f2719271b
(svn r12126) -Codechange: Use a variable instead of calling the same function a few times
belugas <belugas@openttd.org>
parents:
8540
diff
changeset
|
931 DrawGroundSprite(SPR_TRAMWAY_BASE + tunnel_sprites[rts - ROADTYPES_TRAM][tunnelbridge_direction], PAL_NONE); |
7601
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
932 |
8806
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
933 /* Do not draw wires if they are invisible */ |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
934 if (!IsInvisibilitySet(TO_CATENARY)) { |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
935 catenary = true; |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
936 StartSpriteCombine(); |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
937 AddSortableSpriteToDraw(SPR_TRAMWAY_TUNNEL_WIRES + tunnelbridge_direction, PAL_NONE, ti->x, ti->y, BB_data[10], BB_data[11], TILE_HEIGHT, ti->z, IsTransparencySet(TO_CATENARY), BB_data[8], BB_data[9], BB_Z_SEPARATOR); |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
938 } |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
939 } |
9154
046d0b6e0218
(svn r13016) -Codechange: unify the detection if rail catenary should be drawn
smatz <smatz@openttd.org>
parents:
9126
diff
changeset
|
940 } else if (HasCatenaryDrawn(GetRailType(ti->tile))) { |
10107
3a4846dd0d84
(svn r14291) -Fix [FS#2288] (r12853): For tunnels DrawCatenary() draws only pillars; DrawCatenaryOnTunnel() draws only wires.
frosch <frosch@openttd.org>
parents:
10083
diff
changeset
|
941 /* Maybe draw pylons on the entry side */ |
3a4846dd0d84
(svn r14291) -Fix [FS#2288] (r12853): For tunnels DrawCatenary() draws only pillars; DrawCatenaryOnTunnel() draws only wires.
frosch <frosch@openttd.org>
parents:
10083
diff
changeset
|
942 DrawCatenary(ti); |
3a4846dd0d84
(svn r14291) -Fix [FS#2288] (r12853): For tunnels DrawCatenary() draws only pillars; DrawCatenaryOnTunnel() draws only wires.
frosch <frosch@openttd.org>
parents:
10083
diff
changeset
|
943 |
7601
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
944 catenary = true; |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
945 StartSpriteCombine(); |
10107
3a4846dd0d84
(svn r14291) -Fix [FS#2288] (r12853): For tunnels DrawCatenary() draws only pillars; DrawCatenaryOnTunnel() draws only wires.
frosch <frosch@openttd.org>
parents:
10083
diff
changeset
|
946 /* Draw wire above the ramp */ |
7601
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
947 DrawCatenaryOnTunnel(ti); |
6663
9891bf71d5f0
(svn r9894) -Fix (r9892): catenary was drawn on road bridges ;)
rubidium <rubidium@openttd.org>
parents:
6661
diff
changeset
|
948 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
949 |
7601
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
950 AddSortableSpriteToDraw(image + 1, PAL_NONE, ti->x + TILE_SIZE - 1, ti->y + TILE_SIZE - 1, BB_data[0], BB_data[1], TILE_HEIGHT, ti->z, false, BB_data[2], BB_data[3], BB_Z_SEPARATOR); |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
951 |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
952 if (catenary) EndSpriteCombine(); |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
953 |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
954 /* Add helper BB for sprite sorting, that separate the tunnel from things beside of it */ |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
955 AddSortableSpriteToDraw(SPR_EMPTY_BOUNDING_BOX, PAL_NONE, ti->x , ti->y , BB_data[6], BB_data[7], TILE_HEIGHT, ti->z); |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
956 AddSortableSpriteToDraw(SPR_EMPTY_BOUNDING_BOX, PAL_NONE, ti->x + BB_data[4], ti->y + BB_data[5], BB_data[6], BB_data[7], TILE_HEIGHT, ti->z); |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
957 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
958 DrawBridgeMiddle(ti); |
8390
381a22f19287
(svn r11960) -Cleanup: simplify some IsTunnel(Tile) / IsBridge(Tile) conditions
smatz <smatz@openttd.org>
parents:
8385
diff
changeset
|
959 } else { // IsBridge(ti->tile) |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
960 const PalSpriteID *psid; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
961 int base_offset; |
8083
e02014b06c7f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
8081
diff
changeset
|
962 bool ice = HasTunnelBridgeSnowOrDesert(ti->tile); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
963 |
8549
24eb7d2b8315
(svn r12127) -Codechange: Use a variable instead of calling the same function a few times. Again. Just a different value.
belugas <belugas@openttd.org>
parents:
8548
diff
changeset
|
964 if (transport_type == TRANSPORT_RAIL) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
965 base_offset = GetRailTypeInfo(GetRailType(ti->tile))->bridge_offset; |
6422
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
966 assert(base_offset != 8); // This one is used for roads |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
967 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
968 base_offset = 8; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
969 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
970 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
971 /* as the lower 3 bits are used for other stuff, make sure they are clear */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
972 assert( (base_offset & 0x07) == 0x00); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
973 |
8548
f19f2719271b
(svn r12126) -Codechange: Use a variable instead of calling the same function a few times
belugas <belugas@openttd.org>
parents:
8540
diff
changeset
|
974 DrawFoundation(ti, GetBridgeFoundation(ti->tileh, DiagDirToAxis(tunnelbridge_direction))); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
975 |
6422
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
976 /* HACK Wizardry to convert the bridge ramp direction into a sprite offset */ |
8548
f19f2719271b
(svn r12126) -Codechange: Use a variable instead of calling the same function a few times
belugas <belugas@openttd.org>
parents:
8540
diff
changeset
|
977 base_offset += (6 - tunnelbridge_direction) % 4; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
978 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
979 if (ti->tileh == SLOPE_FLAT) base_offset += 4; // sloped bridge head |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
980 |
9642
b4caf5c04b2f
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas <belugas@openttd.org>
parents:
9596
diff
changeset
|
981 /* Table number BRIDGE_PIECE_HEAD always refers to the bridge heads for any bridge type */ |
9490
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
982 if (transport_type != TRANSPORT_WATER) { |
9642
b4caf5c04b2f
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas <belugas@openttd.org>
parents:
9596
diff
changeset
|
983 psid = &GetBridgeSpriteTable(GetBridgeType(ti->tile), BRIDGE_PIECE_HEAD)[base_offset]; |
9490
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
984 } else { |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
985 psid = _aqueduct_sprites + base_offset; |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
986 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
987 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
988 if (!ice) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
989 DrawClearLandTile(ti, 3); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
990 } else { |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
991 DrawGroundSprite(SPR_FLAT_SNOWY_TILE + _tileh_to_sprite[ti->tileh], PAL_NONE); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
992 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
993 |
6422
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
994 /* draw ramp */ |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
995 |
7601
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
996 /* Draw Trambits as SpriteCombine */ |
8549
24eb7d2b8315
(svn r12127) -Codechange: Use a variable instead of calling the same function a few times. Again. Just a different value.
belugas <belugas@openttd.org>
parents:
8548
diff
changeset
|
997 if (transport_type == TRANSPORT_ROAD) StartSpriteCombine(); |
7601
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
998 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
999 /* HACK set the height of the BB of a sloped ramp to 1 so a vehicle on |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1000 * it doesn't disappear behind it |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1001 */ |
8806
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
1002 /* Bridge heads are drawn solid no matter how invisibility/transparency is set */ |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
1003 AddSortableSpriteToDraw(psid->sprite, psid->pal, ti->x, ti->y, 16, 16, ti->tileh == SLOPE_FLAT ? 0 : 8, ti->z); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1004 |
9785
09b970522eb5
(svn r13927) -Add [YAPP]: Draw reserved tracks darker, toggeld by a patch setting. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9689
diff
changeset
|
1005 if (_settings_client.gui.show_track_reservation && transport_type == TRANSPORT_RAIL && GetTunnelBridgeReservation(ti->tile)) { |
09b970522eb5
(svn r13927) -Add [YAPP]: Draw reserved tracks darker, toggeld by a patch setting. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9689
diff
changeset
|
1006 const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile)); |
09b970522eb5
(svn r13927) -Add [YAPP]: Draw reserved tracks darker, toggeld by a patch setting. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9689
diff
changeset
|
1007 if (HasBridgeFlatRamp(ti->tileh, DiagDirToAxis(tunnelbridge_direction))) { |
09b970522eb5
(svn r13927) -Add [YAPP]: Draw reserved tracks darker, toggeld by a patch setting. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9689
diff
changeset
|
1008 AddSortableSpriteToDraw(DiagDirToAxis(tunnelbridge_direction) == AXIS_X ? rti->base_sprites.single_y : rti->base_sprites.single_x, PALETTE_CRASH, ti->x, ti->y, 16, 16, 0, ti->z + 8); |
09b970522eb5
(svn r13927) -Add [YAPP]: Draw reserved tracks darker, toggeld by a patch setting. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9689
diff
changeset
|
1009 } else { |
09b970522eb5
(svn r13927) -Add [YAPP]: Draw reserved tracks darker, toggeld by a patch setting. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9689
diff
changeset
|
1010 AddSortableSpriteToDraw(rti->base_sprites.single_sloped + tunnelbridge_direction, PALETTE_CRASH, ti->x, ti->y, 16, 16, 8, ti->z); |
09b970522eb5
(svn r13927) -Add [YAPP]: Draw reserved tracks darker, toggeld by a patch setting. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9689
diff
changeset
|
1011 } |
09b970522eb5
(svn r13927) -Add [YAPP]: Draw reserved tracks darker, toggeld by a patch setting. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9689
diff
changeset
|
1012 } |
09b970522eb5
(svn r13927) -Add [YAPP]: Draw reserved tracks darker, toggeld by a patch setting. (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9689
diff
changeset
|
1013 |
8549
24eb7d2b8315
(svn r12127) -Codechange: Use a variable instead of calling the same function a few times. Again. Just a different value.
belugas <belugas@openttd.org>
parents:
8548
diff
changeset
|
1014 if (transport_type == TRANSPORT_ROAD) { |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
1015 RoadTypes rts = GetRoadTypes(ti->tile); |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
1016 |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7923
diff
changeset
|
1017 if (HasBit(rts, ROADTYPE_TRAM)) { |
8548
f19f2719271b
(svn r12126) -Codechange: Use a variable instead of calling the same function a few times
belugas <belugas@openttd.org>
parents:
8540
diff
changeset
|
1018 uint offset = tunnelbridge_direction; |
6712
30121ef9dbb2
(svn r9944) -Fix: tile selection drawn on the wrong height for some road bridges.
rubidium <rubidium@openttd.org>
parents:
6708
diff
changeset
|
1019 uint z = ti->z; |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
1020 if (ti->tileh != SLOPE_FLAT) { |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
1021 offset = (offset + 1) & 1; |
6712
30121ef9dbb2
(svn r9944) -Fix: tile selection drawn on the wrong height for some road bridges.
rubidium <rubidium@openttd.org>
parents:
6708
diff
changeset
|
1022 z += TILE_HEIGHT; |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
1023 } else { |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
1024 offset += 2; |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
1025 } |
7601
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1026 /* DrawBridgeTramBits() calls EndSpriteCombine() and StartSpriteCombine() */ |
8806
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
1027 DrawBridgeTramBits(ti->x, ti->y, z, offset, HasBit(rts, ROADTYPE_ROAD), true); |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
1028 } |
7601
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1029 EndSpriteCombine(); |
10014
4da54042dc72
(svn r14173) -Fix: Don't check for rail type and catenary on aqueducts.
peter1138 <peter1138@openttd.org>
parents:
9815
diff
changeset
|
1030 } else if (transport_type == TRANSPORT_RAIL) { |
4da54042dc72
(svn r14173) -Fix: Don't check for rail type and catenary on aqueducts.
peter1138 <peter1138@openttd.org>
parents:
9815
diff
changeset
|
1031 if (HasCatenaryDrawn(GetRailType(ti->tile))) { |
4da54042dc72
(svn r14173) -Fix: Don't check for rail type and catenary on aqueducts.
peter1138 <peter1138@openttd.org>
parents:
9815
diff
changeset
|
1032 DrawCatenary(ti); |
4da54042dc72
(svn r14173) -Fix: Don't check for rail type and catenary on aqueducts.
peter1138 <peter1138@openttd.org>
parents:
9815
diff
changeset
|
1033 } |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
1034 } |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
1035 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1036 DrawBridgeMiddle(ti); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1037 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1038 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1039 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1040 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1041 /** Compute bridge piece. Computes the bridge piece to display depending on the position inside the bridge. |
9642
b4caf5c04b2f
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas <belugas@openttd.org>
parents:
9596
diff
changeset
|
1042 * bridges pieces sequence (middle parts). |
b4caf5c04b2f
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas <belugas@openttd.org>
parents:
9596
diff
changeset
|
1043 * Note that it is not covering the bridge heads, which are always referenced by the same sprite table. |
b4caf5c04b2f
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas <belugas@openttd.org>
parents:
9596
diff
changeset
|
1044 * bridge len 1: BRIDGE_PIECE_NORTH |
b4caf5c04b2f
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas <belugas@openttd.org>
parents:
9596
diff
changeset
|
1045 * bridge len 2: BRIDGE_PIECE_NORTH BRIDGE_PIECE_SOUTH |
b4caf5c04b2f
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas <belugas@openttd.org>
parents:
9596
diff
changeset
|
1046 * bridge len 3: BRIDGE_PIECE_NORTH BRIDGE_PIECE_MIDDLE_ODD BRIDGE_PIECE_SOUTH |
b4caf5c04b2f
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas <belugas@openttd.org>
parents:
9596
diff
changeset
|
1047 * bridge len 4: BRIDGE_PIECE_NORTH BRIDGE_PIECE_INNER_NORTH BRIDGE_PIECE_INNER_SOUTH BRIDGE_PIECE_SOUTH |
b4caf5c04b2f
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas <belugas@openttd.org>
parents:
9596
diff
changeset
|
1048 * bridge len 5: BRIDGE_PIECE_NORTH BRIDGE_PIECE_INNER_NORTH BRIDGE_PIECE_MIDDLE_EVEN BRIDGE_PIECE_INNER_SOUTH BRIDGE_PIECE_SOUTH |
b4caf5c04b2f
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas <belugas@openttd.org>
parents:
9596
diff
changeset
|
1049 * bridge len 6: BRIDGE_PIECE_NORTH BRIDGE_PIECE_INNER_NORTH BRIDGE_PIECE_INNER_SOUTH BRIDGE_PIECE_INNER_NORTH BRIDGE_PIECE_INNER_SOUTH BRIDGE_PIECE_SOUTH |
b4caf5c04b2f
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas <belugas@openttd.org>
parents:
9596
diff
changeset
|
1050 * bridge len 7: BRIDGE_PIECE_NORTH BRIDGE_PIECE_INNER_NORTH BRIDGE_PIECE_INNER_SOUTH BRIDGE_PIECE_MIDDLE_ODD BRIDGE_PIECE_INNER_NORTH BRIDGE_PIECE_INNER_SOUTH BRIDGE_PIECE_SOUTH |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1051 * #0 - always as first, #1 - always as last (if len>1) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1052 * #2,#3 are to pair in order |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1053 * for odd bridges: #5 is going in the bridge middle if on even position, #4 on odd (counting from 0) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1054 * @param north Northernmost tile of bridge |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1055 * @param south Southernmost tile of bridge |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1056 * @return Index of bridge piece |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1057 */ |
9642
b4caf5c04b2f
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas <belugas@openttd.org>
parents:
9596
diff
changeset
|
1058 static BridgePieces CalcBridgePiece(uint north, uint south) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1059 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1060 if (north == 1) { |
9642
b4caf5c04b2f
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas <belugas@openttd.org>
parents:
9596
diff
changeset
|
1061 return BRIDGE_PIECE_NORTH; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1062 } else if (south == 1) { |
9642
b4caf5c04b2f
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas <belugas@openttd.org>
parents:
9596
diff
changeset
|
1063 return BRIDGE_PIECE_SOUTH; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1064 } else if (north < south) { |
9642
b4caf5c04b2f
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas <belugas@openttd.org>
parents:
9596
diff
changeset
|
1065 return north & 1 ? BRIDGE_PIECE_INNER_SOUTH : BRIDGE_PIECE_INNER_NORTH; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1066 } else if (north > south) { |
9642
b4caf5c04b2f
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas <belugas@openttd.org>
parents:
9596
diff
changeset
|
1067 return south & 1 ? BRIDGE_PIECE_INNER_NORTH : BRIDGE_PIECE_INNER_SOUTH; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1068 } else { |
9642
b4caf5c04b2f
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas <belugas@openttd.org>
parents:
9596
diff
changeset
|
1069 return north & 1 ? BRIDGE_PIECE_MIDDLE_EVEN : BRIDGE_PIECE_MIDDLE_ODD; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1070 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1071 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1072 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1073 |
10647
592ae9307430
(svn r14949) -Cleanup: pointer coding style
rubidium <rubidium@openttd.org>
parents:
10532
diff
changeset
|
1074 void DrawBridgeMiddle(const TileInfo *ti) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1075 { |
7601
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1076 /* Sectional view of bridge bounding boxes: |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1077 * |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1078 * 1 2 1,2 = SpriteCombine of Bridge front/(back&floor) and TramCatenary |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1079 * 1 2 3 = empty helper BB |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1080 * 1 7 2 4,5 = pillars under higher bridges |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1081 * 1 6 88888 6 2 6 = elrail-pylons |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1082 * 1 6 88888 6 2 7 = elrail-wire |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1083 * 1 6 88888 6 2 <- TILE_HEIGHT 8 = rail-vehicle on bridge |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1084 * 3333333333333 <- BB_Z_SEPARATOR |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1085 * <- unused |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1086 * 4 5 <- BB_HEIGHT_UNDER_BRIDGE |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1087 * 4 5 |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1088 * 4 5 |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1089 * |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1090 */ |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1091 |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1092 /* Z position of the bridge sprites relative to bridge height (downwards) */ |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1093 static const int BRIDGE_Z_START = 3; |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1094 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1095 if (!IsBridgeAbove(ti->tile)) return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1096 |
9498
40e86605638d
(svn r13478) -Codechange: don't use GetBridgeSpec() for aqueducts
smatz <smatz@openttd.org>
parents:
9497
diff
changeset
|
1097 TileIndex rampnorth = GetNorthernBridgeEnd(ti->tile); |
40e86605638d
(svn r13478) -Codechange: don't use GetBridgeSpec() for aqueducts
smatz <smatz@openttd.org>
parents:
9497
diff
changeset
|
1098 TileIndex rampsouth = GetSouthernBridgeEnd(ti->tile); |
40e86605638d
(svn r13478) -Codechange: don't use GetBridgeSpec() for aqueducts
smatz <smatz@openttd.org>
parents:
9497
diff
changeset
|
1099 TransportType transport_type = GetTunnelBridgeTransportType(rampsouth); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1100 |
9498
40e86605638d
(svn r13478) -Codechange: don't use GetBridgeSpec() for aqueducts
smatz <smatz@openttd.org>
parents:
9497
diff
changeset
|
1101 Axis axis = GetBridgeAxis(ti->tile); |
9642
b4caf5c04b2f
(svn r13705) -Codechange: Define and use BridgePieces enum, which will remove a few more magic numbers
belugas <belugas@openttd.org>
parents:
9596
diff
changeset
|
1102 BridgePieces piece = CalcBridgePiece( |
8398
a6304b304752
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz <smatz@openttd.org>
parents:
8390
diff
changeset
|
1103 GetTunnelBridgeLength(ti->tile, rampnorth) + 1, |
a6304b304752
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz <smatz@openttd.org>
parents:
8390
diff
changeset
|
1104 GetTunnelBridgeLength(ti->tile, rampsouth) + 1 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1105 ); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1106 |
9498
40e86605638d
(svn r13478) -Codechange: don't use GetBridgeSpec() for aqueducts
smatz <smatz@openttd.org>
parents:
9497
diff
changeset
|
1107 const PalSpriteID *psid; |
40e86605638d
(svn r13478) -Codechange: don't use GetBridgeSpec() for aqueducts
smatz <smatz@openttd.org>
parents:
9497
diff
changeset
|
1108 bool drawfarpillar; |
9490
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1109 if (transport_type != TRANSPORT_WATER) { |
9498
40e86605638d
(svn r13478) -Codechange: don't use GetBridgeSpec() for aqueducts
smatz <smatz@openttd.org>
parents:
9497
diff
changeset
|
1110 BridgeType type = GetBridgeType(rampsouth); |
40e86605638d
(svn r13478) -Codechange: don't use GetBridgeSpec() for aqueducts
smatz <smatz@openttd.org>
parents:
9497
diff
changeset
|
1111 drawfarpillar = !HasBit(GetBridgeSpec(type)->flags, 0); |
40e86605638d
(svn r13478) -Codechange: don't use GetBridgeSpec() for aqueducts
smatz <smatz@openttd.org>
parents:
9497
diff
changeset
|
1112 |
40e86605638d
(svn r13478) -Codechange: don't use GetBridgeSpec() for aqueducts
smatz <smatz@openttd.org>
parents:
9497
diff
changeset
|
1113 uint base_offset; |
9490
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1114 if (transport_type == TRANSPORT_RAIL) { |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1115 base_offset = GetRailTypeInfo(GetRailType(rampsouth))->bridge_offset; |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1116 } else { |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1117 base_offset = 8; |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1118 } |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1119 |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1120 psid = base_offset + GetBridgeSpriteTable(type, piece); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1121 } else { |
9498
40e86605638d
(svn r13478) -Codechange: don't use GetBridgeSpec() for aqueducts
smatz <smatz@openttd.org>
parents:
9497
diff
changeset
|
1122 drawfarpillar = true; |
9490
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1123 psid = _aqueduct_sprites; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1124 } |
9498
40e86605638d
(svn r13478) -Codechange: don't use GetBridgeSpec() for aqueducts
smatz <smatz@openttd.org>
parents:
9497
diff
changeset
|
1125 |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
1126 if (axis != AXIS_X) psid += 4; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1127 |
9498
40e86605638d
(svn r13478) -Codechange: don't use GetBridgeSpec() for aqueducts
smatz <smatz@openttd.org>
parents:
9497
diff
changeset
|
1128 int x = ti->x; |
40e86605638d
(svn r13478) -Codechange: don't use GetBridgeSpec() for aqueducts
smatz <smatz@openttd.org>
parents:
9497
diff
changeset
|
1129 int y = ti->y; |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
1130 uint bridge_z = GetBridgeHeight(rampsouth); |
9498
40e86605638d
(svn r13478) -Codechange: don't use GetBridgeSpec() for aqueducts
smatz <smatz@openttd.org>
parents:
9497
diff
changeset
|
1131 uint z = bridge_z - BRIDGE_Z_START; |
7601
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1132 |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1133 /* Add a bounding box, that separates the bridge from things below it. */ |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1134 AddSortableSpriteToDraw(SPR_EMPTY_BOUNDING_BOX, PAL_NONE, x, y, 16, 16, 1, bridge_z - TILE_HEIGHT + BB_Z_SEPARATOR); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1135 |
7601
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1136 /* Draw Trambits as SpriteCombine */ |
8549
24eb7d2b8315
(svn r12127) -Codechange: Use a variable instead of calling the same function a few times. Again. Just a different value.
belugas <belugas@openttd.org>
parents:
8548
diff
changeset
|
1137 if (transport_type == TRANSPORT_ROAD) StartSpriteCombine(); |
7601
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1138 |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1139 /* Draw floor and far part of bridge*/ |
8806
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
1140 if (!IsInvisibilitySet(TO_BRIDGES)) { |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
1141 if (axis == AXIS_X) { |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
1142 AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 16, 1, 0x28, z, IsTransparencySet(TO_BRIDGES), 0, 0, BRIDGE_Z_START); |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
1143 } else { |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
1144 AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 1, 16, 0x28, z, IsTransparencySet(TO_BRIDGES), 0, 0, BRIDGE_Z_START); |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
1145 } |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
1146 } |
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
1147 |
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
1148 psid++; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1149 |
8549
24eb7d2b8315
(svn r12127) -Codechange: Use a variable instead of calling the same function a few times. Again. Just a different value.
belugas <belugas@openttd.org>
parents:
8548
diff
changeset
|
1150 if (transport_type == TRANSPORT_ROAD) { |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
1151 RoadTypes rts = GetRoadTypes(rampsouth); |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
1152 |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7923
diff
changeset
|
1153 if (HasBit(rts, ROADTYPE_TRAM)) { |
7601
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1154 /* DrawBridgeTramBits() calls EndSpriteCombine() and StartSpriteCombine() */ |
8806
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
1155 DrawBridgeTramBits(x, y, bridge_z, axis ^ 1, HasBit(rts, ROADTYPE_ROAD), false); |
7601
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1156 } else { |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1157 EndSpriteCombine(); |
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1158 StartSpriteCombine(); |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
1159 } |
10014
4da54042dc72
(svn r14173) -Fix: Don't check for rail type and catenary on aqueducts.
peter1138 <peter1138@openttd.org>
parents:
9815
diff
changeset
|
1160 } else if (transport_type == TRANSPORT_RAIL) { |
4da54042dc72
(svn r14173) -Fix: Don't check for rail type and catenary on aqueducts.
peter1138 <peter1138@openttd.org>
parents:
9815
diff
changeset
|
1161 if (HasCatenaryDrawn(GetRailType(rampsouth))) { |
4da54042dc72
(svn r14173) -Fix: Don't check for rail type and catenary on aqueducts.
peter1138 <peter1138@openttd.org>
parents:
9815
diff
changeset
|
1162 DrawCatenaryOnBridge(ti); |
4da54042dc72
(svn r14173) -Fix: Don't check for rail type and catenary on aqueducts.
peter1138 <peter1138@openttd.org>
parents:
9815
diff
changeset
|
1163 } |
6687
e75e7fde5aee
(svn r9919) -Codechange: prepare some more places for more road types.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
1164 } |
e75e7fde5aee
(svn r9919) -Codechange: prepare some more places for more road types.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
1165 |
6422
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
1166 /* draw roof, the component of the bridge which is logically between the vehicle and the camera */ |
8806
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
1167 if (!IsInvisibilitySet(TO_BRIDGES)) { |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
1168 if (axis == AXIS_X) { |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
1169 y += 12; |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
1170 if (psid->sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 16, 4, 0x28, z, IsTransparencySet(TO_BRIDGES), 0, 3, BRIDGE_Z_START); |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
1171 } else { |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
1172 x += 12; |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
1173 if (psid->sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 4, 16, 0x28, z, IsTransparencySet(TO_BRIDGES), 3, 0, BRIDGE_Z_START); |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
1174 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1175 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1176 |
7601
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1177 /* Draw TramFront as SpriteCombine */ |
8549
24eb7d2b8315
(svn r12127) -Codechange: Use a variable instead of calling the same function a few times. Again. Just a different value.
belugas <belugas@openttd.org>
parents:
8548
diff
changeset
|
1178 if (transport_type == TRANSPORT_ROAD) EndSpriteCombine(); |
7601
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7587
diff
changeset
|
1179 |
8806
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
1180 /* Do not draw anything more if bridges are invisible */ |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
1181 if (IsInvisibilitySet(TO_BRIDGES)) return; |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8786
diff
changeset
|
1182 |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
1183 psid++; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1184 if (ti->z + 5 == z) { |
6422
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
1185 /* draw poles below for small bridges */ |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
1186 if (psid->sprite != 0) { |
7333
7110c41ab174
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium <rubidium@openttd.org>
parents:
7308
diff
changeset
|
1187 SpriteID image = psid->sprite; |
7110c41ab174
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium <rubidium@openttd.org>
parents:
7308
diff
changeset
|
1188 SpriteID pal = psid->pal; |
7849
e6ee8bfd9045
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas <belugas@openttd.org>
parents:
7845
diff
changeset
|
1189 if (IsTransparencySet(TO_BRIDGES)) { |
7931
44ff7a6d801f
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7929
diff
changeset
|
1190 SetBit(image, PALETTE_MODIFIER_TRANSPARENT); |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
1191 pal = PALETTE_TO_TRANSPARENT; |
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
1192 } |
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
1193 |
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
1194 DrawGroundSpriteAt(image, pal, x, y, z); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1195 } |
9413
512ea64da840
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
1196 } else if (_settings_client.gui.bridge_pillars) { |
6422
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
1197 /* draw pillars below for high bridges */ |
9498
40e86605638d
(svn r13478) -Codechange: don't use GetBridgeSpec() for aqueducts
smatz <smatz@openttd.org>
parents:
9497
diff
changeset
|
1198 DrawBridgePillars(psid, ti, axis, drawfarpillar, x, y, z); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1199 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1200 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1201 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1202 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1203 static uint GetSlopeZ_TunnelBridge(TileIndex tile, uint x, uint y) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1204 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1205 uint z; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1206 Slope tileh = GetTileSlope(tile, &z); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1207 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1208 x &= 0xF; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1209 y &= 0xF; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1210 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1211 if (IsTunnel(tile)) { |
8083
e02014b06c7f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
8081
diff
changeset
|
1212 uint pos = (DiagDirToAxis(GetTunnelBridgeDirection(tile)) == AXIS_X ? y : x); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1213 |
6422
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
1214 /* In the tunnel entrance? */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1215 if (5 <= pos && pos <= 10) return z; |
8390
381a22f19287
(svn r11960) -Cleanup: simplify some IsTunnel(Tile) / IsBridge(Tile) conditions
smatz <smatz@openttd.org>
parents:
8385
diff
changeset
|
1216 } else { // IsBridge(tile) |
8083
e02014b06c7f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
8081
diff
changeset
|
1217 DiagDirection dir = GetTunnelBridgeDirection(tile); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1218 uint pos = (DiagDirToAxis(dir) == AXIS_X ? y : x); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1219 |
7335
0090d1c6b978
(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 <rubidium@openttd.org>
parents:
7333
diff
changeset
|
1220 z += ApplyFoundationToSlope(GetBridgeFoundation(tileh, DiagDirToAxis(dir)), &tileh); |
0090d1c6b978
(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 <rubidium@openttd.org>
parents:
7333
diff
changeset
|
1221 |
6422
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
1222 /* On the bridge ramp? */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1223 if (5 <= pos && pos <= 10) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1224 uint delta; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1225 |
8379
bf751c81fa2f
(svn r11946) -Fix: slope detection of bridge ramps.
frosch <frosch@openttd.org>
parents:
8371
diff
changeset
|
1226 if (tileh != SLOPE_FLAT) return z + TILE_HEIGHT; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1227 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1228 switch (dir) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1229 default: NOT_REACHED(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1230 case DIAGDIR_NE: delta = (TILE_SIZE - 1 - x) / 2; break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1231 case DIAGDIR_SE: delta = y / 2; break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1232 case DIAGDIR_SW: delta = x / 2; break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1233 case DIAGDIR_NW: delta = (TILE_SIZE - 1 - y) / 2; break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1234 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1235 return z + 1 + delta; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1236 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1237 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1238 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1239 return z + GetPartialZ(x, y, tileh); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1240 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1241 |
7335
0090d1c6b978
(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 <rubidium@openttd.org>
parents:
7333
diff
changeset
|
1242 static Foundation GetFoundation_TunnelBridge(TileIndex tile, Slope tileh) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1243 { |
8083
e02014b06c7f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
8081
diff
changeset
|
1244 return IsTunnel(tile) ? FOUNDATION_NONE : GetBridgeFoundation(tileh, DiagDirToAxis(GetTunnelBridgeDirection(tile))); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1245 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1246 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1247 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1248 static void GetAcceptedCargo_TunnelBridge(TileIndex tile, AcceptedCargo ac) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1249 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1250 /* not used */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1251 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1252 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1253 static void GetTileDesc_TunnelBridge(TileIndex tile, TileDesc *td) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1254 { |
9497
5069f9e0b799
(svn r13477) -Fix (r13464): correct tile type in the Query tile info window
smatz <smatz@openttd.org>
parents:
9495
diff
changeset
|
1255 TransportType tt = GetTunnelBridgeTransportType(tile); |
5069f9e0b799
(svn r13477) -Fix (r13464): correct tile type in the Query tile info window
smatz <smatz@openttd.org>
parents:
9495
diff
changeset
|
1256 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1257 if (IsTunnel(tile)) { |
9497
5069f9e0b799
(svn r13477) -Fix (r13464): correct tile type in the Query tile info window
smatz <smatz@openttd.org>
parents:
9495
diff
changeset
|
1258 td->str = (tt == TRANSPORT_RAIL) ? STR_5017_RAILROAD_TUNNEL : STR_5018_ROAD_TUNNEL; |
5069f9e0b799
(svn r13477) -Fix (r13464): correct tile type in the Query tile info window
smatz <smatz@openttd.org>
parents:
9495
diff
changeset
|
1259 } else { // IsBridge(tile) |
5069f9e0b799
(svn r13477) -Fix (r13464): correct tile type in the Query tile info window
smatz <smatz@openttd.org>
parents:
9495
diff
changeset
|
1260 td->str = (tt == TRANSPORT_WATER) ? STR_AQUEDUCT : GetBridgeSpec(GetBridgeType(tile))->transport_name[tt]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1261 } |
9322
258ab31489e0
(svn r13206) -Feature(ette): Display all owners of a tile in the tile-info-window.
frosch <frosch@openttd.org>
parents:
9224
diff
changeset
|
1262 td->owner[0] = GetTileOwner(tile); |
11252
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
1263 |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
1264 Owner road_owner = INVALID_OWNER; |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
1265 Owner tram_owner = INVALID_OWNER; |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
1266 RoadTypes rts = GetRoadTypes(tile); |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
1267 if (HasBit(rts, ROADTYPE_ROAD)) road_owner = GetRoadOwner(tile, ROADTYPE_ROAD); |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
1268 if (HasBit(rts, ROADTYPE_TRAM)) tram_owner = GetRoadOwner(tile, ROADTYPE_TRAM); |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
1269 |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
1270 /* Is there a mix of owners? */ |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
1271 if ((tram_owner != INVALID_OWNER && tram_owner != td->owner[0]) || |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
1272 (road_owner != INVALID_OWNER && road_owner != td->owner[0])) { |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
1273 uint i = 1; |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
1274 if (road_owner != INVALID_OWNER) { |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
1275 td->owner_type[i] = STR_ROAD_OWNER; |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
1276 td->owner[i] = road_owner; |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
1277 i++; |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
1278 } |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
1279 if (tram_owner != INVALID_OWNER) { |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
1280 td->owner_type[i] = STR_TRAM_OWNER; |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
1281 td->owner[i] = tram_owner; |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
1282 } |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
1283 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1284 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1285 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1286 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1287 static void AnimateTile_TunnelBridge(TileIndex tile) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1288 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1289 /* not used */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1290 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1291 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1292 static void TileLoop_TunnelBridge(TileIndex tile) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1293 { |
8088
5d7c61206209
(svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz <smatz@openttd.org>
parents:
8083
diff
changeset
|
1294 bool snow_or_desert = HasTunnelBridgeSnowOrDesert(tile); |
9413
512ea64da840
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents:
9358
diff
changeset
|
1295 switch (_settings_game.game_creation.landscape) { |
6357
96b1652c6011
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas <belugas@openttd.org>
parents:
6343
diff
changeset
|
1296 case LT_ARCTIC: |
6343
f75b72d9fc98
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros <maedhros@openttd.org>
parents:
6259
diff
changeset
|
1297 if (snow_or_desert != (GetTileZ(tile) > GetSnowLine())) { |
8088
5d7c61206209
(svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz <smatz@openttd.org>
parents:
8083
diff
changeset
|
1298 SetTunnelBridgeSnowOrDesert(tile, !snow_or_desert); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1299 MarkTileDirtyByTile(tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1300 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1301 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1302 |
6357
96b1652c6011
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas <belugas@openttd.org>
parents:
6343
diff
changeset
|
1303 case LT_TROPIC: |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1304 if (GetTropicZone(tile) == TROPICZONE_DESERT && !snow_or_desert) { |
8088
5d7c61206209
(svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz <smatz@openttd.org>
parents:
8083
diff
changeset
|
1305 SetTunnelBridgeSnowOrDesert(tile, true); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1306 MarkTileDirtyByTile(tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1307 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1308 break; |
8088
5d7c61206209
(svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz <smatz@openttd.org>
parents:
8083
diff
changeset
|
1309 |
5d7c61206209
(svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz <smatz@openttd.org>
parents:
8083
diff
changeset
|
1310 default: |
5d7c61206209
(svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz <smatz@openttd.org>
parents:
8083
diff
changeset
|
1311 break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1312 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1313 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1314 |
10532
d33755b6159a
(svn r14789) -Feature: allow scrolling with the left mouse button pressed (if enabled). Primarily useful for systems with touch screen (aapo)
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1315 static bool ClickTile_TunnelBridge(TileIndex tile) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1316 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1317 /* not used */ |
10532
d33755b6159a
(svn r14789) -Feature: allow scrolling with the left mouse button pressed (if enabled). Primarily useful for systems with touch screen (aapo)
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1318 return false; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1319 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1320 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1321 |
8616
9e46ac001a8c
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch <frosch@openttd.org>
parents:
8596
diff
changeset
|
1322 static TrackStatus GetTileTrackStatus_TunnelBridge(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1323 { |
8549
24eb7d2b8315
(svn r12127) -Codechange: Use a variable instead of calling the same function a few times. Again. Just a different value.
belugas <belugas@openttd.org>
parents:
8548
diff
changeset
|
1324 TransportType transport_type = GetTunnelBridgeTransportType(tile); |
24eb7d2b8315
(svn r12127) -Codechange: Use a variable instead of calling the same function a few times. Again. Just a different value.
belugas <belugas@openttd.org>
parents:
8548
diff
changeset
|
1325 if (transport_type != mode || (transport_type == TRANSPORT_ROAD && (GetRoadTypes(tile) & sub_mode) == 0)) return 0; |
8596
ae0c04ca28d2
(svn r12177) -Codechange: use 'side' parameter in GetTileTrackStatus so there can be less checks in pathfinders for depots/stations/tunnels/bridges
smatz <smatz@openttd.org>
parents:
8590
diff
changeset
|
1326 |
ae0c04ca28d2
(svn r12177) -Codechange: use 'side' parameter in GetTileTrackStatus so there can be less checks in pathfinders for depots/stations/tunnels/bridges
smatz <smatz@openttd.org>
parents:
8590
diff
changeset
|
1327 DiagDirection dir = GetTunnelBridgeDirection(tile); |
ae0c04ca28d2
(svn r12177) -Codechange: use 'side' parameter in GetTileTrackStatus so there can be less checks in pathfinders for depots/stations/tunnels/bridges
smatz <smatz@openttd.org>
parents:
8590
diff
changeset
|
1328 if (side != INVALID_DIAGDIR && side != ReverseDiagDir(dir)) return 0; |
9224
c8a0fa0e208a
(svn r13090) -Codechange: add functions for direct conversion from DiagDirection to Track and Trackbits
smatz <smatz@openttd.org>
parents:
9154
diff
changeset
|
1329 return CombineTrackStatus(TrackBitsToTrackdirBits(DiagDirToDiagTrackBits(dir)), TRACKDIR_BIT_NONE); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1330 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1331 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10140
diff
changeset
|
1332 static void ChangeTileOwner_TunnelBridge(TileIndex tile, Owner old_owner, Owner new_owner) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1333 { |
11252
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
1334 for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) { |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
1335 /* Update all roadtypes, no matter if they are present */ |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
1336 if (GetRoadOwner(tile, rt) == old_owner) { |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
1337 SetRoadOwner(tile, rt, new_owner == INVALID_OWNER ? OWNER_NONE : new_owner); |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
1338 } |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
1339 } |
f7b6f8f03e5e
(svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents:
11106
diff
changeset
|
1340 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10140
diff
changeset
|
1341 if (!IsTileOwner(tile, old_owner)) return; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1342 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10140
diff
changeset
|
1343 if (new_owner != INVALID_OWNER) { |
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10140
diff
changeset
|
1344 SetTileOwner(tile, new_owner); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1345 } else { |
8519
0e4b2a37af1f
(svn r12094) -Codechange: use DC_BANKRUPT command flag when removing player property to allow further fixes
smatz <smatz@openttd.org>
parents:
8491
diff
changeset
|
1346 if (CmdFailed(DoCommand(tile, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR))) { |
6734
078d8129a184
(svn r9966) -Fix: bridges and tunnels were not always removed on bankruptcy, thus leaving tunnels/bridges with an invalid owner that would crash the game when clicking with the query tool on them.
rubidium <rubidium@openttd.org>
parents:
6712
diff
changeset
|
1347 /* When clearing the bridge/tunnel failed there are still vehicles on/in |
078d8129a184
(svn r9966) -Fix: bridges and tunnels were not always removed on bankruptcy, thus leaving tunnels/bridges with an invalid owner that would crash the game when clicking with the query tool on them.
rubidium <rubidium@openttd.org>
parents:
6712
diff
changeset
|
1348 * the bridge/tunnel. As all *our* vehicles are already removed, they |
9495
9fd9426b36c9
(svn r13475) -Fix (r13464): crash on destroying aquaduct with ship on in and on company bankrupt
smatz <smatz@openttd.org>
parents:
9492
diff
changeset
|
1349 * must be of another owner. Therefore this can't be rail tunnel/bridge. |
6734
078d8129a184
(svn r9966) -Fix: bridges and tunnels were not always removed on bankruptcy, thus leaving tunnels/bridges with an invalid owner that would crash the game when clicking with the query tool on them.
rubidium <rubidium@openttd.org>
parents:
6712
diff
changeset
|
1350 * In that case we can safely reassign the ownership to OWNER_NONE. */ |
9495
9fd9426b36c9
(svn r13475) -Fix (r13464): crash on destroying aquaduct with ship on in and on company bankrupt
smatz <smatz@openttd.org>
parents:
9492
diff
changeset
|
1351 assert(GetTunnelBridgeTransportType(tile) != TRANSPORT_RAIL); |
6734
078d8129a184
(svn r9966) -Fix: bridges and tunnels were not always removed on bankruptcy, thus leaving tunnels/bridges with an invalid owner that would crash the game when clicking with the query tool on them.
rubidium <rubidium@openttd.org>
parents:
6712
diff
changeset
|
1352 SetTileOwner(tile, OWNER_NONE); |
078d8129a184
(svn r9966) -Fix: bridges and tunnels were not always removed on bankruptcy, thus leaving tunnels/bridges with an invalid owner that would crash the game when clicking with the query tool on them.
rubidium <rubidium@openttd.org>
parents:
6712
diff
changeset
|
1353 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1354 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1355 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1356 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1357 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1358 static const byte _tunnel_fractcoord_1[4] = {0x8E, 0x18, 0x81, 0xE8}; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1359 static const byte _tunnel_fractcoord_2[4] = {0x81, 0x98, 0x87, 0x38}; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1360 static const byte _tunnel_fractcoord_3[4] = {0x82, 0x88, 0x86, 0x48}; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1361 static const byte _exit_tunnel_track[4] = {1, 2, 1, 2}; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1362 |
6000
2f43f0d4d589
(svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium <rubidium@openttd.org>
parents:
5993
diff
changeset
|
1363 /** Get the trackdir of the exit of a tunnel */ |
2f43f0d4d589
(svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium <rubidium@openttd.org>
parents:
5993
diff
changeset
|
1364 static const Trackdir _road_exit_tunnel_state[DIAGDIR_END] = { |
2f43f0d4d589
(svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium <rubidium@openttd.org>
parents:
5993
diff
changeset
|
1365 TRACKDIR_X_SW, TRACKDIR_Y_NW, TRACKDIR_X_NE, TRACKDIR_Y_SE |
2f43f0d4d589
(svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium <rubidium@openttd.org>
parents:
5993
diff
changeset
|
1366 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1367 static const byte _road_exit_tunnel_frame[4] = {2, 7, 9, 4}; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1368 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1369 static const byte _tunnel_fractcoord_4[4] = {0x52, 0x85, 0x98, 0x29}; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1370 static const byte _tunnel_fractcoord_5[4] = {0x92, 0x89, 0x58, 0x25}; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1371 static const byte _tunnel_fractcoord_6[4] = {0x92, 0x89, 0x56, 0x45}; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1372 static const byte _tunnel_fractcoord_7[4] = {0x52, 0x85, 0x96, 0x49}; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1373 |
8119
b6ec923e9fa8
(svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium <rubidium@openttd.org>
parents:
8116
diff
changeset
|
1374 static VehicleEnterTileStatus VehicleEnter_TunnelBridge(Vehicle *v, TileIndex tile, int x, int y) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1375 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1376 int z = GetSlopeZ(x, y) - v->z_pos; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1377 |
7923
504d4b2ecc6c
(svn r11476) -Codechange: rename the function myabs to abs to get rid of an unneeded define
skidd13 <skidd13@openttd.org>
parents:
7857
diff
changeset
|
1378 if (abs(z) > 2) return VETSB_CANNOT_ENTER; |
8548
f19f2719271b
(svn r12126) -Codechange: Use a variable instead of calling the same function a few times
belugas <belugas@openttd.org>
parents:
8540
diff
changeset
|
1379 const DiagDirection dir = GetTunnelBridgeDirection(tile); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1380 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1381 if (IsTunnel(tile)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1382 byte fc; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1383 DiagDirection vdir; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1384 |
6259
4a39d6291d58
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents:
6248
diff
changeset
|
1385 if (v->type == VEH_TRAIN) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1386 fc = (x & 0xF) + (y << 4); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1387 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1388 vdir = DirToDiagDir(v->direction); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1389 |
5993
2498be7c7e94
(svn r8701) -Codechange: replace magic numbers with enums for u.rail.track.
rubidium <rubidium@openttd.org>
parents:
5991
diff
changeset
|
1390 if (v->u.rail.track != TRACK_BIT_WORMHOLE && dir == vdir) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1391 if (IsFrontEngine(v) && fc == _tunnel_fractcoord_1[dir]) { |
6213
1625f839e124
(svn r9009) -Fix (r1): Determine whether to play a sound or not when entering a tunnel based on engine type (only steam engines) instead of on spritenum which can be invalid for newgrf trains. DBSet(XL) or any other steam trains without newsounds should sound their horn now.
Darkvater <Darkvater@openttd.org>
parents:
6141
diff
changeset
|
1392 if (!PlayVehicleSound(v, VSE_TUNNEL) && RailVehInfo(v->engine_type)->engclass == 0) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1393 SndPlayVehicleFx(SND_05_TRAIN_THROUGH_TUNNEL, v); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1394 } |
5991
1b793d99b5ba
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium <rubidium@openttd.org>
parents:
5930
diff
changeset
|
1395 return VETSB_CONTINUE; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1396 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1397 if (fc == _tunnel_fractcoord_2[dir]) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1398 v->tile = tile; |
5587
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
1399 v->u.rail.track = TRACK_BIT_WORMHOLE; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1400 v->vehstatus |= VS_HIDDEN; |
5991
1b793d99b5ba
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium <rubidium@openttd.org>
parents:
5930
diff
changeset
|
1401 return VETSB_ENTERED_WORMHOLE; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1402 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1403 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1404 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1405 if (dir == ReverseDiagDir(vdir) && fc == _tunnel_fractcoord_3[dir] && z == 0) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1406 /* We're at the tunnel exit ?? */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1407 v->tile = tile; |
5587
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
1408 v->u.rail.track = (TrackBits)_exit_tunnel_track[dir]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1409 assert(v->u.rail.track); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1410 v->vehstatus &= ~VS_HIDDEN; |
5991
1b793d99b5ba
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium <rubidium@openttd.org>
parents:
5930
diff
changeset
|
1411 return VETSB_ENTERED_WORMHOLE; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1412 } |
6259
4a39d6291d58
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents:
6248
diff
changeset
|
1413 } else if (v->type == VEH_ROAD) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1414 fc = (x & 0xF) + (y << 4); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1415 vdir = DirToDiagDir(v->direction); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1416 |
6422
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
1417 /* Enter tunnel? */ |
6000
2f43f0d4d589
(svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium <rubidium@openttd.org>
parents:
5993
diff
changeset
|
1418 if (v->u.road.state != RVSB_WORMHOLE && dir == vdir) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1419 if (fc == _tunnel_fractcoord_4[dir] || |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1420 fc == _tunnel_fractcoord_5[dir]) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1421 v->tile = tile; |
6000
2f43f0d4d589
(svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium <rubidium@openttd.org>
parents:
5993
diff
changeset
|
1422 v->u.road.state = RVSB_WORMHOLE; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1423 v->vehstatus |= VS_HIDDEN; |
5991
1b793d99b5ba
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium <rubidium@openttd.org>
parents:
5930
diff
changeset
|
1424 return VETSB_ENTERED_WORMHOLE; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1425 } else { |
5991
1b793d99b5ba
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium <rubidium@openttd.org>
parents:
5930
diff
changeset
|
1426 return VETSB_CONTINUE; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1427 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1428 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1429 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1430 if (dir == ReverseDiagDir(vdir) && ( |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1431 /* We're at the tunnel exit ?? */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1432 fc == _tunnel_fractcoord_6[dir] || |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1433 fc == _tunnel_fractcoord_7[dir] |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1434 ) && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1435 z == 0) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1436 v->tile = tile; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1437 v->u.road.state = _road_exit_tunnel_state[dir]; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1438 v->u.road.frame = _road_exit_tunnel_frame[dir]; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1439 v->vehstatus &= ~VS_HIDDEN; |
5991
1b793d99b5ba
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium <rubidium@openttd.org>
parents:
5930
diff
changeset
|
1440 return VETSB_ENTERED_WORMHOLE; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1441 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1442 } |
8390
381a22f19287
(svn r11960) -Cleanup: simplify some IsTunnel(Tile) / IsBridge(Tile) conditions
smatz <smatz@openttd.org>
parents:
8385
diff
changeset
|
1443 } else { // IsBridge(tile) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1444 |
9490
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1445 if (v->IsPrimaryVehicle() && v->type != VEH_SHIP) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1446 /* modify speed of vehicle */ |
8491
cf57eb06b4d9
(svn r12066) -Codechange: Rename GetBridge for the more common GetBridgeSpec
belugas <belugas@openttd.org>
parents:
8489
diff
changeset
|
1447 uint16 spd = GetBridgeSpec(GetBridgeType(tile))->speed; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1448 |
6259
4a39d6291d58
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents:
6248
diff
changeset
|
1449 if (v->type == VEH_ROAD) spd *= 2; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1450 if (v->cur_speed > spd) v->cur_speed = spd; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1451 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1452 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1453 if (DirToDiagDir(v->direction) == dir) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1454 switch (dir) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1455 default: NOT_REACHED(); |
5991
1b793d99b5ba
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium <rubidium@openttd.org>
parents:
5930
diff
changeset
|
1456 case DIAGDIR_NE: if ((x & 0xF) != 0) return VETSB_CONTINUE; break; |
1b793d99b5ba
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium <rubidium@openttd.org>
parents:
5930
diff
changeset
|
1457 case DIAGDIR_SE: if ((y & 0xF) != TILE_SIZE - 1) return VETSB_CONTINUE; break; |
1b793d99b5ba
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium <rubidium@openttd.org>
parents:
5930
diff
changeset
|
1458 case DIAGDIR_SW: if ((x & 0xF) != TILE_SIZE - 1) return VETSB_CONTINUE; break; |
1b793d99b5ba
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium <rubidium@openttd.org>
parents:
5930
diff
changeset
|
1459 case DIAGDIR_NW: if ((y & 0xF) != 0) return VETSB_CONTINUE; break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1460 } |
9490
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1461 switch (v->type) { |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1462 case VEH_TRAIN: |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1463 v->u.rail.track = TRACK_BIT_WORMHOLE; |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1464 ClrBit(v->u.rail.flags, VRF_GOINGUP); |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1465 ClrBit(v->u.rail.flags, VRF_GOINGDOWN); |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1466 break; |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1467 |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1468 case VEH_ROAD: |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1469 v->u.road.state = RVSB_WORMHOLE; |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1470 break; |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1471 |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1472 case VEH_SHIP: |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1473 v->u.ship.state = TRACK_BIT_WORMHOLE; |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1474 break; |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1475 |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1476 default: NOT_REACHED(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1477 } |
5991
1b793d99b5ba
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium <rubidium@openttd.org>
parents:
5930
diff
changeset
|
1478 return VETSB_ENTERED_WORMHOLE; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1479 } else if (DirToDiagDir(v->direction) == ReverseDiagDir(dir)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1480 v->tile = tile; |
9490
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1481 switch (v->type) { |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1482 case VEH_TRAIN: |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1483 if (v->u.rail.track == TRACK_BIT_WORMHOLE) { |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1484 v->u.rail.track = (DiagDirToAxis(dir) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y); |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1485 return VETSB_ENTERED_WORMHOLE; |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1486 } |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1487 break; |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1488 |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1489 case VEH_ROAD: |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1490 if (v->u.road.state == RVSB_WORMHOLE) { |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1491 v->u.road.state = _road_exit_tunnel_state[dir]; |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1492 v->u.road.frame = 0; |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1493 return VETSB_ENTERED_WORMHOLE; |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1494 } |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1495 break; |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1496 |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1497 case VEH_SHIP: |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1498 if (v->u.ship.state == TRACK_BIT_WORMHOLE) { |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1499 v->u.ship.state = (DiagDirToAxis(dir) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y); |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1500 return VETSB_ENTERED_WORMHOLE; |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1501 } |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1502 break; |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1503 |
8622c9315e8c
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium <rubidium@openttd.org>
parents:
9413
diff
changeset
|
1504 default: NOT_REACHED(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1505 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1506 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1507 } |
5991
1b793d99b5ba
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium <rubidium@openttd.org>
parents:
5930
diff
changeset
|
1508 return VETSB_CONTINUE; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1509 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1510 |
11090
df23c4e04638
(svn r15434) -Codechange: bit of type safety for the DC_xxx flags.
rubidium <rubidium@openttd.org>
parents:
11069
diff
changeset
|
1511 static CommandCost TerraformTile_TunnelBridge(TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new) |
7494
3f6f5fcc079a
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium <rubidium@openttd.org>
parents:
7472
diff
changeset
|
1512 { |
9492
d68dd1843f67
(svn r13468) -Fix: make aqueducts a little more expensive than normal bridges and disable terraforming of aqueduct bridgeheads; one can't terraform normal canal tiles either.
rubidium <rubidium@openttd.org>
parents:
9491
diff
changeset
|
1513 if (_settings_game.construction.build_on_slopes && AutoslopeEnabled() && IsBridge(tile) && GetTunnelBridgeTransportType(tile) != TRANSPORT_WATER) { |
8083
e02014b06c7f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
8081
diff
changeset
|
1514 DiagDirection direction = GetTunnelBridgeDirection(tile); |
7582
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7548
diff
changeset
|
1515 Axis axis = DiagDirToAxis(direction); |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7548
diff
changeset
|
1516 CommandCost res; |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
1517 uint z_old; |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
1518 Slope tileh_old = GetTileSlope(tile, &z_old); |
7582
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7548
diff
changeset
|
1519 |
10017
005e91956321
(svn r14176) -Fix: better 'safe' than ... 'save'
smatz <smatz@openttd.org>
parents:
10014
diff
changeset
|
1520 /* Check if new slope is valid for bridges in general (so we can safely call GetBridgeFoundation()) */ |
7582
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7548
diff
changeset
|
1521 if ((direction == DIAGDIR_NW) || (direction == DIAGDIR_NE)) { |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
1522 CheckBridgeSlopeSouth(axis, &tileh_old, &z_old); |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
1523 res = CheckBridgeSlopeSouth(axis, &tileh_new, &z_new); |
7582
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7548
diff
changeset
|
1524 } else { |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
1525 CheckBridgeSlopeNorth(axis, &tileh_old, &z_old); |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
1526 res = CheckBridgeSlopeNorth(axis, &tileh_new, &z_new); |
7582
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7548
diff
changeset
|
1527 } |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7548
diff
changeset
|
1528 |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
1529 /* Surface slope is valid and remains unchanged? */ |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
1530 if (!CmdFailed(res) && (z_old == z_new) && (tileh_old == tileh_new)) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); |
7582
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7548
diff
changeset
|
1531 } |
e77bd387f449
(svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7548
diff
changeset
|
1532 |
7494
3f6f5fcc079a
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium <rubidium@openttd.org>
parents:
7472
diff
changeset
|
1533 return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
3f6f5fcc079a
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium <rubidium@openttd.org>
parents:
7472
diff
changeset
|
1534 } |
3f6f5fcc079a
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium <rubidium@openttd.org>
parents:
7472
diff
changeset
|
1535 |
5587
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
1536 extern const TileTypeProcs _tile_type_tunnelbridge_procs = { |
11368
82c90cd591ab
(svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents:
11354
diff
changeset
|
1537 DrawTile_TunnelBridge, // draw_tile_proc |
82c90cd591ab
(svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents:
11354
diff
changeset
|
1538 GetSlopeZ_TunnelBridge, // get_slope_z_proc |
82c90cd591ab
(svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents:
11354
diff
changeset
|
1539 ClearTile_TunnelBridge, // clear_tile_proc |
82c90cd591ab
(svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents:
11354
diff
changeset
|
1540 GetAcceptedCargo_TunnelBridge, // get_accepted_cargo_proc |
82c90cd591ab
(svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents:
11354
diff
changeset
|
1541 GetTileDesc_TunnelBridge, // get_tile_desc_proc |
82c90cd591ab
(svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents:
11354
diff
changeset
|
1542 GetTileTrackStatus_TunnelBridge, // get_tile_track_status_proc |
82c90cd591ab
(svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents:
11354
diff
changeset
|
1543 ClickTile_TunnelBridge, // click_tile_proc |
82c90cd591ab
(svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents:
11354
diff
changeset
|
1544 AnimateTile_TunnelBridge, // animate_tile_proc |
82c90cd591ab
(svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents:
11354
diff
changeset
|
1545 TileLoop_TunnelBridge, // tile_loop_clear |
82c90cd591ab
(svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents:
11354
diff
changeset
|
1546 ChangeTileOwner_TunnelBridge, // change_tile_owner_clear |
82c90cd591ab
(svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents:
11354
diff
changeset
|
1547 NULL, // get_produced_cargo_proc |
82c90cd591ab
(svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents:
11354
diff
changeset
|
1548 VehicleEnter_TunnelBridge, // vehicle_enter_tile_proc |
82c90cd591ab
(svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents:
11354
diff
changeset
|
1549 GetFoundation_TunnelBridge, // get_foundation_proc |
82c90cd591ab
(svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents:
11354
diff
changeset
|
1550 TerraformTile_TunnelBridge, // terraform_tile_proc |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1551 }; |