Mercurial > hg > openttd
annotate src/tunnelbridge_cmd.cpp @ 8596:ae0c04ca28d2 draft
(svn r12177) -Codechange: use 'side' parameter in GetTileTrackStatus so there can be less checks in pathfinders for depots/stations/tunnels/bridges
author | smatz <smatz@openttd.org> |
---|---|
date | Mon, 18 Feb 2008 16:11:31 +0000 |
parents | 0bbc9ad3a6a0 |
children | 9e46ac001a8c |
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 "bridge_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
|
11 #include "rail_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
|
12 #include "road_map.h" |
8119
b6ec923e9fa8
(svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium <rubidium@openttd.org>
parents:
8116
diff
changeset
|
13 #include "tile_cmd.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
|
14 #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
|
15 #include "tunnel_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
|
16 #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
|
17 #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
|
18 #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
|
19 #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
|
20 #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
|
21 #include "bridge.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
22 #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
|
23 #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
|
24 #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
|
25 #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
|
26 #include "autoslope.h" |
7849
e6ee8bfd9045
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas <belugas@openttd.org>
parents:
7845
diff
changeset
|
27 #include "transparency.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
|
28 #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
|
29 #include "strings_func.h" |
8140
fb8a05d579da
(svn r11702) -Codechange: move all date related stuff to date*.
rubidium <rubidium@openttd.org>
parents:
8139
diff
changeset
|
30 #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
|
31 #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
|
32 #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
|
33 #include "sound_func.h" |
8238
e9d8b0764f38
(svn r11802) -Fix [FS#716]: do not crash trains when leaving depot to a very long track
smatz <smatz@openttd.org>
parents:
8236
diff
changeset
|
34 #include "signal_func.h" |
8398
a6304b304752
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz <smatz@openttd.org>
parents:
8390
diff
changeset
|
35 #include "tunnelbridge.h" |
8590
0bbc9ad3a6a0
(svn r12171) -Fix [FS#609]: return correct bridge price for AI when DC_QUERY_COST is set (patch by Raimar Falke)
smatz <smatz@openttd.org>
parents:
8589
diff
changeset
|
36 #include "player_base.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 |
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
|
38 #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
|
39 #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
|
40 #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
|
41 |
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
|
42 BridgeSpec _bridge[MAX_BRIDGES]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
43 |
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
|
44 /** 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
|
45 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
|
46 { |
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
|
47 /* First, free sprite table data */ |
8532
b3bd4f1ed981
(svn r12107) -Codechange: Add and use the typedef BridgeType
belugas <belugas@openttd.org>
parents:
8531
diff
changeset
|
48 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
|
49 if (_bridge[i].sprite_table != NULL) { |
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 for (uint j = 0; j < 7; j++) free(_bridge[i].sprite_table[j]); |
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 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
|
52 } |
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 } |
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 |
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 /* 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
|
56 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
|
57 /* 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
|
58 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
|
59 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
60 |
6422
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
61 /** 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
|
62 * 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
|
63 */ |
5584
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 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
|
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 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
|
67 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
|
68 |
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 < 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
|
70 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
|
71 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
|
72 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
|
73 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
|
74 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
|
75 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
76 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
77 |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
78 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
|
79 { |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
80 if ((tileh == SLOPE_FLAT) || |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
81 (((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
|
82 (((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
|
83 |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
84 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
|
85 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
86 |
8379
bf751c81fa2f
(svn r11946) -Fix: slope detection of bridge ramps.
frosch <frosch@openttd.org>
parents:
8371
diff
changeset
|
87 /** |
bf751c81fa2f
(svn r11946) -Fix: slope detection of bridge ramps.
frosch <frosch@openttd.org>
parents:
8371
diff
changeset
|
88 * 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
|
89 * |
bf751c81fa2f
(svn r11946) -Fix: slope detection of bridge ramps.
frosch <frosch@openttd.org>
parents:
8371
diff
changeset
|
90 * @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
|
91 * @param axis Orientation of bridge |
bf751c81fa2f
(svn r11946) -Fix: slope detection of bridge ramps.
frosch <frosch@openttd.org>
parents:
8371
diff
changeset
|
92 * @return true iff the track is flat. |
bf751c81fa2f
(svn r11946) -Fix: slope detection of bridge ramps.
frosch <frosch@openttd.org>
parents:
8371
diff
changeset
|
93 */ |
bf751c81fa2f
(svn r11946) -Fix: slope detection of bridge ramps.
frosch <frosch@openttd.org>
parents:
8371
diff
changeset
|
94 bool HasBridgeFlatRamp(Slope tileh, Axis axis) |
bf751c81fa2f
(svn r11946) -Fix: slope detection of bridge ramps.
frosch <frosch@openttd.org>
parents:
8371
diff
changeset
|
95 { |
bf751c81fa2f
(svn r11946) -Fix: slope detection of bridge ramps.
frosch <frosch@openttd.org>
parents:
8371
diff
changeset
|
96 ApplyFoundationToSlope(GetBridgeFoundation(tileh, axis), &tileh); |
bf751c81fa2f
(svn r11946) -Fix: slope detection of bridge ramps.
frosch <frosch@openttd.org>
parents:
8371
diff
changeset
|
97 /* 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
|
98 return (tileh != SLOPE_FLAT); |
bf751c81fa2f
(svn r11946) -Fix: slope detection of bridge ramps.
frosch <frosch@openttd.org>
parents:
8371
diff
changeset
|
99 } |
bf751c81fa2f
(svn r11946) -Fix: slope detection of bridge ramps.
frosch <frosch@openttd.org>
parents:
8371
diff
changeset
|
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
|
101 static inline const PalSpriteID *GetBridgeSpriteTable(int index, byte table) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
102 { |
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
|
103 const BridgeSpec *bridge = GetBridgeSpec(index); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
104 assert(table < 7); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
105 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
|
106 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
|
107 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
108 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
|
109 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
110 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
111 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
112 |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
113 /** |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
114 * 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
|
115 * |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
116 * @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
|
117 * @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
|
118 * @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
|
119 * @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
|
120 */ |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
121 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
|
122 { |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
123 Foundation f = GetBridgeFoundation(*tileh, axis); |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
124 *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
|
125 |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
126 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
|
127 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
|
128 |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
129 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
|
130 |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
131 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
|
132 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
133 |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
134 /** |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
135 * 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
|
136 * |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
137 * @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
|
138 * @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
|
139 * @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
|
140 * @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
|
141 */ |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
142 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
|
143 { |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
144 Foundation f = GetBridgeFoundation(*tileh, axis); |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
145 *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
|
146 |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
147 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
|
148 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
|
149 |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
150 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
|
151 |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
152 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
|
153 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
154 |
8532
b3bd4f1ed981
(svn r12107) -Codechange: Add and use the typedef BridgeType
belugas <belugas@openttd.org>
parents:
8531
diff
changeset
|
155 bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
156 { |
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
|
157 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
|
158 uint max; // max possible length of a bridge (with patch 100) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
159 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
160 if (bridge_type >= MAX_BRIDGES) 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
|
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 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
163 max = b->max_length; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
164 if (max >= 16 && _patches.longbridges) max = 100; |
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 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
174 * - p2 = (bit 0- 7) - bridge type (hi bh) |
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
|
175 * - p2 = (bit 8-..) - rail type or road types. |
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
|
176 * - p2 = (bit 15 ) - set means road 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
|
177 */ |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6857
diff
changeset
|
178 CommandCost CmdBuildBridge(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2) |
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: |
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
|
213 roadtypes = (RoadTypes)GB(p2, 8, 3); |
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
|
214 if (!AreValidRoadTypes(roadtypes) || !HasRoadTypesAvail(_current_player, roadtypes)) 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
|
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: |
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
|
218 railtype = (RailType)GB(p2, 8, 8); |
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 |
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
|
222 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
|
223 /* For now, only TRANSPORT_RAIL and TRANSPORT_ROAD are allowed. |
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
|
224 * But let not this stops us for preparing the future */ |
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 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
|
226 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
227 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
228 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
|
229 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
|
230 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
|
231 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
|
232 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
233 /* 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
|
234 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
|
235 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
|
236 direction = AXIS_Y; |
6106 | 237 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
|
238 } 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
|
239 direction = AXIS_X; |
6106 | 240 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
|
241 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
242 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
|
243 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
244 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
245 /* set and test bridge length, availability */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
246 bridge_len = sx + sy - x - y - 1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
247 if (!CheckBridge_Stuff(bridge_type, bridge_len)) return_cmd_error(STR_5015_CAN_T_BUILD_BRIDGE_HERE); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
248 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
249 /* 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
|
250 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
|
251 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
|
252 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
|
253 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
|
254 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
255 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
256 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
|
257 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
|
258 |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
259 CommandCost terraform_cost_north = CheckBridgeSlopeNorth(direction, &tileh_start, &z_start); |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
260 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
|
261 |
7682
166e9289116a
(svn r11213) -Fix [FS#1298]: confusing messages when trying to build a bridge.
rubidium <rubidium@openttd.org>
parents:
7677
diff
changeset
|
262 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
|
263 |
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
|
264 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
|
265 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
|
266 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
|
267 /* 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
|
268 |
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 /* 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
|
270 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
|
271 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
|
272 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
273 |
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
|
274 /* 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
|
275 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
|
276 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
|
277 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
|
278 |
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
|
279 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
|
280 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
|
281 } 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
|
282 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
|
283 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
|
284 } |
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 } |
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 |
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 /* 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
|
288 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
|
289 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
|
290 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
291 |
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
|
292 /* Do not allow replacing another player's 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
|
293 if (!IsTileOwner(tile_start, _current_player) && !IsTileOwner(tile_start, OWNER_TOWN)) { |
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 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
|
295 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
296 |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6943
diff
changeset
|
297 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
|
298 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
|
299 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
|
300 |
c67d99aa2eb2
(svn r9940) -Fix [FS#805]: upgrading a bridge removed roadtypes.
rubidium <rubidium@openttd.org>
parents:
6699
diff
changeset
|
301 /* 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
|
302 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
|
303 } 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
|
304 /* 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
|
305 |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
306 bool allow_on_slopes = (!_is_old_ai_player && _patches.build_on_slopes); |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
307 |
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
|
308 /* 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
|
309 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
|
310 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
|
311 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
|
312 |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
313 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
|
314 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
|
315 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
|
316 |
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
|
317 /* 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
|
318 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
|
319 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
|
320 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
|
321 |
6422
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
322 /* 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
|
323 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
|
324 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
|
325 cost.AddCost(terraform_cost_south); |
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
|
326 } |
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
|
327 |
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 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
|
329 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
|
330 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
|
331 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
332 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
|
333 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
|
334 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
|
335 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
|
336 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
337 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
|
338 |
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 (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
|
340 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
|
341 } |
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 } |
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 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
346 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
347 /* 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
|
348 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
|
349 DiagDirection dir = AxisToDiagDir(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
|
350 Owner owner = (replace_bridge && IsTileOwner(tile_start, OWNER_TOWN)) ? OWNER_TOWN : _current_player; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
351 |
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
|
352 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
|
353 case TRANSPORT_RAIL: |
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
|
354 MakeRailBridgeRamp(tile_start, owner, bridge_type, 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
|
355 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
|
356 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
|
357 |
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 case TRANSPORT_ROAD: |
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 MakeRoadBridgeRamp(tile_start, owner, bridge_type, 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
|
360 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
|
361 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
|
362 |
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
|
363 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
|
364 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
|
365 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
|
366 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
367 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
|
368 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
|
369 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
370 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
371 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
|
372 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
|
373 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
|
374 |
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
|
375 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
|
376 /* 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
|
377 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
|
378 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
379 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
380 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
|
381 case MP_WATER: |
7758
013f54f32e5e
(svn r11303) -Fix: EnsureNoVehicle and EnsureNoVehicleOnGround were both used to check whether there was no vehicle on the ground, except that the former didn't take care of aircraft shadows. So now we only use EnsureNoVehicleOnGround.
rubidium <rubidium@openttd.org>
parents:
7739
diff
changeset
|
382 if (!EnsureNoVehicleOnGround(tile)) return_cmd_error(STR_980E_SHIP_IN_THE_WAY); |
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
|
383 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
|
384 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
385 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
386 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
|
387 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
|
388 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
389 |
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
|
390 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
|
391 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
|
392 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
393 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
394 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
|
395 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
|
396 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
|
397 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
|
398 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
|
399 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
400 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
401 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
|
402 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
|
403 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
404 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
405 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
|
406 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
407 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
408 default: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
409 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
|
410 /* 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
|
411 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
|
412 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
|
413 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
|
414 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
415 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
416 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
417 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
|
418 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
|
419 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
|
420 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
421 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
422 |
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
|
423 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
|
424 Track track = AxisToTrack(direction); |
8306
ea2c123b3655
(svn r11871) -Fix [FS#1074]: do not update signals after each tile when building/removing a large block of track/signals/station
smatz <smatz@openttd.org>
parents:
8300
diff
changeset
|
425 AddSideToSignalBuffer(tile_start, INVALID_DIAGDIR, _current_player); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
426 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
|
427 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
428 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
429 /* 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
|
430 * 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
|
431 * 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
|
432 */ |
8590
0bbc9ad3a6a0
(svn r12171) -Fix [FS#609]: return correct bridge price for AI when DC_QUERY_COST is set (patch by Raimar Falke)
smatz <smatz@openttd.org>
parents:
8589
diff
changeset
|
433 if (!(flags & DC_QUERY_COST) || (IsValidPlayer(_current_player) && GetPlayer(_current_player)->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
|
434 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
|
435 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
436 if (IsValidPlayer(_current_player) && !_is_old_ai_player) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
437 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
|
438 |
8491
cf57eb06b4d9
(svn r12066) -Codechange: Rename GetBridge for the more common GetBridgeSpec
belugas <belugas@openttd.org>
parents:
8489
diff
changeset
|
439 cost.AddCost((int64)bridge_len * _price.build_bridge * GetBridgeSpec(bridge_type)->price >> 8); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
440 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
441 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
442 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
|
443 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
444 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
445 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
446 /** Build Tunnel. |
6484
17fdaec13730
(svn r9665) -Documentation: Doxygen corrections,errors, corrections of corrections...
belugas <belugas@openttd.org>
parents:
6427
diff
changeset
|
447 * @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
|
448 * @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
|
449 * @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
|
450 * @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
|
451 */ |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6857
diff
changeset
|
452 CommandCost CmdBuildTunnel(TileIndex start_tile, uint32 flags, uint32 p1, uint32 p2) |
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 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
|
455 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
|
456 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
|
457 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
|
458 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
|
459 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
|
460 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
|
461 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
|
462 CommandCost cost(EXPENSES_CONSTRUCTION); |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6857
diff
changeset
|
463 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
|
464 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
465 _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
|
466 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
|
467 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
|
468 } else { |
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
|
469 const RoadTypes rts = (RoadTypes)GB(p1, 0, 3); |
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
|
470 if (!AreValidRoadTypes(rts) || !HasRoadTypesAvail(_current_player, 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
|
471 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
472 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
473 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
|
474 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
|
475 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
|
476 |
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
|
477 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
|
478 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
479 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
|
480 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
|
481 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
482 /* 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
|
483 * 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
|
484 * 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
|
485 * 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
|
486 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
487 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
|
488 DiagDirection tunnel_in_way_dir; |
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
|
489 if (OtherAxis(DiagDirToAxis(direction)) == AXIS_X) { |
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
|
490 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
|
491 } 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
|
492 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
|
493 } |
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
|
494 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
495 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
|
496 |
cfd4d752ab7f
(svn r10362) -Codechange: make tunnel costs less exponential for (very) long tunnels.
rubidium <rubidium@openttd.org>
parents:
7044
diff
changeset
|
497 /** 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
|
498 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
|
499 /** 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
|
500 int tiles = 0; |
7308
45a7fdc97647
(svn r10660) -Codechange: simplified tunnel cost algorithm (bilbo)
truelight <truelight@openttd.org>
parents:
7266
diff
changeset
|
501 /** 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
|
502 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
|
503 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
504 for (;;) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
505 end_tile += delta; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
506 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
|
507 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
508 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
|
509 |
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
|
510 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
|
511 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
|
512 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
513 |
7095
cfd4d752ab7f
(svn r10362) -Codechange: make tunnel costs less exponential for (very) long tunnels.
rubidium <rubidium@openttd.org>
parents:
7044
diff
changeset
|
514 tiles++; |
7308
45a7fdc97647
(svn r10660) -Codechange: simplified tunnel cost algorithm (bilbo)
truelight <truelight@openttd.org>
parents:
7266
diff
changeset
|
515 if (tiles == tiles_bump) { |
45a7fdc97647
(svn r10660) -Codechange: simplified tunnel cost algorithm (bilbo)
truelight <truelight@openttd.org>
parents:
7266
diff
changeset
|
516 tiles_coef++; |
45a7fdc97647
(svn r10660) -Codechange: simplified tunnel cost algorithm (bilbo)
truelight <truelight@openttd.org>
parents:
7266
diff
changeset
|
517 tiles_bump *= 2; |
45a7fdc97647
(svn r10660) -Codechange: simplified tunnel cost algorithm (bilbo)
truelight <truelight@openttd.org>
parents:
7266
diff
changeset
|
518 } |
7095
cfd4d752ab7f
(svn r10362) -Codechange: make tunnel costs less exponential for (very) long tunnels.
rubidium <rubidium@openttd.org>
parents:
7044
diff
changeset
|
519 |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6943
diff
changeset
|
520 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
|
521 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
|
522 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
523 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
524 /* 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
|
525 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
|
526 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
|
527 |
6422
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
528 /* 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
|
529 _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
|
530 |
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
|
531 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
|
532 |
6422
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
533 /* 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
|
534 if (end_tileh != ComplementSlope(start_tileh)) { |
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
|
535 /* Check if there is a structure on the terraformed tile. Do not add the cost, that will be done by the terraforming */ |
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
|
536 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
|
537 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
|
538 |
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
|
539 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
|
540 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
|
541 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
542 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
|
543 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
|
544 } |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6943
diff
changeset
|
545 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
|
546 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
|
547 |
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 (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
|
549 if (transport_type == TRANSPORT_RAIL) { |
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
|
550 MakeRailTunnel(start_tile, _current_player, direction, (RailType)GB(p1, 0, 4)); |
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
551 MakeRailTunnel(end_tile, _current_player, ReverseDiagDir(direction), (RailType)GB(p1, 0, 4)); |
8306
ea2c123b3655
(svn r11871) -Fix [FS#1074]: do not update signals after each tile when building/removing a large block of track/signals/station
smatz <smatz@openttd.org>
parents:
8300
diff
changeset
|
552 AddSideToSignalBuffer(start_tile, INVALID_DIAGDIR, _current_player); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
553 YapfNotifyTrackLayoutChange(start_tile, AxisToTrack(DiagDirToAxis(direction))); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
554 } else { |
6663
9891bf71d5f0
(svn r9894) -Fix (r9892): catenary was drawn on road bridges ;)
rubidium <rubidium@openttd.org>
parents:
6661
diff
changeset
|
555 MakeRoadTunnel(start_tile, _current_player, direction, (RoadTypes)GB(p1, 0, 3)); |
9891bf71d5f0
(svn r9894) -Fix (r9892): catenary was drawn on road bridges ;)
rubidium <rubidium@openttd.org>
parents:
6661
diff
changeset
|
556 MakeRoadTunnel(end_tile, _current_player, ReverseDiagDir(direction), (RoadTypes)GB(p1, 0, 3)); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
557 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
558 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
559 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
560 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
|
561 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
562 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
563 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
564 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
|
565 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
566 /* Floods can remove anything as well as the scenario editor */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
567 if (_current_player == OWNER_WATER || _game_mode == GM_EDITOR) return true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
568 /* Obviously if the bridge/tunnel belongs to us, or no-one, we can remove it */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
569 if (CheckTileOwnership(tile) || IsTileOwner(tile, OWNER_NONE)) return true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
570 /* Otherwise we can only remove town-owned stuff with extra patch-settings, or cheat */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
571 if (IsTileOwner(tile, OWNER_TOWN) && (_patches.extra_dynamite || _cheats.magic_bulldozer.value)) return true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
572 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
|
573 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
574 |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6857
diff
changeset
|
575 static CommandCost DoClearTunnel(TileIndex tile, uint32 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
|
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 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
|
578 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
|
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 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
|
581 |
8072
0cba7093ca14
(svn r11633) -Codechange: merge CheckTunnelEmpty and IsVehicleOnBridge into GetVehicleTunnelBridge
smatz <smatz@openttd.org>
parents:
8043
diff
changeset
|
582 endtile = GetOtherTunnelEnd(tile); |
0cba7093ca14
(svn r11633) -Codechange: merge CheckTunnelEmpty and IsVehicleOnBridge into GetVehicleTunnelBridge
smatz <smatz@openttd.org>
parents:
8043
diff
changeset
|
583 |
0cba7093ca14
(svn r11633) -Codechange: merge CheckTunnelEmpty and IsVehicleOnBridge into GetVehicleTunnelBridge
smatz <smatz@openttd.org>
parents:
8043
diff
changeset
|
584 if (GetVehicleTunnelBridge(tile, endtile) != NULL) 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
|
585 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
586 _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
|
587 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
588 if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
589 t = ClosestTownFromTile(tile, (uint)-1); // town penalty rating |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
590 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
591 /* 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
|
592 * 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
|
593 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
|
594 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
|
595 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
|
596 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
597 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
598 |
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
|
599 /* 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
|
600 * 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
|
601 if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) { |
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
|
602 ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM); |
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
|
603 } |
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
|
604 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
605 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
|
606 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
|
607 /* 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
|
608 DiagDirection dir = GetTunnelBridgeDirection(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
|
609 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
|
610 |
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
|
611 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
|
612 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
|
613 |
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
|
614 /* cannot use INVALID_DIAGDIR for signal update because the tunnel doesn't exist anymore */ |
8306
ea2c123b3655
(svn r11871) -Fix [FS#1074]: do not update signals after each tile when building/removing a large block of track/signals/station
smatz <smatz@openttd.org>
parents:
8300
diff
changeset
|
615 AddSideToSignalBuffer(tile, ReverseDiagDir(dir), owner); |
ea2c123b3655
(svn r11871) -Fix [FS#1074]: do not update signals after each tile when building/removing a large block of track/signals/station
smatz <smatz@openttd.org>
parents:
8300
diff
changeset
|
616 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
|
617 |
6556baf1d76d
(svn r11861) -Fix: do not call rail specific functions when removing road tunnel/bridge
smatz <smatz@openttd.org>
parents:
8264
diff
changeset
|
618 Track track = AxisToTrack(DiagDirToAxis(dir)); |
6556baf1d76d
(svn r11861) -Fix: do not call rail specific functions when removing road tunnel/bridge
smatz <smatz@openttd.org>
parents:
8264
diff
changeset
|
619 YapfNotifyTrackLayoutChange(tile, track); |
6556baf1d76d
(svn r11861) -Fix: do not call rail specific functions when removing road tunnel/bridge
smatz <smatz@openttd.org>
parents:
8264
diff
changeset
|
620 YapfNotifyTrackLayoutChange(endtile, track); |
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
|
621 } 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
|
622 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
|
623 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
|
624 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
625 } |
8398
a6304b304752
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz <smatz@openttd.org>
parents:
8390
diff
changeset
|
626 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
|
627 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
628 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
629 |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6857
diff
changeset
|
630 static CommandCost DoClearBridge(TileIndex tile, uint32 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
|
631 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
632 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
|
633 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
|
634 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
|
635 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
|
636 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
637 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
|
638 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
639 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
|
640 |
8072
0cba7093ca14
(svn r11633) -Codechange: merge CheckTunnelEmpty and IsVehicleOnBridge into GetVehicleTunnelBridge
smatz <smatz@openttd.org>
parents:
8043
diff
changeset
|
641 if (GetVehicleTunnelBridge(tile, endtile) != NULL) 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
|
642 |
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
|
643 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
|
644 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
|
645 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
646 if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
647 t = ClosestTownFromTile(tile, (uint)-1); // town penalty rating |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
648 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
649 /* 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
|
650 * 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
|
651 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
|
652 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
|
653 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
|
654 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
655 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
656 |
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
|
657 /* 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
|
658 * 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
|
659 if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) { |
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
|
660 ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM); |
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
|
661 } |
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
|
662 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
663 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
|
664 /* 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
|
665 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
|
666 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
|
667 uint height = GetBridgeHeight(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
|
668 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
669 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
|
670 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
|
671 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
|
672 /* 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
|
673 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
|
674 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
|
675 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
|
676 } |
8297
6556baf1d76d
(svn r11861) -Fix: do not call rail specific functions when removing road tunnel/bridge
smatz <smatz@openttd.org>
parents:
8264
diff
changeset
|
677 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
|
678 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
|
679 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
680 |
8297
6556baf1d76d
(svn r11861) -Fix: do not call rail specific functions when removing road tunnel/bridge
smatz <smatz@openttd.org>
parents:
8264
diff
changeset
|
681 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
|
682 /* cannot use INVALID_DIAGDIR for signal update because the bridge doesn't exist anymore */ |
8306
ea2c123b3655
(svn r11871) -Fix [FS#1074]: do not update signals after each tile when building/removing a large block of track/signals/station
smatz <smatz@openttd.org>
parents:
8300
diff
changeset
|
683 AddSideToSignalBuffer(tile, ReverseDiagDir(direction), owner); |
ea2c123b3655
(svn r11871) -Fix [FS#1074]: do not update signals after each tile when building/removing a large block of track/signals/station
smatz <smatz@openttd.org>
parents:
8300
diff
changeset
|
684 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
|
685 |
6556baf1d76d
(svn r11861) -Fix: do not call rail specific functions when removing road tunnel/bridge
smatz <smatz@openttd.org>
parents:
8264
diff
changeset
|
686 Track track = AxisToTrack(DiagDirToAxis(direction)); |
6556baf1d76d
(svn r11861) -Fix: do not call rail specific functions when removing road tunnel/bridge
smatz <smatz@openttd.org>
parents:
8264
diff
changeset
|
687 YapfNotifyTrackLayoutChange(tile, track); |
6556baf1d76d
(svn r11861) -Fix: do not call rail specific functions when removing road tunnel/bridge
smatz <smatz@openttd.org>
parents:
8264
diff
changeset
|
688 YapfNotifyTrackLayoutChange(endtile, track); |
6556baf1d76d
(svn r11861) -Fix: do not call rail specific functions when removing road tunnel/bridge
smatz <smatz@openttd.org>
parents:
8264
diff
changeset
|
689 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
690 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
691 |
8398
a6304b304752
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz <smatz@openttd.org>
parents:
8390
diff
changeset
|
692 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
|
693 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
694 |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6857
diff
changeset
|
695 static CommandCost ClearTile_TunnelBridge(TileIndex tile, byte 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
|
696 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
697 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
|
698 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
|
699 return DoClearTunnel(tile, flags); |
8390
381a22f19287
(svn r11960) -Cleanup: simplify some IsTunnel(Tile) / IsBridge(Tile) conditions
smatz <smatz@openttd.org>
parents:
8385
diff
changeset
|
700 } 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
|
701 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
|
702 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
|
703 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
704 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
705 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
|
706 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
707 |
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
|
708 /** |
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
|
709 * 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
|
710 * |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
711 * @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
|
712 * @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
|
713 * @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
|
714 * @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
|
715 * @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
|
716 * @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
|
717 * @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
|
718 */ |
8532
b3bd4f1ed981
(svn r12107) -Codechange: Add and use the typedef BridgeType
belugas <belugas@openttd.org>
parents:
8531
diff
changeset
|
719 static void DrawBridgePillars(const PalSpriteID *psid, const TileInfo* ti, Axis axis, BridgeType type, 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
|
720 { |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
721 SpriteID image = psid->sprite; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
722 if (image != 0) { |
8491
cf57eb06b4d9
(svn r12066) -Codechange: Rename GetBridge for the more common GetBridgeSpec
belugas <belugas@openttd.org>
parents:
8489
diff
changeset
|
723 bool drawfarpillar = !HasBit(GetBridgeSpec(type)->flags, 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
|
724 |
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
|
725 /* "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
|
726 * 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
|
727 * |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
728 * 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
|
729 * 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
|
730 * 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
|
731 * |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
732 * 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
|
733 */ |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7923
diff
changeset
|
734 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
|
735 |
6f07e415b521
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7697
diff
changeset
|
736 /* "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
|
737 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
|
738 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
|
739 |
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
|
740 /* 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
|
741 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
|
742 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
|
743 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
|
744 |
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
|
745 /* 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
|
746 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
|
747 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
|
748 /* 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
|
749 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
|
750 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
|
751 |
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
|
752 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
|
753 /* 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
|
754 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
|
755 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
|
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 |
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
|
758 /* 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
|
759 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
|
760 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
|
761 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
762 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
763 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
764 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
765 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
766 /** |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
767 * 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
|
768 * @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
|
769 * @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
|
770 * @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
|
771 * @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
|
772 * @param overlay do we want to still see the road? |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
773 */ |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
774 static void DrawBridgeTramBits(int x, int y, byte z, int offset, bool overlay) |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
775 { |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
776 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
|
777 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
|
778 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
|
779 |
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
|
780 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
|
781 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
|
782 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
|
783 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
|
784 |
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
|
785 /* 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
|
786 * The bounding boxes here are the same as for bridge front/roof */ |
7849
e6ee8bfd9045
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas <belugas@openttd.org>
parents:
7845
diff
changeset
|
787 AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + tram_offsets[overlay][offset], PAL_NONE, x, y, size_x[offset], size_y[offset], 0x28, z, IsTransparencySet(TO_BRIDGES)); |
6699
323f494a7076
(svn r9931) -Fix: some glitches with catenary and bridges.
rubidium <rubidium@openttd.org>
parents:
6691
diff
changeset
|
788 |
8528
58090cf32d23
(svn r12103) -Feature(tte): separate catenary transparency settings from building transparency settings
smatz <smatz@openttd.org>
parents:
8519
diff
changeset
|
789 AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + back_offsets[offset], PAL_NONE, x, y, size_x[offset], size_y[offset], 0x28, z, IsTransparencySet(TO_CATENARY)); |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
790 |
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
|
791 /* 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
|
792 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
|
793 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
|
794 |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
795 /* For sloped sprites the bounding box needs to be higher, as the pylons stop on a higher point */ |
8528
58090cf32d23
(svn r12103) -Feature(tte): separate catenary transparency settings from building transparency settings
smatz <smatz@openttd.org>
parents:
8519
diff
changeset
|
796 AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + front_offsets[offset], PAL_NONE, x, y, size_x[offset] + front_bb_offset_x[offset], size_y[offset] + front_bb_offset_y[offset], 0x28, z, IsTransparencySet(TO_CATENARY), front_bb_offset_x[offset], front_bb_offset_y[offset]); |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
797 } |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
798 |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
799 /** |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
800 * 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
|
801 * 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
|
802 * 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
|
803 * 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
|
804 * @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
|
805 * <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
|
806 * <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
|
807 * <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
|
808 * <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
|
809 * </ul> |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
810 * 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
|
811 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
812 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
|
813 { |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
814 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
|
815 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
|
816 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
|
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 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
|
819 /* 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
|
820 * |
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
|
821 * 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
|
822 * 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
|
823 * 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
|
824 * 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
|
825 * |
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
|
826 */ |
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
|
827 |
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
|
828 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
|
829 /* 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
|
830 * 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
|
831 { 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
|
832 { 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
|
833 { 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
|
834 { 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
|
835 }; |
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
|
836 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
|
837 |
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 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
|
839 |
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
|
840 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
|
841 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
|
842 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
843 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
|
844 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
845 |
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
|
846 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
|
847 |
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
|
848 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
|
849 DrawGroundSprite(image, PAL_NONE); |
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
|
850 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
|
851 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
|
852 |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7923
diff
changeset
|
853 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
|
854 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
|
855 |
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
|
856 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
|
857 |
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 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
|
859 StartSpriteCombine(); |
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
|
860 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); |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
861 } |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
862 } else if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) { |
6663
9891bf71d5f0
(svn r9894) -Fix (r9892): catenary was drawn on road bridges ;)
rubidium <rubidium@openttd.org>
parents:
6661
diff
changeset
|
863 DrawCatenary(ti); |
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
|
864 |
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
|
865 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
|
866 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
|
867 DrawCatenaryOnTunnel(ti); |
6663
9891bf71d5f0
(svn r9894) -Fix (r9892): catenary was drawn on road bridges ;)
rubidium <rubidium@openttd.org>
parents:
6661
diff
changeset
|
868 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
869 |
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
|
870 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
|
871 |
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
|
872 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
|
873 |
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
|
874 /* 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
|
875 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
|
876 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
|
877 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
878 DrawBridgeMiddle(ti); |
8390
381a22f19287
(svn r11960) -Cleanup: simplify some IsTunnel(Tile) / IsBridge(Tile) conditions
smatz <smatz@openttd.org>
parents:
8385
diff
changeset
|
879 } 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
|
880 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
|
881 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
|
882 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
|
883 |
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
|
884 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
|
885 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
|
886 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
|
887 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
888 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
|
889 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
890 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
891 /* 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
|
892 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
|
893 |
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
|
894 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
|
895 |
6422
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
896 /* 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
|
897 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
|
898 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
899 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
|
900 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
901 /* Table number 6 always refers to the bridge heads for any bridge type */ |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
902 psid = &GetBridgeSpriteTable(GetBridgeType(ti->tile), 6)[base_offset]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
903 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
904 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
|
905 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
|
906 } else { |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
907 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
|
908 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
909 |
6422
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
910 /* 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
|
911 |
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
|
912 /* 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
|
913 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
|
914 |
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 /* 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
|
916 * 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
|
917 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
918 AddSortableSpriteToDraw( |
7849
e6ee8bfd9045
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas <belugas@openttd.org>
parents:
7845
diff
changeset
|
919 psid->sprite, psid->pal, ti->x, ti->y, 16, 16, ti->tileh == SLOPE_FLAT ? 0 : 8, ti->z, IsTransparencySet(TO_BRIDGES) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
920 ); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
921 |
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
|
922 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
|
923 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
|
924 |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7923
diff
changeset
|
925 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
|
926 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
|
927 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
|
928 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
|
929 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
|
930 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
|
931 } else { |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
932 offset += 2; |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
933 } |
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
|
934 /* DrawBridgeTramBits() calls EndSpriteCombine() and StartSpriteCombine() */ |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7923
diff
changeset
|
935 DrawBridgeTramBits(ti->x, ti->y, z, offset, HasBit(rts, ROADTYPE_ROAD)); |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
936 } |
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
|
937 EndSpriteCombine(); |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
938 } else if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) { |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
939 DrawCatenary(ti); |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
940 } |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
941 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
942 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
|
943 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
944 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
945 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
946 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
947 /** Compute bridge piece. Computes the bridge piece to display depending on the position inside the bridge. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
948 * bridges pieces sequence (middle parts) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
949 * bridge len 1: 0 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
950 * bridge len 2: 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
|
951 * bridge len 3: 0 4 1 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
952 * bridge len 4: 0 2 3 1 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
953 * bridge len 5: 0 2 5 3 1 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
954 * bridge len 6: 0 2 3 2 3 1 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
955 * bridge len 7: 0 2 3 4 2 3 1 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
956 * #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
|
957 * #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
|
958 * 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
|
959 * @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
|
960 * @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
|
961 * @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
|
962 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
963 static uint CalcBridgePiece(uint north, uint south) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
964 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
965 if (north == 1) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
966 return 0; |
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 if (south == 1) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
968 return 1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
969 } else if (north < south) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
970 return north & 1 ? 3 : 2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
971 } else if (north > south) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
972 return south & 1 ? 2 : 3; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
973 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
974 return north & 1 ? 5 : 4; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
975 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
976 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
977 |
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 void DrawBridgeMiddle(const 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
|
980 { |
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
|
981 /* 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
|
982 * |
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
|
983 * 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
|
984 * 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
|
985 * 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
|
986 * 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
|
987 * 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
|
988 * 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
|
989 * 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
|
990 * <- 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
|
991 * 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
|
992 * 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
|
993 * 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
|
994 * |
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
|
995 */ |
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 |
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
|
997 /* 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
|
998 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
|
999 |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
1000 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
|
1001 uint base_offset; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1002 TileIndex rampnorth; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1003 TileIndex rampsouth; |
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
|
1004 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
|
1005 Axis axis; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1006 uint piece; |
8532
b3bd4f1ed981
(svn r12107) -Codechange: Add and use the typedef BridgeType
belugas <belugas@openttd.org>
parents:
8531
diff
changeset
|
1007 BridgeType 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
|
1008 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
|
1009 int y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1010 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
|
1011 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1012 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
|
1013 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1014 rampnorth = GetNorthernBridgeEnd(ti->tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1015 rampsouth = GetSouthernBridgeEnd(ti->tile); |
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
|
1016 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
|
1017 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1018 axis = GetBridgeAxis(ti->tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1019 piece = CalcBridgePiece( |
8398
a6304b304752
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz <smatz@openttd.org>
parents:
8390
diff
changeset
|
1020 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
|
1021 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
|
1022 ); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1023 type = GetBridgeType(rampsouth); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1024 |
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
|
1025 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
|
1026 base_offset = GetRailTypeInfo(GetRailType(rampsouth))->bridge_offset; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1027 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1028 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
|
1029 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1030 |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
1031 psid = base_offset + GetBridgeSpriteTable(type, piece); |
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
1032 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
|
1033 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1034 x = ti->x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1035 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
|
1036 uint bridge_z = GetBridgeHeight(rampsouth); |
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
|
1037 z = bridge_z - BRIDGE_Z_START; |
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
|
1038 |
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
|
1039 /* 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
|
1040 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
|
1041 |
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
|
1042 /* 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
|
1043 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
|
1044 |
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
|
1045 /* Draw floor and far part of bridge*/ |
7333
7110c41ab174
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium <rubidium@openttd.org>
parents:
7308
diff
changeset
|
1046 if (axis == AXIS_X) { |
7849
e6ee8bfd9045
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas <belugas@openttd.org>
parents:
7845
diff
changeset
|
1047 AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 16, 1, 0x28, z, IsTransparencySet(TO_BRIDGES), 0, 0, BRIDGE_Z_START); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1048 } else { |
7849
e6ee8bfd9045
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas <belugas@openttd.org>
parents:
7845
diff
changeset
|
1049 AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 1, 16, 0x28, z, IsTransparencySet(TO_BRIDGES), 0, 0, BRIDGE_Z_START); |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
1050 } |
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
1051 |
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
1052 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
|
1053 |
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
|
1054 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
|
1055 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
|
1056 |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7923
diff
changeset
|
1057 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
|
1058 /* DrawBridgeTramBits() calls EndSpriteCombine() and StartSpriteCombine() */ |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7923
diff
changeset
|
1059 DrawBridgeTramBits(x, y, bridge_z, axis ^ 1, HasBit(rts, ROADTYPE_ROAD)); |
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
|
1060 } 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
|
1061 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
|
1062 StartSpriteCombine(); |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
1063 } |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6687
diff
changeset
|
1064 } else if (GetRailType(rampsouth) == RAILTYPE_ELECTRIC) { |
6687
e75e7fde5aee
(svn r9919) -Codechange: prepare some more places for more road types.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
1065 DrawCatenary(ti); |
e75e7fde5aee
(svn r9919) -Codechange: prepare some more places for more road types.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
1066 } |
e75e7fde5aee
(svn r9919) -Codechange: prepare some more places for more road types.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
1067 |
6422
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
1068 /* draw roof, the component of the bridge which is logically between the vehicle and the camera */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1069 if (axis == AXIS_X) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1070 y += 12; |
7849
e6ee8bfd9045
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas <belugas@openttd.org>
parents:
7845
diff
changeset
|
1071 if (psid->sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 16, 4, 0x28, z, IsTransparencySet(TO_BRIDGES), 0, 3, BRIDGE_Z_START); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1072 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1073 x += 12; |
7849
e6ee8bfd9045
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas <belugas@openttd.org>
parents:
7845
diff
changeset
|
1074 if (psid->sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 4, 16, 0x28, z, IsTransparencySet(TO_BRIDGES), 3, 0, BRIDGE_Z_START); |
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 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1076 |
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
|
1077 /* 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
|
1078 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
|
1079 |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
1080 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
|
1081 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
|
1082 /* 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
|
1083 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
|
1084 SpriteID image = psid->sprite; |
7110c41ab174
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium <rubidium@openttd.org>
parents:
7308
diff
changeset
|
1085 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
|
1086 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
|
1087 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
|
1088 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
|
1089 } |
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
1090 |
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
1091 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
|
1092 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1093 } else if (_patches.bridge_pillars) { |
6422
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
1094 /* draw pillars below for high bridges */ |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5587
diff
changeset
|
1095 DrawBridgePillars(psid, ti, axis, type, 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
|
1096 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1097 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1098 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1099 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1100 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
|
1101 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1102 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
|
1103 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
|
1104 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1105 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
|
1106 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
|
1107 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1108 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
|
1109 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
|
1110 |
6422
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
1111 /* 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
|
1112 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
|
1113 } 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
|
1114 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
|
1115 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
|
1116 |
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
|
1117 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
|
1118 |
6422
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
1119 /* 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
|
1120 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
|
1121 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
|
1122 |
8379
bf751c81fa2f
(svn r11946) -Fix: slope detection of bridge ramps.
frosch <frosch@openttd.org>
parents:
8371
diff
changeset
|
1123 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
|
1124 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1125 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
|
1126 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
|
1127 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
|
1128 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
|
1129 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
|
1130 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
|
1131 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1132 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
|
1133 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1134 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1135 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1136 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
|
1137 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1138 |
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
|
1139 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
|
1140 { |
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
|
1141 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
|
1142 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1143 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1144 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1145 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
|
1146 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1147 /* 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
|
1148 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1149 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1150 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
|
1151 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1152 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
|
1153 td->str = (GetTunnelBridgeTransportType(tile) == 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
|
1154 STR_5017_RAILROAD_TUNNEL : STR_5018_ROAD_TUNNEL; |
8475
b4303c7799a1
(svn r12048) -Cleanup: Move some strings in the original bridge array, adjust documentation a bit.
belugas <belugas@openttd.org>
parents:
8471
diff
changeset
|
1155 } else { //so it must be a bridge |
8540
5de93bf73609
(svn r12118) -Codechange: Put the two descriptions of bridges in an array instead of two single variables, following the transport type it represents
belugas <belugas@openttd.org>
parents:
8536
diff
changeset
|
1156 td->str = GetBridgeSpec(GetBridgeType(tile))->transport_name[GetTunnelBridgeTransportType(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
|
1157 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1158 td->owner = GetTileOwner(tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1159 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1160 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1161 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1162 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
|
1163 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1164 /* 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
|
1165 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1166 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1167 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
|
1168 { |
8088
5d7c61206209
(svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz <smatz@openttd.org>
parents:
8083
diff
changeset
|
1169 bool snow_or_desert = HasTunnelBridgeSnowOrDesert(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
|
1170 switch (_opt.landscape) { |
6357
96b1652c6011
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas <belugas@openttd.org>
parents:
6343
diff
changeset
|
1171 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
|
1172 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
|
1173 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
|
1174 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
|
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 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1177 |
6357
96b1652c6011
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas <belugas@openttd.org>
parents:
6343
diff
changeset
|
1178 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
|
1179 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
|
1180 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
|
1181 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
|
1182 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1183 break; |
8088
5d7c61206209
(svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz <smatz@openttd.org>
parents:
8083
diff
changeset
|
1184 |
5d7c61206209
(svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz <smatz@openttd.org>
parents:
8083
diff
changeset
|
1185 default: |
5d7c61206209
(svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz <smatz@openttd.org>
parents:
8083
diff
changeset
|
1186 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
|
1187 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1188 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1189 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1190 static void ClickTile_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
|
1191 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1192 /* 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
|
1193 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1194 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1195 |
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
|
1196 static uint32 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
|
1197 { |
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
|
1198 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
|
1199 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
|
1200 |
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
|
1201 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
|
1202 if (side != INVALID_DIAGDIR && side != ReverseDiagDir(dir)) return 0; |
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
|
1203 return AxisToTrackBits(DiagDirToAxis(dir)) * 0x101; |
5584
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 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1206 static void ChangeTileOwner_TunnelBridge(TileIndex tile, PlayerID old_player, PlayerID new_player) |
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 if (!IsTileOwner(tile, old_player)) return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1209 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1210 if (new_player != PLAYER_SPECTATOR) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1211 SetTileOwner(tile, new_player); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1212 } 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
|
1213 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
|
1214 /* 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
|
1215 * the bridge/tunnel. As all *our* vehicles are already removed, they |
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
|
1216 * must be of another owner. Therefor this must be a road bridge/tunnel. |
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
|
1217 * In that case we can safely reassign the ownership to OWNER_NONE. */ |
8088
5d7c61206209
(svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz <smatz@openttd.org>
parents:
8083
diff
changeset
|
1218 assert(GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD); |
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
|
1219 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
|
1220 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1221 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1222 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1223 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1224 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1225 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
|
1226 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
|
1227 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
|
1228 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
|
1229 |
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
|
1230 /** 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
|
1231 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
|
1232 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
|
1233 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1234 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
|
1235 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1236 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
|
1237 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
|
1238 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
|
1239 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
|
1240 |
8119
b6ec923e9fa8
(svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium <rubidium@openttd.org>
parents:
8116
diff
changeset
|
1241 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
|
1242 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1243 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
|
1244 |
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
|
1245 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
|
1246 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
|
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 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
|
1249 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
|
1250 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
|
1251 |
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
|
1252 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
|
1253 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
|
1254 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1255 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
|
1256 |
5993
2498be7c7e94
(svn r8701) -Codechange: replace magic numbers with enums for u.rail.track.
rubidium <rubidium@openttd.org>
parents:
5991
diff
changeset
|
1257 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
|
1258 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
|
1259 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
|
1260 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
|
1261 } |
5991
1b793d99b5ba
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium <rubidium@openttd.org>
parents:
5930
diff
changeset
|
1262 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
|
1263 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1264 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
|
1265 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
|
1266 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
|
1267 v->vehstatus |= VS_HIDDEN; |
5991
1b793d99b5ba
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium <rubidium@openttd.org>
parents:
5930
diff
changeset
|
1268 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
|
1269 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1270 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1271 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1272 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
|
1273 /* 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
|
1274 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
|
1275 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
|
1276 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
|
1277 v->vehstatus &= ~VS_HIDDEN; |
5991
1b793d99b5ba
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium <rubidium@openttd.org>
parents:
5930
diff
changeset
|
1278 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
|
1279 } |
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
|
1280 } 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
|
1281 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
|
1282 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
|
1283 |
6422
fb10eafe2a26
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas <belugas@openttd.org>
parents:
6406
diff
changeset
|
1284 /* 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
|
1285 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
|
1286 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
|
1287 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
|
1288 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
|
1289 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
|
1290 v->vehstatus |= VS_HIDDEN; |
5991
1b793d99b5ba
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium <rubidium@openttd.org>
parents:
5930
diff
changeset
|
1291 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
|
1292 } else { |
5991
1b793d99b5ba
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium <rubidium@openttd.org>
parents:
5930
diff
changeset
|
1293 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
|
1294 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1295 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1296 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1297 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
|
1298 /* 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
|
1299 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
|
1300 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
|
1301 ) && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1302 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
|
1303 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
|
1304 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
|
1305 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
|
1306 v->vehstatus &= ~VS_HIDDEN; |
5991
1b793d99b5ba
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium <rubidium@openttd.org>
parents:
5930
diff
changeset
|
1307 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
|
1308 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1309 } |
8390
381a22f19287
(svn r11960) -Cleanup: simplify some IsTunnel(Tile) / IsBridge(Tile) conditions
smatz <smatz@openttd.org>
parents:
8385
diff
changeset
|
1310 } 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
|
1311 |
7548
c0e537dd249b
(svn r11068) -Codechange: remove Vehicle::HasFront as all vehicles have the Vehicle::first pointer correctly set.
rubidium <rubidium@openttd.org>
parents:
7539
diff
changeset
|
1312 if (v->IsPrimaryVehicle()) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1313 /* modify speed of vehicle */ |
8491
cf57eb06b4d9
(svn r12066) -Codechange: Rename GetBridge for the more common GetBridgeSpec
belugas <belugas@openttd.org>
parents:
8489
diff
changeset
|
1314 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
|
1315 |
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
|
1316 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
|
1317 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
|
1318 } |
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 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
|
1321 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
|
1322 default: NOT_REACHED(); |
5991
1b793d99b5ba
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium <rubidium@openttd.org>
parents:
5930
diff
changeset
|
1323 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
|
1324 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
|
1325 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
|
1326 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
|
1327 } |
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
|
1328 if (v->type == VEH_TRAIN) { |
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
|
1329 v->u.rail.track = TRACK_BIT_WORMHOLE; |
7929
4d13dbed828c
(svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7928
diff
changeset
|
1330 ClrBit(v->u.rail.flags, VRF_GOINGUP); |
4d13dbed828c
(svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7928
diff
changeset
|
1331 ClrBit(v->u.rail.flags, VRF_GOINGDOWN); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1332 } else { |
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
|
1333 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
|
1334 } |
5991
1b793d99b5ba
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium <rubidium@openttd.org>
parents:
5930
diff
changeset
|
1335 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
|
1336 } 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
|
1337 v->tile = tile; |
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
|
1338 if (v->type == VEH_TRAIN) { |
5993
2498be7c7e94
(svn r8701) -Codechange: replace magic numbers with enums for u.rail.track.
rubidium <rubidium@openttd.org>
parents:
5991
diff
changeset
|
1339 if (v->u.rail.track == TRACK_BIT_WORMHOLE) { |
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
|
1340 v->u.rail.track = (DiagDirToAxis(dir) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y); |
5991
1b793d99b5ba
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium <rubidium@openttd.org>
parents:
5930
diff
changeset
|
1341 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
|
1342 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1343 } else { |
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
|
1344 if (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
|
1345 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
|
1346 v->u.road.frame = 0; |
5991
1b793d99b5ba
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium <rubidium@openttd.org>
parents:
5930
diff
changeset
|
1347 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
|
1348 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1349 } |
5991
1b793d99b5ba
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium <rubidium@openttd.org>
parents:
5930
diff
changeset
|
1350 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
|
1351 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1352 } |
5991
1b793d99b5ba
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium <rubidium@openttd.org>
parents:
5930
diff
changeset
|
1353 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
|
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 |
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
|
1356 static CommandCost TerraformTile_TunnelBridge(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new) |
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
|
1357 { |
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
|
1358 if (_patches.build_on_slopes && AutoslopeEnabled() && 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
|
1359 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
|
1360 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
|
1361 CommandCost res; |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
1362 uint z_old; |
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
1363 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
|
1364 |
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
|
1365 /* Check if new slope is valid for bridges in general (so we can savely call GetBridgeFoundation()) */ |
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
|
1366 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
|
1367 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
|
1368 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
|
1369 } else { |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
1370 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
|
1371 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
|
1372 } |
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
|
1373 |
8371
dc34ed2f4803
(svn r11937) -Feature: Allow building bridge heads on more slopes.
frosch <frosch@openttd.org>
parents:
8370
diff
changeset
|
1374 /* 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
|
1375 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
|
1376 } |
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
|
1377 |
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
|
1378 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
|
1379 } |
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
|
1380 |
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
|
1381 extern const TileTypeProcs _tile_type_tunnelbridge_procs = { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1382 DrawTile_TunnelBridge, /* draw_tile_proc */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1383 GetSlopeZ_TunnelBridge, /* get_slope_z_proc */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1384 ClearTile_TunnelBridge, /* clear_tile_proc */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1385 GetAcceptedCargo_TunnelBridge, /* get_accepted_cargo_proc */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1386 GetTileDesc_TunnelBridge, /* get_tile_desc_proc */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1387 GetTileTrackStatus_TunnelBridge, /* get_tile_track_status_proc */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1388 ClickTile_TunnelBridge, /* click_tile_proc */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1389 AnimateTile_TunnelBridge, /* animate_tile_proc */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1390 TileLoop_TunnelBridge, /* tile_loop_clear */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1391 ChangeTileOwner_TunnelBridge, /* change_tile_owner_clear */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1392 NULL, /* get_produced_cargo_proc */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1393 VehicleEnter_TunnelBridge, /* vehicle_enter_tile_proc */ |
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
|
1394 GetFoundation_TunnelBridge, /* get_foundation_proc */ |
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
|
1395 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
|
1396 }; |