Mercurial > hg > openttd
annotate src/road_cmd.cpp @ 8821:2589a14c08fb draft
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
author | smatz <smatz@openttd.org> |
---|---|
date | Fri, 04 Apr 2008 18:41:16 +0000 |
parents | 104bbcae351d |
children | 40fb100b7b49 |
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 |
6393
ffd35446c110
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas <belugas@openttd.org>
parents:
6368
diff
changeset
|
3 /** @file road_cmd.cpp */ |
ffd35446c110
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas <belugas@openttd.org>
parents:
6368
diff
changeset
|
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
|
5 #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
|
6 #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
|
7 #include "bridge_map.h" |
6160
6bb39697173c
(svn r8908) -Codechange: declaration of DrawBridgeMiddle does not belong in a map accessors header.
rubidium <rubidium@openttd.org>
parents:
6134
diff
changeset
|
8 #include "bridge.h" |
6134 | 9 #include "cmd_helper.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
|
10 #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
|
11 #include "road_map.h" |
8102
afb4c7da91df
(svn r11663) -Codechange: moving of the road related types and functions.
rubidium <rubidium@openttd.org>
parents:
8096
diff
changeset
|
12 #include "road_internal.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
|
13 #include "sprite.h" |
8119
b6ec923e9fa8
(svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium <rubidium@openttd.org>
parents:
8116
diff
changeset
|
14 #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
|
15 #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
|
16 #include "town_map.h" |
8224
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8211
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 "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
|
21 #include "depot.h" |
6541
b6b454522d0b
(svn r9730) -Feature: [NewGRF] Add support for miscellaneous grf feature bit 1 - paved roads on desert tiles.
maedhros <maedhros@openttd.org>
parents:
6491
diff
changeset
|
22 #include "newgrf.h" |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
23 #include "station_map.h" |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
24 #include "tunnel_map.h" |
7389
63f05f10a3c1
(svn r10758) -Codechange: make the depot struct use the pool item class as super class.
rubidium <rubidium@openttd.org>
parents:
7370
diff
changeset
|
25 #include "misc/autoptr.hpp" |
8211
165064de4629
(svn r11774) -Change: do not include variables.h in a header when it is not needed.
rubidium <rubidium@openttd.org>
parents:
8197
diff
changeset
|
26 #include "variables.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:
7539
diff
changeset
|
27 #include "autoslope.h" |
7849
e6ee8bfd9045
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas <belugas@openttd.org>
parents:
7832
diff
changeset
|
28 #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
|
29 #include "tunnelbridge_map.h" |
8106
47b1794a7eca
(svn r11667) -Codechange: split window.h into a header that defines some 'global' window related types, on that defined 'global' window functions and one that defines functions and types only used by *_gui.cpps.
rubidium <rubidium@openttd.org>
parents:
8102
diff
changeset
|
30 #include "window_func.h" |
8114
2d6af5d7a142
(svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
8108
diff
changeset
|
31 #include "strings_func.h" |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
8139
diff
changeset
|
32 #include "vehicle_func.h" |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
8139
diff
changeset
|
33 #include "vehicle_base.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
|
34 #include "sound_func.h" |
8342
441cda3cfbdb
(svn r11908) -Fix: update crossing when merging a company, when building a crossing and after loading older savegame
smatz <smatz@openttd.org>
parents:
8308
diff
changeset
|
35 #include "road_func.h" |
8398
a6304b304752
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz <smatz@openttd.org>
parents:
8390
diff
changeset
|
36 #include "tunnelbridge.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
|
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" |
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:
7539
diff
changeset
|
40 |
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:
7539
diff
changeset
|
41 #define M(x) (1 << (x)) |
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:
7539
diff
changeset
|
42 /* Level crossings may only be built on these slopes */ |
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:
7539
diff
changeset
|
43 static const uint32 VALID_LEVEL_CROSSING_SLOPES = (M(SLOPE_SEN) | M(SLOPE_ENW) | M(SLOPE_NWS) | M(SLOPE_NS) | M(SLOPE_WSE) | M(SLOPE_EW) | M(SLOPE_FLAT)); |
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:
7539
diff
changeset
|
44 #undef M |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
45 |
8744
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
46 /* Invalid RoadBits on slopes */ |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
47 static const RoadBits _invalid_tileh_slopes_road[2][15] = { |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
48 /* The inverse of the mixable RoadBits on a leveled slope */ |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
49 { |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
50 ROAD_NONE, // SLOPE_FLAT |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
51 ROAD_NE | ROAD_SE, // SLOPE_W |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
52 ROAD_NE | ROAD_NW, // SLOPE_S |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
53 |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
54 ROAD_NE, // SLOPE_SW |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
55 ROAD_NW | ROAD_SW, // SLOPE_E |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
56 ROAD_NONE, // SLOPE_EW |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
57 |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
58 ROAD_NW, // SLOPE_SE |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
59 ROAD_NONE, // SLOPE_WSE |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
60 ROAD_SE | ROAD_SW, // SLOPE_N |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
61 |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
62 ROAD_SE, // SLOPE_NW |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
63 ROAD_NONE, // SLOPE_NS |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
64 ROAD_NONE, // SLOPE_ENW |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
65 |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
66 ROAD_SW, // SLOPE_NE |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
67 ROAD_NONE, // SLOPE_SEN |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
68 ROAD_NONE // SLOPE_NWS |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
69 }, |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
70 /* The inverse of the allowed straight roads on a slope |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
71 * (with and without a foundation). */ |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
72 { |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
73 ROAD_NONE, // SLOPE_FLAT |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
74 ROAD_NONE, // SLOPE_W Foundation |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
75 ROAD_NONE, // SLOPE_S Foundation |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
76 |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
77 ROAD_Y, // SLOPE_SW |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
78 ROAD_NONE, // SLOPE_E Foundation |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
79 ROAD_ALL, // SLOPE_EW |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
80 |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
81 ROAD_X, // SLOPE_SE |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
82 ROAD_ALL, // SLOPE_WSE |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
83 ROAD_NONE, // SLOPE_N Foundation |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
84 |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
85 ROAD_X, // SLOPE_NW |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
86 ROAD_ALL, // SLOPE_NS |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
87 ROAD_ALL, // SLOPE_ENW |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
88 |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
89 ROAD_Y, // SLOPE_NE |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
90 ROAD_ALL, // SLOPE_SEN |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
91 ROAD_ALL // SLOPE_NW |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
92 } |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
93 }; |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
94 |
8384
30198447a5e7
(svn r11953) -Fix (r11172): do not allow modifying roadbits when other roadtypes would need different foundation
smatz <smatz@openttd.org>
parents:
8344
diff
changeset
|
95 Foundation GetRoadFoundation(Slope tileh, RoadBits bits); |
30198447a5e7
(svn r11953) -Fix (r11172): do not allow modifying roadbits when other roadtypes would need different foundation
smatz <smatz@openttd.org>
parents:
8344
diff
changeset
|
96 |
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:
6626
diff
changeset
|
97 bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, bool *edge_road, RoadType rt) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
98 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
99 *edge_road = true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
100 |
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:
6626
diff
changeset
|
101 if (_game_mode == GM_EDITOR || remove == ROAD_NONE) return 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
|
102 |
6751
f1e45e71da47
(svn r9986) -Fix (r9934): flooding towns could not remove tram tracks (boekabart).
rubidium <rubidium@openttd.org>
parents:
6732
diff
changeset
|
103 /* Water can always flood and towns can always remove "normal" road pieces. |
f1e45e71da47
(svn r9986) -Fix (r9934): flooding towns could not remove tram tracks (boekabart).
rubidium <rubidium@openttd.org>
parents:
6732
diff
changeset
|
104 * Towns are not be allowed to remove non "normal" road pieces, like tram |
f1e45e71da47
(svn r9986) -Fix (r9934): flooding towns could not remove tram tracks (boekabart).
rubidium <rubidium@openttd.org>
parents:
6732
diff
changeset
|
105 * tracks as that would result in trams that cannot turn. */ |
f1e45e71da47
(svn r9986) -Fix (r9934): flooding towns could not remove tram tracks (boekabart).
rubidium <rubidium@openttd.org>
parents:
6732
diff
changeset
|
106 if (_current_player == OWNER_WATER || |
f1e45e71da47
(svn r9986) -Fix (r9934): flooding towns could not remove tram tracks (boekabart).
rubidium <rubidium@openttd.org>
parents:
6732
diff
changeset
|
107 (rt == ROADTYPE_ROAD && !IsValidPlayer(_current_player))) return 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
|
108 |
6393
ffd35446c110
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas <belugas@openttd.org>
parents:
6368
diff
changeset
|
109 /* Only do the special processing if the road is owned |
ffd35446c110
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas <belugas@openttd.org>
parents:
6368
diff
changeset
|
110 * by a town */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
111 if (owner != OWNER_TOWN) return (owner == OWNER_NONE) || CheckOwnership(owner); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
112 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
113 if (_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
|
114 |
6393
ffd35446c110
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas <belugas@openttd.org>
parents:
6368
diff
changeset
|
115 /* Get a bitmask of which neighbouring roads has a tile */ |
8734
c370e9d5f5c4
(svn r12419) -Cleanup: of the internal road-piece building and removing.
skidd13 <skidd13@openttd.org>
parents:
8732
diff
changeset
|
116 RoadBits n = ROAD_NONE; |
c370e9d5f5c4
(svn r12419) -Cleanup: of the internal road-piece building and removing.
skidd13 <skidd13@openttd.org>
parents:
8732
diff
changeset
|
117 RoadBits present = GetAnyRoadBits(tile, rt); |
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:
6626
diff
changeset
|
118 if (present & ROAD_NE && GetAnyRoadBits(TILE_ADDXY(tile, -1, 0), rt) & ROAD_SW) n |= ROAD_NE; |
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:
6626
diff
changeset
|
119 if (present & ROAD_SE && GetAnyRoadBits(TILE_ADDXY(tile, 0, 1), rt) & ROAD_NW) n |= ROAD_SE; |
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:
6626
diff
changeset
|
120 if (present & ROAD_SW && GetAnyRoadBits(TILE_ADDXY(tile, 1, 0), rt) & ROAD_NE) n |= ROAD_SW; |
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:
6626
diff
changeset
|
121 if (present & ROAD_NW && GetAnyRoadBits(TILE_ADDXY(tile, 0, -1), rt) & ROAD_SE) n |= ROAD_NW; |
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 |
6393
ffd35446c110
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas <belugas@openttd.org>
parents:
6368
diff
changeset
|
123 /* If 0 or 1 bits are set in n, or if no bits that match the bits to remove, |
ffd35446c110
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas <belugas@openttd.org>
parents:
6368
diff
changeset
|
124 * then allow it */ |
8734
c370e9d5f5c4
(svn r12419) -Cleanup: of the internal road-piece building and removing.
skidd13 <skidd13@openttd.org>
parents:
8732
diff
changeset
|
125 if (KillFirstBit(n) != ROAD_NONE && (n & remove) != ROAD_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
|
126 *edge_road = false; |
6393
ffd35446c110
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas <belugas@openttd.org>
parents:
6368
diff
changeset
|
127 /* you can remove all kind of roads with extra dynamite */ |
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 if (_patches.extra_dynamite) 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
|
129 |
8734
c370e9d5f5c4
(svn r12419) -Cleanup: of the internal road-piece building and removing.
skidd13 <skidd13@openttd.org>
parents:
8732
diff
changeset
|
130 const Town *t = ClosestTownFromTile(tile, (uint)-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
|
131 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
132 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
|
133 _error_message = 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
|
134 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
|
135 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
136 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
137 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
|
138 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
139 |
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:
6626
diff
changeset
|
140 static bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, bool *edge_road, RoadType rt) |
6116
05018fddac7b
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium <rubidium@openttd.org>
parents:
5991
diff
changeset
|
141 { |
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:
6626
diff
changeset
|
142 return CheckAllowRemoveRoad(tile, remove, GetRoadOwner(tile, rt), edge_road, rt); |
6116
05018fddac7b
(svn r8852) -Fix (r8735): make the dynamite tool for drive through road stops as if it were removing a normal road tile (consider the local authority and such).
rubidium <rubidium@openttd.org>
parents:
5991
diff
changeset
|
143 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
144 |
8428
f92ccc2f6f17
(svn r11998) -Fix [FS#1692](r10053): possible remote assert by setting bit 6 of p1 for CMD_REMOVE_ROAD
smatz <smatz@openttd.org>
parents:
8413
diff
changeset
|
145 |
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 /** Delete a piece of road. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
147 * @param tile tile where to remove road from |
6483
f7bd49098924
(svn r9664) -Documentation: Doxygen corrections,errors and omissions
belugas <belugas@openttd.org>
parents:
6427
diff
changeset
|
148 * @param flags operation to perform |
8428
f92ccc2f6f17
(svn r11998) -Fix [FS#1692](r10053): possible remote assert by setting bit 6 of p1 for CMD_REMOVE_ROAD
smatz <smatz@openttd.org>
parents:
8413
diff
changeset
|
149 * @param pieces roadbits to remove |
f92ccc2f6f17
(svn r11998) -Fix [FS#1692](r10053): possible remote assert by setting bit 6 of p1 for CMD_REMOVE_ROAD
smatz <smatz@openttd.org>
parents:
8413
diff
changeset
|
150 * @param rt roadtype to remove |
f92ccc2f6f17
(svn r11998) -Fix [FS#1692](r10053): possible remote assert by setting bit 6 of p1 for CMD_REMOVE_ROAD
smatz <smatz@openttd.org>
parents:
8413
diff
changeset
|
151 * @param crossing_check should we check if there is a tram track when we are removing road from crossing? |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
152 */ |
8428
f92ccc2f6f17
(svn r11998) -Fix [FS#1692](r10053): possible remote assert by setting bit 6 of p1 for CMD_REMOVE_ROAD
smatz <smatz@openttd.org>
parents:
8413
diff
changeset
|
153 static CommandCost RemoveRoad(TileIndex tile, uint32 flags, RoadBits pieces, RoadType rt, bool crossing_check) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
154 { |
6393
ffd35446c110
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas <belugas@openttd.org>
parents:
6368
diff
changeset
|
155 /* cost for removing inner/edge -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
|
156 static const uint16 road_remove_cost[2] = {50, 18}; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
157 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
158 /* true if the roadpiece was always removeable, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
159 * false if it was a center piece. Affects town ratings drop */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
160 bool edge_road; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
161 |
7223
0b4daf6f0c5f
(svn r10502) -Fix [FS#1017]: trying to get the town from a tile that can never be associated with a town.
rubidium <rubidium@openttd.org>
parents:
6968
diff
changeset
|
162 Town *t = NULL; |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
163 switch (GetTileType(tile)) { |
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:
7355
diff
changeset
|
164 case MP_ROAD: |
7223
0b4daf6f0c5f
(svn r10502) -Fix [FS#1017]: trying to get the town from a tile that can never be associated with a town.
rubidium <rubidium@openttd.org>
parents:
6968
diff
changeset
|
165 if (_game_mode != GM_EDITOR && GetRoadOwner(tile, rt) == OWNER_TOWN) t = GetTownByTile(tile); |
8075
8de1216a9e47
(svn r11636) -Fix: it was possible to build/remove road/tram in tunnel/bridge when there was vehicle in it
smatz <smatz@openttd.org>
parents:
8043
diff
changeset
|
166 if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
167 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
|
168 |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
169 case MP_STATION: |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
170 if (!IsDriveThroughStopTile(tile)) return CMD_ERROR; |
8075
8de1216a9e47
(svn r11636) -Fix: it was possible to build/remove road/tram in tunnel/bridge when there was vehicle in it
smatz <smatz@openttd.org>
parents:
8043
diff
changeset
|
171 if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
172 break; |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
173 |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
174 case MP_TUNNELBRIDGE: |
8390
381a22f19287
(svn r11960) -Cleanup: simplify some IsTunnel(Tile) / IsBridge(Tile) conditions
smatz <smatz@openttd.org>
parents:
8384
diff
changeset
|
175 if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR; |
381a22f19287
(svn r11960) -Cleanup: simplify some IsTunnel(Tile) / IsBridge(Tile) conditions
smatz <smatz@openttd.org>
parents:
8384
diff
changeset
|
176 if (GetVehicleTunnelBridge(tile, GetOtherTunnelBridgeEnd(tile)) != NULL) return CMD_ERROR; |
381a22f19287
(svn r11960) -Cleanup: simplify some IsTunnel(Tile) / IsBridge(Tile) conditions
smatz <smatz@openttd.org>
parents:
8384
diff
changeset
|
177 break; |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
178 |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
179 default: |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
180 return CMD_ERROR; |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
181 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
182 |
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:
6626
diff
changeset
|
183 RoadTypes rts = GetRoadTypes(tile); |
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:
6626
diff
changeset
|
184 /* The tile doesn't have the given road type */ |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7857
diff
changeset
|
185 if (!HasBit(rts, rt)) return CMD_ERROR; |
6134 | 186 |
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:
6626
diff
changeset
|
187 if (!CheckAllowRemoveRoad(tile, pieces, &edge_road, rt)) 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
|
188 |
6393
ffd35446c110
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas <belugas@openttd.org>
parents:
6368
diff
changeset
|
189 /* check if you're allowed to remove the street owned by a town |
ffd35446c110
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas <belugas@openttd.org>
parents:
6368
diff
changeset
|
190 * removal allowance depends on difficulty setting */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
191 if (!CheckforTownRating(flags, t, ROAD_REMOVE)) 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
|
192 |
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:
7355
diff
changeset
|
193 if (!IsTileType(tile, MP_ROAD)) { |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
194 /* If it's the last roadtype, just clear the whole tile */ |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
195 if (rts == RoadTypeToRoadTypes(rt)) return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
196 |
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); |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
198 if (IsTileType(tile, MP_TUNNELBRIDGE)) { |
8197
bdb186c8fe93
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz <smatz@openttd.org>
parents:
8187
diff
changeset
|
199 TileIndex other_end = GetOtherTunnelBridgeEnd(tile); |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
200 /* Pay for *every* tile of the bridge or tunnel */ |
8398
a6304b304752
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz <smatz@openttd.org>
parents:
8390
diff
changeset
|
201 cost.AddCost((GetTunnelBridgeLength(other_end, tile) + 2) * _price.remove_road); |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
202 if (flags & DC_EXEC) { |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
203 SetRoadTypes(other_end, GetRoadTypes(other_end) & ~RoadTypeToRoadTypes(rt)); |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
204 SetRoadTypes(tile, GetRoadTypes(tile) & ~RoadTypeToRoadTypes(rt)); |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
205 |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
206 /* Mark tiles diry that have been repaved */ |
6714
ed8181c3da57
(svn r9946) -Fix: more places that weren't correctly marked dirty...
rubidium <rubidium@openttd.org>
parents:
6713
diff
changeset
|
207 MarkTileDirtyByTile(tile); |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
208 MarkTileDirtyByTile(other_end); |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
209 if (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
|
210 TileIndexDiff delta = TileOffsByDiagDir(GetTunnelBridgeDirection(tile)); |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
211 |
6713
80ec86a82007
(svn r9945) -Fix: bridges were not properly marked dirty when adding/removing roadtypes.
rubidium <rubidium@openttd.org>
parents:
6711
diff
changeset
|
212 for (TileIndex t = tile + delta; t != other_end; t += delta) MarkTileDirtyByTile(t); |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
213 } |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
214 } |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
215 } else { |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6946
diff
changeset
|
216 cost.AddCost(_price.remove_road); |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
217 if (flags & DC_EXEC) { |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
218 SetRoadTypes(tile, GetRoadTypes(tile) & ~RoadTypeToRoadTypes(rt)); |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
219 MarkTileDirtyByTile(tile); |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
220 } |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
221 } |
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
|
222 return cost; |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
223 } |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
224 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
225 switch (GetRoadTileType(tile)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
226 case ROAD_TILE_NORMAL: { |
8744
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
227 const Slope tileh = GetTileSlope(tile, NULL); |
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:
6626
diff
changeset
|
228 RoadBits present = GetRoadBits(tile, rt); |
8744
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
229 const RoadBits other = GetOtherRoadBits(tile, rt); |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
230 const Foundation f = GetRoadFoundation(tileh, present); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
231 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
232 if (HasRoadWorks(tile)) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
233 |
8744
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
234 /* Autocomplete to a straight road |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
235 * @li on steep slopes |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
236 * @li if the bits of the other roadtypes result in another foundation |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
237 * @li if build on slopes is disabled */ |
8747
640aafa5c0a1
(svn r12443) -Add: OpenTTDs version to openttd.cfg, just so we do not need to keep to ask people for their version number because it's likely they give you the wrong answer anyway.
rubidium <rubidium@openttd.org>
parents:
8746
diff
changeset
|
238 if (IsSteepSlope(tileh) || (IsStraightRoad(other) && |
640aafa5c0a1
(svn r12443) -Add: OpenTTDs version to openttd.cfg, just so we do not need to keep to ask people for their version number because it's likely they give you the wrong answer anyway.
rubidium <rubidium@openttd.org>
parents:
8746
diff
changeset
|
239 (other & _invalid_tileh_slopes_road[0][tileh & SLOPE_ELEVATED]) != ROAD_NONE) || |
640aafa5c0a1
(svn r12443) -Add: OpenTTDs version to openttd.cfg, just so we do not need to keep to ask people for their version number because it's likely they give you the wrong answer anyway.
rubidium <rubidium@openttd.org>
parents:
8746
diff
changeset
|
240 (tileh != SLOPE_FLAT && !_patches.build_on_slopes)) { |
8734
c370e9d5f5c4
(svn r12419) -Cleanup: of the internal road-piece building and removing.
skidd13 <skidd13@openttd.org>
parents:
8732
diff
changeset
|
241 pieces |= MirrorRoadBits(pieces); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
242 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
243 |
6393
ffd35446c110
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas <belugas@openttd.org>
parents:
6368
diff
changeset
|
244 /* limit the bits to delete to the existing bits. */ |
8734
c370e9d5f5c4
(svn r12419) -Cleanup: of the internal road-piece building and removing.
skidd13 <skidd13@openttd.org>
parents:
8732
diff
changeset
|
245 pieces &= present; |
c370e9d5f5c4
(svn r12419) -Cleanup: of the internal road-piece building and removing.
skidd13 <skidd13@openttd.org>
parents:
8732
diff
changeset
|
246 if (pieces == ROAD_NONE) 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
|
247 |
8744
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
248 /* Now set present what it will be after the remove */ |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
249 present ^= pieces; |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
250 |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
251 /* Check for invalid RoadBit combinations on slopes */ |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
252 if (tileh != SLOPE_FLAT && present != ROAD_NONE && |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
253 (present & _invalid_tileh_slopes_road[0][tileh & SLOPE_ELEVATED]) == present) { |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
254 return CMD_ERROR; |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
255 } |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
256 |
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
|
257 ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
258 if (flags & DC_EXEC) { |
6662
baa28c8cfe84
(svn r9893) -Fix (r9892): various small bugs that only act up when using something different than plain roads.
rubidium <rubidium@openttd.org>
parents:
6661
diff
changeset
|
259 if (present == ROAD_NONE) { |
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:
6626
diff
changeset
|
260 RoadTypes rts = GetRoadTypes(tile) & ComplementRoadTypes(RoadTypeToRoadTypes(rt)); |
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:
6626
diff
changeset
|
261 if (rts == ROADTYPES_NONE) { |
7536
52edfe2a54b8
(svn r11056) -Fix [FS#1213]: road/tram tiles would not always get marked dirty properly, causing glitches for non-local players. Patch by SmatZ.
rubidium <rubidium@openttd.org>
parents:
7516
diff
changeset
|
262 /* Includes MarkTileDirtyByTile() */ |
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:
6626
diff
changeset
|
263 DoClearSquare(tile); |
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:
6626
diff
changeset
|
264 } else { |
6662
baa28c8cfe84
(svn r9893) -Fix (r9892): various small bugs that only act up when using something different than plain roads.
rubidium <rubidium@openttd.org>
parents:
6661
diff
changeset
|
265 SetRoadBits(tile, ROAD_NONE, rt); |
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:
6626
diff
changeset
|
266 SetRoadTypes(tile, rts); |
7536
52edfe2a54b8
(svn r11056) -Fix [FS#1213]: road/tram tiles would not always get marked dirty properly, causing glitches for non-local players. Patch by SmatZ.
rubidium <rubidium@openttd.org>
parents:
7516
diff
changeset
|
267 MarkTileDirtyByTile(tile); |
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:
6626
diff
changeset
|
268 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
269 } else { |
6764
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
270 /* When bits are removed, you *always* end up with something that |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
271 * is not a complete straight road tile. However, trams do not have |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
272 * onewayness, so they cannot remove it either. */ |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
273 if (rt != ROADTYPE_TRAM) SetDisallowedRoadDirections(tile, DRD_NONE); |
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:
6626
diff
changeset
|
274 SetRoadBits(tile, present, rt); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
275 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
|
276 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
277 } |
8744
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
278 |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
279 /* If we change the foundation we have to pay for it. */ |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
280 return CommandCost(EXPENSES_CONSTRUCTION, CountBits(pieces) * _price.remove_road + |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
281 ((GetRoadFoundation(tileh, present) != f) ? _price.terraform : (Money)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
|
282 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
283 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
284 case ROAD_TILE_CROSSING: { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
285 if (pieces & ComplementRoadBits(GetCrossingRoadBits(tile))) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
286 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
|
287 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
288 |
6697
398474f3706e
(svn r9929) -Fix [FS#803]: fix several drawing issues.
rubidium <rubidium@openttd.org>
parents:
6691
diff
changeset
|
289 /* Don't allow road to be removed from the crossing when there is tram; |
398474f3706e
(svn r9929) -Fix [FS#803]: fix several drawing issues.
rubidium <rubidium@openttd.org>
parents:
6691
diff
changeset
|
290 * we can't draw the crossing without trambits ;) */ |
8563
992fa65afba1
(svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents:
8560
diff
changeset
|
291 if (rt == ROADTYPE_ROAD && HasTileRoadType(tile, ROADTYPE_TRAM) && (flags & DC_EXEC || crossing_check)) return CMD_ERROR; |
6697
398474f3706e
(svn r9929) -Fix [FS#803]: fix several drawing issues.
rubidium <rubidium@openttd.org>
parents:
6691
diff
changeset
|
292 |
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
|
293 if (rt == ROADTYPE_ROAD) { |
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
|
294 ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_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
|
295 } |
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
|
296 |
8187
628ae1d0d227
(svn r11750) -Revert (r11749): commited too much
glx <glx@openttd.org>
parents:
8186
diff
changeset
|
297 if (flags & DC_EXEC) { |
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:
6626
diff
changeset
|
298 RoadTypes rts = GetRoadTypes(tile) & ComplementRoadTypes(RoadTypeToRoadTypes(rt)); |
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:
6626
diff
changeset
|
299 if (rts == ROADTYPES_NONE) { |
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:
6626
diff
changeset
|
300 MakeRailNormal(tile, GetTileOwner(tile), GetCrossingRailBits(tile), GetRailType(tile)); |
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:
6626
diff
changeset
|
301 } else { |
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:
6626
diff
changeset
|
302 SetRoadTypes(tile, rts); |
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:
6626
diff
changeset
|
303 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
304 MarkTileDirtyByTile(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
|
305 YapfNotifyTrackLayoutChange(tile, FindFirstTrack(GetTrackBits(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
|
306 } |
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
|
307 return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_road * 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
|
308 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
309 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
310 default: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
311 case ROAD_TILE_DEPOT: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
312 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
|
313 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
314 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
315 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
316 |
8428
f92ccc2f6f17
(svn r11998) -Fix [FS#1692](r10053): possible remote assert by setting bit 6 of p1 for CMD_REMOVE_ROAD
smatz <smatz@openttd.org>
parents:
8413
diff
changeset
|
317 /** Delete a piece of road. |
f92ccc2f6f17
(svn r11998) -Fix [FS#1692](r10053): possible remote assert by setting bit 6 of p1 for CMD_REMOVE_ROAD
smatz <smatz@openttd.org>
parents:
8413
diff
changeset
|
318 * @param tile tile where to remove road from |
f92ccc2f6f17
(svn r11998) -Fix [FS#1692](r10053): possible remote assert by setting bit 6 of p1 for CMD_REMOVE_ROAD
smatz <smatz@openttd.org>
parents:
8413
diff
changeset
|
319 * @param flags operation to perform |
f92ccc2f6f17
(svn r11998) -Fix [FS#1692](r10053): possible remote assert by setting bit 6 of p1 for CMD_REMOVE_ROAD
smatz <smatz@openttd.org>
parents:
8413
diff
changeset
|
320 * @param p1 bit 0..3 road pieces to remove (RoadBits) |
f92ccc2f6f17
(svn r11998) -Fix [FS#1692](r10053): possible remote assert by setting bit 6 of p1 for CMD_REMOVE_ROAD
smatz <smatz@openttd.org>
parents:
8413
diff
changeset
|
321 * bit 4..5 road type |
f92ccc2f6f17
(svn r11998) -Fix [FS#1692](r10053): possible remote assert by setting bit 6 of p1 for CMD_REMOVE_ROAD
smatz <smatz@openttd.org>
parents:
8413
diff
changeset
|
322 * @param p2 unused |
f92ccc2f6f17
(svn r11998) -Fix [FS#1692](r10053): possible remote assert by setting bit 6 of p1 for CMD_REMOVE_ROAD
smatz <smatz@openttd.org>
parents:
8413
diff
changeset
|
323 */ |
f92ccc2f6f17
(svn r11998) -Fix [FS#1692](r10053): possible remote assert by setting bit 6 of p1 for CMD_REMOVE_ROAD
smatz <smatz@openttd.org>
parents:
8413
diff
changeset
|
324 CommandCost CmdRemoveRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
f92ccc2f6f17
(svn r11998) -Fix [FS#1692](r10053): possible remote assert by setting bit 6 of p1 for CMD_REMOVE_ROAD
smatz <smatz@openttd.org>
parents:
8413
diff
changeset
|
325 { |
f92ccc2f6f17
(svn r11998) -Fix [FS#1692](r10053): possible remote assert by setting bit 6 of p1 for CMD_REMOVE_ROAD
smatz <smatz@openttd.org>
parents:
8413
diff
changeset
|
326 RoadType rt = (RoadType)GB(p1, 4, 2); |
f92ccc2f6f17
(svn r11998) -Fix [FS#1692](r10053): possible remote assert by setting bit 6 of p1 for CMD_REMOVE_ROAD
smatz <smatz@openttd.org>
parents:
8413
diff
changeset
|
327 if (!IsValidRoadType(rt)) return CMD_ERROR; |
f92ccc2f6f17
(svn r11998) -Fix [FS#1692](r10053): possible remote assert by setting bit 6 of p1 for CMD_REMOVE_ROAD
smatz <smatz@openttd.org>
parents:
8413
diff
changeset
|
328 |
f92ccc2f6f17
(svn r11998) -Fix [FS#1692](r10053): possible remote assert by setting bit 6 of p1 for CMD_REMOVE_ROAD
smatz <smatz@openttd.org>
parents:
8413
diff
changeset
|
329 RoadBits pieces = Extract<RoadBits, 0>(p1); |
f92ccc2f6f17
(svn r11998) -Fix [FS#1692](r10053): possible remote assert by setting bit 6 of p1 for CMD_REMOVE_ROAD
smatz <smatz@openttd.org>
parents:
8413
diff
changeset
|
330 |
f92ccc2f6f17
(svn r11998) -Fix [FS#1692](r10053): possible remote assert by setting bit 6 of p1 for CMD_REMOVE_ROAD
smatz <smatz@openttd.org>
parents:
8413
diff
changeset
|
331 return RemoveRoad(tile, flags, pieces, rt, true); |
f92ccc2f6f17
(svn r11998) -Fix [FS#1692](r10053): possible remote assert by setting bit 6 of p1 for CMD_REMOVE_ROAD
smatz <smatz@openttd.org>
parents:
8413
diff
changeset
|
332 } |
f92ccc2f6f17
(svn r11998) -Fix [FS#1692](r10053): possible remote assert by setting bit 6 of p1 for CMD_REMOVE_ROAD
smatz <smatz@openttd.org>
parents:
8413
diff
changeset
|
333 |
7641
5e3cd60f89c4
(svn r11172) -Codechange: rewrite of town road building and addition of the possibility to clean up unconnected road bits during the local road reconstructions. Based on a patch by skidd13.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
334 /** |
5e3cd60f89c4
(svn r11172) -Codechange: rewrite of town road building and addition of the possibility to clean up unconnected road bits during the local road reconstructions. Based on a patch by skidd13.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
335 * Calculate the costs for roads on slopes |
5e3cd60f89c4
(svn r11172) -Codechange: rewrite of town road building and addition of the possibility to clean up unconnected road bits during the local road reconstructions. Based on a patch by skidd13.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
336 * Aside modify the RoadBits to fit on the slopes |
5e3cd60f89c4
(svn r11172) -Codechange: rewrite of town road building and addition of the possibility to clean up unconnected road bits during the local road reconstructions. Based on a patch by skidd13.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
337 * |
5e3cd60f89c4
(svn r11172) -Codechange: rewrite of town road building and addition of the possibility to clean up unconnected road bits during the local road reconstructions. Based on a patch by skidd13.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
338 * @note The RoadBits are modified too! |
5e3cd60f89c4
(svn r11172) -Codechange: rewrite of town road building and addition of the possibility to clean up unconnected road bits during the local road reconstructions. Based on a patch by skidd13.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
339 * @param tileh The current slope |
5e3cd60f89c4
(svn r11172) -Codechange: rewrite of town road building and addition of the possibility to clean up unconnected road bits during the local road reconstructions. Based on a patch by skidd13.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
340 * @param pieces The RoadBits we want to add |
8744
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
341 * @param existing The existent RoadBits of the current type |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
342 * @param other The other existent RoadBits |
7641
5e3cd60f89c4
(svn r11172) -Codechange: rewrite of town road building and addition of the possibility to clean up unconnected road bits during the local road reconstructions. Based on a patch by skidd13.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
343 * @return The costs for these RoadBits on this slope |
5e3cd60f89c4
(svn r11172) -Codechange: rewrite of town road building and addition of the possibility to clean up unconnected road bits during the local road reconstructions. Based on a patch by skidd13.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
344 */ |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
345 static CommandCost CheckRoadSlope(Slope tileh, RoadBits *pieces, RoadBits existing, RoadBits other) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
346 { |
8744
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
347 /* Remove already build pieces */ |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
348 CLRBITS(*pieces, existing); |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
349 |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
350 /* If we can't build anything stop here */ |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
351 if (*pieces == ROAD_NONE) return CMD_ERROR; |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
352 |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
353 /* All RoadBit combos are valid on flat land */ |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
354 if (tileh == SLOPE_FLAT) return CommandCost(); |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
355 |
8734
c370e9d5f5c4
(svn r12419) -Cleanup: of the internal road-piece building and removing.
skidd13 <skidd13@openttd.org>
parents:
8732
diff
changeset
|
356 /* Proceed steep Slopes first to reduce lookup table size */ |
7641
5e3cd60f89c4
(svn r11172) -Codechange: rewrite of town road building and addition of the possibility to clean up unconnected road bits during the local road reconstructions. Based on a patch by skidd13.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
357 if (IsSteepSlope(tileh)) { |
5e3cd60f89c4
(svn r11172) -Codechange: rewrite of town road building and addition of the possibility to clean up unconnected road bits during the local road reconstructions. Based on a patch by skidd13.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
358 /* Force straight roads. */ |
5e3cd60f89c4
(svn r11172) -Codechange: rewrite of town road building and addition of the possibility to clean up unconnected road bits during the local road reconstructions. Based on a patch by skidd13.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
359 *pieces |= MirrorRoadBits(*pieces); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
360 |
8744
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
361 /* Use existing as all existing since only straight |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
362 * roads are allowed here. */ |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
363 existing |= other; |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
364 |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
365 if ((existing == ROAD_NONE || existing == *pieces) && IsStraightRoad(*pieces)) { |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
366 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
|
367 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
368 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
|
369 } |
7641
5e3cd60f89c4
(svn r11172) -Codechange: rewrite of town road building and addition of the possibility to clean up unconnected road bits during the local road reconstructions. Based on a patch by skidd13.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
370 |
8744
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
371 /* Save the merge of all bits of the current type */ |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
372 RoadBits type_bits = existing | *pieces; |
7641
5e3cd60f89c4
(svn r11172) -Codechange: rewrite of town road building and addition of the possibility to clean up unconnected road bits during the local road reconstructions. Based on a patch by skidd13.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
373 |
8744
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
374 /* Roads on slopes */ |
8746
4721d04c3b76
(svn r12442) -Feature: Allow build leveled roads on slopes for the old ai
skidd13 <skidd13@openttd.org>
parents:
8744
diff
changeset
|
375 if (_patches.build_on_slopes && (_invalid_tileh_slopes_road[0][tileh] & (other | type_bits)) == ROAD_NONE) { |
8744
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
376 |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
377 /* If we add leveling we've got to pay for it */ |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
378 if ((other | existing) == ROAD_NONE) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
379 |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
380 return CommandCost(); |
7641
5e3cd60f89c4
(svn r11172) -Codechange: rewrite of town road building and addition of the possibility to clean up unconnected road bits during the local road reconstructions. Based on a patch by skidd13.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
381 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
382 |
8744
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
383 /* Autocomplete uphill roads */ |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
384 *pieces |= MirrorRoadBits(*pieces); |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
385 type_bits = existing | *pieces; |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
386 |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
387 /* Uphill roads */ |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
388 if (IsStraightRoad(type_bits) && (other == type_bits || other == ROAD_NONE) && |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
389 (_invalid_tileh_slopes_road[1][tileh] & (other | type_bits)) == ROAD_NONE) { |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
390 |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
391 /* Slopes with foundation ? */ |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
392 if (IsSlopeWithOneCornerRaised(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
|
393 |
8744
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
394 /* Prevent build on slopes if it isn't allowed */ |
8746
4721d04c3b76
(svn r12442) -Feature: Allow build leveled roads on slopes for the old ai
skidd13 <skidd13@openttd.org>
parents:
8744
diff
changeset
|
395 if (_patches.build_on_slopes) { |
8744
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
396 |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
397 /* If we add foundation we've got to pay for it */ |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
398 if ((other | existing) == ROAD_NONE) 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
|
399 |
8744
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
400 return CommandCost(); |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
401 } |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
402 } else { |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
403 if (CountBits(existing) == 1) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
404 return CommandCost(); |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
405 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
406 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
407 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
|
408 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
409 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
410 /** Build a piece of road. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
411 * @param tile tile where to build road |
6483
f7bd49098924
(svn r9664) -Documentation: Doxygen corrections,errors and omissions
belugas <belugas@openttd.org>
parents:
6427
diff
changeset
|
412 * @param flags operation to perform |
6134 | 413 * @param p1 bit 0..3 road pieces to build (RoadBits) |
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:
6626
diff
changeset
|
414 * bit 4..5 road type |
6764
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
415 * bit 6..7 disallowed directions to toggle |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
416 * @param p2 the town that is building the road (0 if not applicable) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
417 */ |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6857
diff
changeset
|
418 CommandCost CmdBuildRoad(TileIndex 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
|
419 { |
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
|
420 CommandCost cost(EXPENSES_CONSTRUCTION); |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
421 |
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
|
422 RoadBits existing = ROAD_NONE; |
8744
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
423 RoadBits other_bits = ROAD_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
|
424 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
425 /* Road pieces are max 4 bitset values (NE, NW, SE, SW) and town can only be non-zero |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
426 * if a non-player is building the road */ |
6134 | 427 if ((IsValidPlayer(_current_player) && p2 != 0) || (_current_player == OWNER_TOWN && !IsValidTownID(p2))) return CMD_ERROR; |
428 | |
429 RoadBits pieces = Extract<RoadBits, 0>(p1); | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
430 |
8690
efeb7acc4651
(svn r12363) -Fix: do not allow building 'zero' road bits
smatz <smatz@openttd.org>
parents:
8647
diff
changeset
|
431 /* do not allow building 'zero' road bits, code wouldn't handle it */ |
efeb7acc4651
(svn r12363) -Fix: do not allow building 'zero' road bits
smatz <smatz@openttd.org>
parents:
8647
diff
changeset
|
432 if (pieces == ROAD_NONE) return CMD_ERROR; |
efeb7acc4651
(svn r12363) -Fix: do not allow building 'zero' road bits
smatz <smatz@openttd.org>
parents:
8647
diff
changeset
|
433 |
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:
6626
diff
changeset
|
434 RoadType rt = (RoadType)GB(p1, 4, 2); |
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
|
435 if (!IsValidRoadType(rt) || !ValParamRoadType(rt)) 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:
6626
diff
changeset
|
436 |
6764
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
437 DisallowedRoadDirections toggle_drd = (DisallowedRoadDirections)GB(p1, 6, 2); |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
438 |
8734
c370e9d5f5c4
(svn r12419) -Cleanup: of the internal road-piece building and removing.
skidd13 <skidd13@openttd.org>
parents:
8732
diff
changeset
|
439 Slope tileh = GetTileSlope(tile, NULL); |
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 switch (GetTileType(tile)) { |
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:
7355
diff
changeset
|
442 case MP_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
|
443 switch (GetRoadTileType(tile)) { |
6764
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
444 case ROAD_TILE_NORMAL: { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
445 if (HasRoadWorks(tile)) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS); |
6756
df99458f5c49
(svn r9991) -Fix: one could build road when trams were driving on the tile and vice versa.
rubidium <rubidium@openttd.org>
parents:
6751
diff
changeset
|
446 |
8744
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
447 other_bits = GetOtherRoadBits(tile, rt); |
8563
992fa65afba1
(svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents:
8560
diff
changeset
|
448 if (!HasTileRoadType(tile, rt)) 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
|
449 |
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:
6626
diff
changeset
|
450 existing = GetRoadBits(tile, rt); |
8734
c370e9d5f5c4
(svn r12419) -Cleanup: of the internal road-piece building and removing.
skidd13 <skidd13@openttd.org>
parents:
8732
diff
changeset
|
451 bool crossing = !IsStraightRoad(existing | pieces); |
6768
639a3c6b34ed
(svn r10004) -Fix: trams can always intersect/have junctions on one way roads (because they only work for busses and lorries).
rubidium <rubidium@openttd.org>
parents:
6764
diff
changeset
|
452 if (rt != ROADTYPE_TRAM && (GetDisallowedRoadDirections(tile) != DRD_NONE || toggle_drd != DRD_NONE) && crossing) { |
6764
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
453 /* Junctions cannot be one-way */ |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
454 return_cmd_error(STR_ERR_ONEWAY_ROADS_CAN_T_HAVE_JUNCTION); |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
455 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
456 if ((existing & pieces) == pieces) { |
6764
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
457 /* We only want to set the (dis)allowed road directions */ |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
458 if (toggle_drd != DRD_NONE && rt != ROADTYPE_TRAM && GetRoadOwner(tile, ROADTYPE_ROAD) == _current_player) { |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
459 if (crossing) return_cmd_error(STR_ERR_ONEWAY_ROADS_CAN_T_HAVE_JUNCTION); |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
460 |
8601
94ed88937d4d
(svn r12183) -Codechange: give a better error message when building road over existing road with vehicle on it, or do not fail at all
smatz <smatz@openttd.org>
parents:
8598
diff
changeset
|
461 if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; |
94ed88937d4d
(svn r12183) -Codechange: give a better error message when building road over existing road with vehicle on it, or do not fail at all
smatz <smatz@openttd.org>
parents:
8598
diff
changeset
|
462 |
6764
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
463 /* Ignore half built tiles */ |
8734
c370e9d5f5c4
(svn r12419) -Cleanup: of the internal road-piece building and removing.
skidd13 <skidd13@openttd.org>
parents:
8732
diff
changeset
|
464 if (flags & DC_EXEC && rt != ROADTYPE_TRAM && IsStraightRoad(existing)) { |
6764
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
465 SetDisallowedRoadDirections(tile, GetDisallowedRoadDirections(tile) ^ toggle_drd); |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
466 MarkTileDirtyByTile(tile); |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
467 } |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6946
diff
changeset
|
468 return CommandCost(); |
6764
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
469 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
470 return_cmd_error(STR_1007_ALREADY_BUILT); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
471 } |
6764
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
472 } 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
|
473 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
474 case ROAD_TILE_CROSSING: |
8563
992fa65afba1
(svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents:
8560
diff
changeset
|
475 if (HasTileRoadType(tile, rt)) return_cmd_error(STR_1007_ALREADY_BUILT); |
8744
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
476 other_bits = GetCrossingRoadBits(tile); |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
477 if (pieces & ComplementRoadBits(other_bits)) goto do_clear; |
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:
6626
diff
changeset
|
478 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
|
479 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
480 default: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
481 case ROAD_TILE_DEPOT: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
482 goto do_clear; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
483 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
484 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
485 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
486 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
|
487 if (IsSteepSlope(tileh)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
488 return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
489 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
490 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
491 /* Level crossings may only be built on these slopes */ |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7857
diff
changeset
|
492 if (!HasBit(VALID_LEVEL_CROSSING_SLOPES, 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
|
493 return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
494 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
495 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
496 if (GetRailTileType(tile) != RAIL_TILE_NORMAL) goto do_clear; |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
497 |
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
498 Axis roaddir; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
499 switch (GetTrackBits(tile)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
500 case TRACK_BIT_X: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
501 if (pieces & ROAD_X) goto do_clear; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
502 roaddir = AXIS_Y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
503 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
504 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
505 case TRACK_BIT_Y: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
506 if (pieces & ROAD_Y) goto do_clear; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
507 roaddir = 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
|
508 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 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
510 default: goto do_clear; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
511 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
512 |
6406
ecbbe4b0a9a2
(svn r9542) -Fix(FS# 712): When checking if a vehicle is on a given tile, and you are working on the ground tile, do not take aircrafts into account, as they do not pose any danger for the construction/destruction/conversion itself. Z stuff, in other words
belugas <belugas@openttd.org>
parents:
6393
diff
changeset
|
513 if (!EnsureNoVehicleOnGround(tile)) 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
|
514 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
515 if (flags & DC_EXEC) { |
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
|
516 YapfNotifyTrackLayoutChange(tile, FindFirstTrack(GetTrackBits(tile))); |
6697
398474f3706e
(svn r9929) -Fix [FS#803]: fix several drawing issues.
rubidium <rubidium@openttd.org>
parents:
6691
diff
changeset
|
517 /* Always add road to the roadtypes (can't draw without it) */ |
398474f3706e
(svn r9929) -Fix [FS#803]: fix several drawing issues.
rubidium <rubidium@openttd.org>
parents:
6691
diff
changeset
|
518 MakeRoadCrossing(tile, _current_player, _current_player, _current_player, GetTileOwner(tile), roaddir, GetRailType(tile), RoadTypeToRoadTypes(rt) | ROADTYPES_ROAD, p2); |
8344
6312fafcfe47
(svn r11910) -Fix: play 'ding-ding' crossing sound in more cases (except gameload and crossing construction)
smatz <smatz@openttd.org>
parents:
8342
diff
changeset
|
519 UpdateLevelCrossing(tile, false); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
520 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
|
521 } |
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
|
522 return CommandCost(EXPENSES_CONSTRUCTION, _price.build_road * (rt == ROADTYPE_ROAD ? 2 : 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
|
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 |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
525 case MP_STATION: |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
526 if (!IsDriveThroughStopTile(tile)) return CMD_ERROR; |
8563
992fa65afba1
(svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents:
8560
diff
changeset
|
527 if (HasTileRoadType(tile, rt)) return_cmd_error(STR_1007_ALREADY_BUILT); |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
528 break; |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
529 |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
530 case MP_TUNNELBRIDGE: |
8390
381a22f19287
(svn r11960) -Cleanup: simplify some IsTunnel(Tile) / IsBridge(Tile) conditions
smatz <smatz@openttd.org>
parents:
8384
diff
changeset
|
531 if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR; |
8563
992fa65afba1
(svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents:
8560
diff
changeset
|
532 if (HasTileRoadType(tile, rt)) return_cmd_error(STR_1007_ALREADY_BUILT); |
8390
381a22f19287
(svn r11960) -Cleanup: simplify some IsTunnel(Tile) / IsBridge(Tile) conditions
smatz <smatz@openttd.org>
parents:
8384
diff
changeset
|
533 /* Don't allow adding roadtype to the bridge/tunnel when vehicles are already driving on it */ |
381a22f19287
(svn r11960) -Cleanup: simplify some IsTunnel(Tile) / IsBridge(Tile) conditions
smatz <smatz@openttd.org>
parents:
8384
diff
changeset
|
534 if (GetVehicleTunnelBridge(tile, GetOtherTunnelBridgeEnd(tile)) != NULL) return CMD_ERROR; |
381a22f19287
(svn r11960) -Cleanup: simplify some IsTunnel(Tile) / IsBridge(Tile) conditions
smatz <smatz@openttd.org>
parents:
8384
diff
changeset
|
535 break; |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
536 |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
537 default: { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
538 do_clear:; |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
539 CommandCost ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
540 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:
6946
diff
changeset
|
541 cost.AddCost(ret); |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
542 } 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
|
543 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
544 |
8744
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
545 if (other_bits != pieces) { |
6715
daaf943a1281
(svn r9947) -Fix [FS#807]: don't check whether roadbits may be built when they are already built for another type.
rubidium <rubidium@openttd.org>
parents:
6714
diff
changeset
|
546 /* Check the foundation/slopes when adding road/tram bits */ |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
547 CommandCost ret = CheckRoadSlope(tileh, &pieces, existing, other_bits); |
6715
daaf943a1281
(svn r9947) -Fix [FS#807]: don't check whether roadbits may be built when they are already built for another type.
rubidium <rubidium@openttd.org>
parents:
6714
diff
changeset
|
548 /* Return an error if we need to build a foundation (ret != 0) but the |
daaf943a1281
(svn r9947) -Fix [FS#807]: don't check whether roadbits may be built when they are already built for another type.
rubidium <rubidium@openttd.org>
parents:
6714
diff
changeset
|
549 * current patch-setting is turned off (or stupid AI@work) */ |
8746
4721d04c3b76
(svn r12442) -Feature: Allow build leveled roads on slopes for the old ai
skidd13 <skidd13@openttd.org>
parents:
8744
diff
changeset
|
550 if (CmdFailed(ret) || (ret.GetCost() != 0 && !_patches.build_on_slopes)) { |
6715
daaf943a1281
(svn r9947) -Fix [FS#807]: don't check whether roadbits may be built when they are already built for another type.
rubidium <rubidium@openttd.org>
parents:
6714
diff
changeset
|
551 return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
daaf943a1281
(svn r9947) -Fix [FS#807]: don't check whether roadbits may be built when they are already built for another type.
rubidium <rubidium@openttd.org>
parents:
6714
diff
changeset
|
552 } |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6946
diff
changeset
|
553 cost.AddCost(ret); |
6715
daaf943a1281
(svn r9947) -Fix [FS#807]: don't check whether roadbits may be built when they are already built for another type.
rubidium <rubidium@openttd.org>
parents:
6714
diff
changeset
|
554 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
555 |
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:
7355
diff
changeset
|
556 if (IsTileType(tile, MP_ROAD)) { |
6393
ffd35446c110
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas <belugas@openttd.org>
parents:
6368
diff
changeset
|
557 /* Don't put the pieces that already exist */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
558 pieces &= ComplementRoadBits(existing); |
8384
30198447a5e7
(svn r11953) -Fix (r11172): do not allow modifying roadbits when other roadtypes would need different foundation
smatz <smatz@openttd.org>
parents:
8344
diff
changeset
|
559 |
30198447a5e7
(svn r11953) -Fix (r11172): do not allow modifying roadbits when other roadtypes would need different foundation
smatz <smatz@openttd.org>
parents:
8344
diff
changeset
|
560 /* Check if new road bits will have the same foundation as other existing road types */ |
8563
992fa65afba1
(svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents:
8560
diff
changeset
|
561 if (IsNormalRoad(tile)) { |
8384
30198447a5e7
(svn r11953) -Fix (r11172): do not allow modifying roadbits when other roadtypes would need different foundation
smatz <smatz@openttd.org>
parents:
8344
diff
changeset
|
562 Slope slope = GetTileSlope(tile, NULL); |
30198447a5e7
(svn r11953) -Fix (r11172): do not allow modifying roadbits when other roadtypes would need different foundation
smatz <smatz@openttd.org>
parents:
8344
diff
changeset
|
563 Foundation found_new = GetRoadFoundation(slope, pieces | existing); |
30198447a5e7
(svn r11953) -Fix (r11172): do not allow modifying roadbits when other roadtypes would need different foundation
smatz <smatz@openttd.org>
parents:
8344
diff
changeset
|
564 |
30198447a5e7
(svn r11953) -Fix (r11172): do not allow modifying roadbits when other roadtypes would need different foundation
smatz <smatz@openttd.org>
parents:
8344
diff
changeset
|
565 /* Test if all other roadtypes can be built at that foundation */ |
30198447a5e7
(svn r11953) -Fix (r11172): do not allow modifying roadbits when other roadtypes would need different foundation
smatz <smatz@openttd.org>
parents:
8344
diff
changeset
|
566 for (RoadType rtest = ROADTYPE_ROAD; rtest < ROADTYPE_END; rtest++) { |
30198447a5e7
(svn r11953) -Fix (r11172): do not allow modifying roadbits when other roadtypes would need different foundation
smatz <smatz@openttd.org>
parents:
8344
diff
changeset
|
567 if (rtest != rt) { // check only other road types |
30198447a5e7
(svn r11953) -Fix (r11172): do not allow modifying roadbits when other roadtypes would need different foundation
smatz <smatz@openttd.org>
parents:
8344
diff
changeset
|
568 RoadBits bits = GetRoadBits(tile, rtest); |
30198447a5e7
(svn r11953) -Fix (r11172): do not allow modifying roadbits when other roadtypes would need different foundation
smatz <smatz@openttd.org>
parents:
8344
diff
changeset
|
569 /* do not check if there are not road bits of given type */ |
30198447a5e7
(svn r11953) -Fix (r11172): do not allow modifying roadbits when other roadtypes would need different foundation
smatz <smatz@openttd.org>
parents:
8344
diff
changeset
|
570 if (bits != ROAD_NONE && GetRoadFoundation(slope, bits) != found_new) { |
30198447a5e7
(svn r11953) -Fix (r11172): do not allow modifying roadbits when other roadtypes would need different foundation
smatz <smatz@openttd.org>
parents:
8344
diff
changeset
|
571 return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
30198447a5e7
(svn r11953) -Fix (r11172): do not allow modifying roadbits when other roadtypes would need different foundation
smatz <smatz@openttd.org>
parents:
8344
diff
changeset
|
572 } |
30198447a5e7
(svn r11953) -Fix (r11172): do not allow modifying roadbits when other roadtypes would need different foundation
smatz <smatz@openttd.org>
parents:
8344
diff
changeset
|
573 } |
30198447a5e7
(svn r11953) -Fix (r11172): do not allow modifying roadbits when other roadtypes would need different foundation
smatz <smatz@openttd.org>
parents:
8344
diff
changeset
|
574 } |
30198447a5e7
(svn r11953) -Fix (r11172): do not allow modifying roadbits when other roadtypes would need different foundation
smatz <smatz@openttd.org>
parents:
8344
diff
changeset
|
575 } |
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 |
8601
94ed88937d4d
(svn r12183) -Codechange: give a better error message when building road over existing road with vehicle on it, or do not fail at all
smatz <smatz@openttd.org>
parents:
8598
diff
changeset
|
578 if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; |
94ed88937d4d
(svn r12183) -Codechange: give a better error message when building road over existing road with vehicle on it, or do not fail at all
smatz <smatz@openttd.org>
parents:
8598
diff
changeset
|
579 |
7832
1f9fb5d427f9
(svn r11382) -Codechange: renamed COUNTBITS to CountBits, as it is no longer a macro (skidd13)
truelight <truelight@openttd.org>
parents:
7819
diff
changeset
|
580 cost.AddCost(CountBits(pieces) * _price.build_road); |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
581 if (IsTileType(tile, MP_TUNNELBRIDGE)) { |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
582 /* Pay for *every* tile of the bridge or tunnel */ |
8398
a6304b304752
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz <smatz@openttd.org>
parents:
8390
diff
changeset
|
583 cost.MultiplyCost(GetTunnelBridgeLength(GetOtherTunnelBridgeEnd(tile), tile) + 2); |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
584 } |
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 if (flags & DC_EXEC) { |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
587 switch (GetTileType(tile)) { |
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:
7355
diff
changeset
|
588 case MP_ROAD: { |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
589 RoadTileType rtt = GetRoadTileType(tile); |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
590 if (existing == ROAD_NONE || rtt == ROAD_TILE_CROSSING) { |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
591 SetRoadTypes(tile, GetRoadTypes(tile) | RoadTypeToRoadTypes(rt)); |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
592 SetRoadOwner(tile, rt, _current_player); |
6968
c41d7b4f4480
(svn r10224) -Fix [FS#891]: the town road belongs to didn't get set properly when a town builds road over tram bits.
rubidium <rubidium@openttd.org>
parents:
6965
diff
changeset
|
593 if (_current_player == OWNER_TOWN && rt == ROADTYPE_ROAD) SetTownIndex(tile, p2); |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
594 } |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
595 if (rtt != ROAD_TILE_CROSSING) SetRoadBits(tile, existing | pieces, rt); |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
596 } break; |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
597 |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
598 case MP_TUNNELBRIDGE: { |
8197
bdb186c8fe93
(svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz <smatz@openttd.org>
parents:
8187
diff
changeset
|
599 TileIndex other_end = GetOtherTunnelBridgeEnd(tile); |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
600 |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
601 SetRoadTypes(other_end, GetRoadTypes(other_end) | RoadTypeToRoadTypes(rt)); |
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:
6626
diff
changeset
|
602 SetRoadTypes(tile, GetRoadTypes(tile) | RoadTypeToRoadTypes(rt)); |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
603 |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
604 /* Mark tiles diry that have been repaved */ |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
605 MarkTileDirtyByTile(other_end); |
6714
ed8181c3da57
(svn r9946) -Fix: more places that weren't correctly marked dirty...
rubidium <rubidium@openttd.org>
parents:
6713
diff
changeset
|
606 MarkTileDirtyByTile(tile); |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
607 if (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
|
608 TileIndexDiff delta = TileOffsByDiagDir(GetTunnelBridgeDirection(tile)); |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
609 |
6713
80ec86a82007
(svn r9945) -Fix: bridges were not properly marked dirty when adding/removing roadtypes.
rubidium <rubidium@openttd.org>
parents:
6711
diff
changeset
|
610 for (TileIndex t = tile + delta; t != other_end; t += delta) MarkTileDirtyByTile(t); |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
611 } |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
612 } break; |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
613 |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
614 case MP_STATION: |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
615 SetRoadTypes(tile, GetRoadTypes(tile) | RoadTypeToRoadTypes(rt)); |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
616 break; |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
617 |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
618 default: |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
619 MakeRoadNormal(tile, pieces, RoadTypeToRoadTypes(rt), p2, _current_player, _current_player, _current_player); |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
620 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
|
621 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
622 |
8563
992fa65afba1
(svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents:
8560
diff
changeset
|
623 if (rt != ROADTYPE_TRAM && IsNormalRoadTile(tile)) { |
6764
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
624 existing |= pieces; |
8734
c370e9d5f5c4
(svn r12419) -Cleanup: of the internal road-piece building and removing.
skidd13 <skidd13@openttd.org>
parents:
8732
diff
changeset
|
625 SetDisallowedRoadDirections(tile, IsStraightRoad(existing) ? |
6764
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
626 GetDisallowedRoadDirections(tile) ^ toggle_drd : DRD_NONE); |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
627 } |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
628 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
629 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
|
630 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
631 return cost; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
632 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
633 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
634 /** Build a long piece of road. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
635 * @param end_tile end tile of drag |
6483
f7bd49098924
(svn r9664) -Documentation: Doxygen corrections,errors and omissions
belugas <belugas@openttd.org>
parents:
6427
diff
changeset
|
636 * @param flags operation to perform |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
637 * @param p1 start tile of drag |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
638 * @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
|
639 * - p2 = (bit 0) - start tile starts in the 2nd half of tile (p2 & 1) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
640 * - p2 = (bit 1) - end tile starts in the 2nd half of tile (p2 & 2) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
641 * - p2 = (bit 2) - direction: 0 = along x-axis, 1 = along y-axis (p2 & 4) |
6662
baa28c8cfe84
(svn r9893) -Fix (r9892): various small bugs that only act up when using something different than plain roads.
rubidium <rubidium@openttd.org>
parents:
6661
diff
changeset
|
642 * - p2 = (bit 3 + 4) - road type |
6764
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
643 * - p2 = (bit 5) - set road 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
|
644 */ |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6857
diff
changeset
|
645 CommandCost CmdBuildLongRoad(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
|
646 { |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
647 CommandCost cost(EXPENSES_CONSTRUCTION); |
6710
967edc35a015
(svn r9942) -Fix [FS#804]: crash when upgrading both ends of a bridge.
rubidium <rubidium@openttd.org>
parents:
6702
diff
changeset
|
648 bool had_bridge = false; |
7428
d3fb06b480d2
(svn r10833) -Fix [FS#1115]: assertion (different cost between test and execution) of overbuilding road tunnels with tram tracks (and vice versa) when the dragged area contains both ends of the tunnel.
rubidium <rubidium@openttd.org>
parents:
7389
diff
changeset
|
649 bool had_tunnel = false; |
6764
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
650 bool had_success = false; |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
651 DisallowedRoadDirections drd = DRD_NORTHBOUND; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
652 |
8601
94ed88937d4d
(svn r12183) -Codechange: give a better error message when building road over existing road with vehicle on it, or do not fail at all
smatz <smatz@openttd.org>
parents:
8598
diff
changeset
|
653 _error_message = INVALID_STRING_ID; |
94ed88937d4d
(svn r12183) -Codechange: give a better error message when building road over existing road with vehicle on it, or do not fail at all
smatz <smatz@openttd.org>
parents:
8598
diff
changeset
|
654 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
655 if (p1 >= MapSize()) 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
|
656 |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
657 TileIndex start_tile = p1; |
6662
baa28c8cfe84
(svn r9893) -Fix (r9892): various small bugs that only act up when using something different than plain roads.
rubidium <rubidium@openttd.org>
parents:
6661
diff
changeset
|
658 RoadType rt = (RoadType)GB(p2, 3, 2); |
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
|
659 if (!IsValidRoadType(rt) || !ValParamRoadType(rt)) 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
|
660 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
661 /* Only drag in X or Y direction dictated by the direction variable */ |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7857
diff
changeset
|
662 if (!HasBit(p2, 2) && TileY(start_tile) != TileY(end_tile)) return CMD_ERROR; // x-axis |
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7857
diff
changeset
|
663 if (HasBit(p2, 2) && TileX(start_tile) != TileX(end_tile)) return CMD_ERROR; // y-axis |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
664 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
665 /* Swap start and ending tile, also the half-tile drag var (bit 0 and 1) */ |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7857
diff
changeset
|
666 if (start_tile > end_tile || (start_tile == end_tile && HasBit(p2, 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
|
667 TileIndex t = start_tile; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
668 start_tile = 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
|
669 end_tile = t; |
7954
38bb7c45688f
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13 <skidd13@openttd.org>
parents:
7928
diff
changeset
|
670 p2 ^= IsInsideMM(p2 & 3, 1, 3) ? 3 : 0; |
6764
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
671 drd = DRD_SOUTHBOUND; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
672 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
673 |
6764
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
674 /* On the X-axis, we have to swap the initial bits, so they |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
675 * will be interpreted correctly in the GTTS. Futhermore |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
676 * when you just 'click' on one tile to build them. */ |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7857
diff
changeset
|
677 if (HasBit(p2, 2) == (start_tile == end_tile && HasBit(p2, 0) == HasBit(p2, 1))) drd ^= DRD_BOTH; |
6764
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
678 /* No disallowed direction bits have to be toggled */ |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7857
diff
changeset
|
679 if (!HasBit(p2, 5)) drd = DRD_NONE; |
6764
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
680 |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
681 TileIndex tile = start_tile; |
6393
ffd35446c110
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas <belugas@openttd.org>
parents:
6368
diff
changeset
|
682 /* Start tile is the small number. */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
683 for (;;) { |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7857
diff
changeset
|
684 RoadBits bits = HasBit(p2, 2) ? ROAD_Y : ROAD_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
|
685 |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7857
diff
changeset
|
686 if (tile == end_tile && !HasBit(p2, 1)) bits &= ROAD_NW | ROAD_NE; |
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7857
diff
changeset
|
687 if (tile == start_tile && HasBit(p2, 0)) bits &= ROAD_SE | ROAD_SW; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
688 |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
689 CommandCost ret = DoCommand(tile, drd << 6 | rt << 4 | bits, 0, flags, CMD_BUILD_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
|
690 if (CmdFailed(ret)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
691 if (_error_message != STR_1007_ALREADY_BUILT) 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
|
692 } else { |
6764
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
693 had_success = true; |
7428
d3fb06b480d2
(svn r10833) -Fix [FS#1115]: assertion (different cost between test and execution) of overbuilding road tunnels with tram tracks (and vice versa) when the dragged area contains both ends of the tunnel.
rubidium <rubidium@openttd.org>
parents:
7389
diff
changeset
|
694 /* Only pay for the upgrade on one side of the bridges and tunnels */ |
d3fb06b480d2
(svn r10833) -Fix [FS#1115]: assertion (different cost between test and execution) of overbuilding road tunnels with tram tracks (and vice versa) when the dragged area contains both ends of the tunnel.
rubidium <rubidium@openttd.org>
parents:
7389
diff
changeset
|
695 if (IsTileType(tile, MP_TUNNELBRIDGE)) { |
d3fb06b480d2
(svn r10833) -Fix [FS#1115]: assertion (different cost between test and execution) of overbuilding road tunnels with tram tracks (and vice versa) when the dragged area contains both ends of the tunnel.
rubidium <rubidium@openttd.org>
parents:
7389
diff
changeset
|
696 if (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
|
697 if ((!had_bridge || GetTunnelBridgeDirection(tile) == DIAGDIR_SE || GetTunnelBridgeDirection(tile) == DIAGDIR_SW)) { |
7428
d3fb06b480d2
(svn r10833) -Fix [FS#1115]: assertion (different cost between test and execution) of overbuilding road tunnels with tram tracks (and vice versa) when the dragged area contains both ends of the tunnel.
rubidium <rubidium@openttd.org>
parents:
7389
diff
changeset
|
698 cost.AddCost(ret); |
d3fb06b480d2
(svn r10833) -Fix [FS#1115]: assertion (different cost between test and execution) of overbuilding road tunnels with tram tracks (and vice versa) when the dragged area contains both ends of the tunnel.
rubidium <rubidium@openttd.org>
parents:
7389
diff
changeset
|
699 } |
d3fb06b480d2
(svn r10833) -Fix [FS#1115]: assertion (different cost between test and execution) of overbuilding road tunnels with tram tracks (and vice versa) when the dragged area contains both ends of the tunnel.
rubidium <rubidium@openttd.org>
parents:
7389
diff
changeset
|
700 had_bridge = true; |
8390
381a22f19287
(svn r11960) -Cleanup: simplify some IsTunnel(Tile) / IsBridge(Tile) conditions
smatz <smatz@openttd.org>
parents:
8384
diff
changeset
|
701 } else { // 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
|
702 if ((!had_tunnel || GetTunnelBridgeDirection(tile) == DIAGDIR_SE || GetTunnelBridgeDirection(tile) == DIAGDIR_SW)) { |
7428
d3fb06b480d2
(svn r10833) -Fix [FS#1115]: assertion (different cost between test and execution) of overbuilding road tunnels with tram tracks (and vice versa) when the dragged area contains both ends of the tunnel.
rubidium <rubidium@openttd.org>
parents:
7389
diff
changeset
|
703 cost.AddCost(ret); |
d3fb06b480d2
(svn r10833) -Fix [FS#1115]: assertion (different cost between test and execution) of overbuilding road tunnels with tram tracks (and vice versa) when the dragged area contains both ends of the tunnel.
rubidium <rubidium@openttd.org>
parents:
7389
diff
changeset
|
704 } |
d3fb06b480d2
(svn r10833) -Fix [FS#1115]: assertion (different cost between test and execution) of overbuilding road tunnels with tram tracks (and vice versa) when the dragged area contains both ends of the tunnel.
rubidium <rubidium@openttd.org>
parents:
7389
diff
changeset
|
705 had_tunnel = true; |
6710
967edc35a015
(svn r9942) -Fix [FS#804]: crash when upgrading both ends of a bridge.
rubidium <rubidium@openttd.org>
parents:
6702
diff
changeset
|
706 } |
967edc35a015
(svn r9942) -Fix [FS#804]: crash when upgrading both ends of a bridge.
rubidium <rubidium@openttd.org>
parents:
6702
diff
changeset
|
707 } else { |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6946
diff
changeset
|
708 cost.AddCost(ret); |
6710
967edc35a015
(svn r9942) -Fix [FS#804]: crash when upgrading both ends of a bridge.
rubidium <rubidium@openttd.org>
parents:
6702
diff
changeset
|
709 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
710 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
711 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
712 if (tile == end_tile) break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
713 |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7857
diff
changeset
|
714 tile += HasBit(p2, 2) ? TileDiffXY(0, 1) : TileDiffXY(1, 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
|
715 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
716 |
6764
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
717 return !had_success ? CMD_ERROR : cost; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
718 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
719 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
720 /** Remove a long piece of road. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
721 * @param end_tile end tile of drag |
6483
f7bd49098924
(svn r9664) -Documentation: Doxygen corrections,errors and omissions
belugas <belugas@openttd.org>
parents:
6427
diff
changeset
|
722 * @param flags operation to perform |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
723 * @param p1 start tile of drag |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
724 * @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
|
725 * - p2 = (bit 0) - start tile starts in the 2nd half of tile (p2 & 1) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
726 * - p2 = (bit 1) - end tile starts in the 2nd half of tile (p2 & 2) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
727 * - p2 = (bit 2) - direction: 0 = along x-axis, 1 = along y-axis (p2 & 4) |
6662
baa28c8cfe84
(svn r9893) -Fix (r9892): various small bugs that only act up when using something different than plain roads.
rubidium <rubidium@openttd.org>
parents:
6661
diff
changeset
|
728 * - p2 = (bit 3 + 4) - road 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
|
729 */ |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6857
diff
changeset
|
730 CommandCost CmdRemoveLongRoad(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
|
731 { |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
732 CommandCost cost(EXPENSES_CONSTRUCTION); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
733 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
734 if (p1 >= MapSize()) 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
|
735 |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
736 TileIndex start_tile = p1; |
6662
baa28c8cfe84
(svn r9893) -Fix (r9892): various small bugs that only act up when using something different than plain roads.
rubidium <rubidium@openttd.org>
parents:
6661
diff
changeset
|
737 RoadType rt = (RoadType)GB(p2, 3, 2); |
baa28c8cfe84
(svn r9893) -Fix (r9892): various small bugs that only act up when using something different than plain roads.
rubidium <rubidium@openttd.org>
parents:
6661
diff
changeset
|
738 if (!IsValidRoadType(rt)) 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
|
739 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
740 /* Only drag in X or Y direction dictated by the direction variable */ |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7857
diff
changeset
|
741 if (!HasBit(p2, 2) && TileY(start_tile) != TileY(end_tile)) return CMD_ERROR; // x-axis |
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7857
diff
changeset
|
742 if (HasBit(p2, 2) && TileX(start_tile) != TileX(end_tile)) return CMD_ERROR; // y-axis |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
743 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
744 /* Swap start and ending tile, also the half-tile drag var (bit 0 and 1) */ |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7857
diff
changeset
|
745 if (start_tile > end_tile || (start_tile == end_tile && HasBit(p2, 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
|
746 TileIndex t = start_tile; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
747 start_tile = 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
|
748 end_tile = t; |
7954
38bb7c45688f
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13 <skidd13@openttd.org>
parents:
7928
diff
changeset
|
749 p2 ^= IsInsideMM(p2 & 3, 1, 3) ? 3 : 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
|
750 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
751 |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
752 Money money = GetAvailableMoneyForCommand(); |
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
753 TileIndex tile = start_tile; |
6393
ffd35446c110
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas <belugas@openttd.org>
parents:
6368
diff
changeset
|
754 /* Start tile is the small number. */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
755 for (;;) { |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7857
diff
changeset
|
756 RoadBits bits = HasBit(p2, 2) ? ROAD_Y : ROAD_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
|
757 |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7857
diff
changeset
|
758 if (tile == end_tile && !HasBit(p2, 1)) bits &= ROAD_NW | ROAD_NE; |
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7857
diff
changeset
|
759 if (tile == start_tile && HasBit(p2, 0)) bits &= ROAD_SE | ROAD_SW; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
760 |
6393
ffd35446c110
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas <belugas@openttd.org>
parents:
6368
diff
changeset
|
761 /* try to remove the halves. */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
762 if (bits != 0) { |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
763 CommandCost ret = RemoveRoad(tile, flags & ~DC_EXEC, bits, rt, true); |
7442
60cf5845f300
(svn r10890) -Fix [FS#1125]: removing road with the road removal tool would also work with a negative bank account, making the bank account even more negative than it was.
rubidium <rubidium@openttd.org>
parents:
7428
diff
changeset
|
764 if (CmdSucceeded(ret)) { |
60cf5845f300
(svn r10890) -Fix [FS#1125]: removing road with the road removal tool would also work with a negative bank account, making the bank account even more negative than it was.
rubidium <rubidium@openttd.org>
parents:
7428
diff
changeset
|
765 if (flags & DC_EXEC) { |
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
|
766 money -= ret.GetCost(); |
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
|
767 if (money < 0) { |
7442
60cf5845f300
(svn r10890) -Fix [FS#1125]: removing road with the road removal tool would also work with a negative bank account, making the bank account even more negative than it was.
rubidium <rubidium@openttd.org>
parents:
7428
diff
changeset
|
768 _additional_cash_required = DoCommand(end_tile, start_tile, p2, flags & ~DC_EXEC, CMD_REMOVE_LONG_ROAD).GetCost(); |
60cf5845f300
(svn r10890) -Fix [FS#1125]: removing road with the road removal tool would also work with a negative bank account, making the bank account even more negative than it was.
rubidium <rubidium@openttd.org>
parents:
7428
diff
changeset
|
769 return cost; |
60cf5845f300
(svn r10890) -Fix [FS#1125]: removing road with the road removal tool would also work with a negative bank account, making the bank account even more negative than it was.
rubidium <rubidium@openttd.org>
parents:
7428
diff
changeset
|
770 } |
8428
f92ccc2f6f17
(svn r11998) -Fix [FS#1692](r10053): possible remote assert by setting bit 6 of p1 for CMD_REMOVE_ROAD
smatz <smatz@openttd.org>
parents:
8413
diff
changeset
|
771 RemoveRoad(tile, flags, bits, rt, true); |
7442
60cf5845f300
(svn r10890) -Fix [FS#1125]: removing road with the road removal tool would also work with a negative bank account, making the bank account even more negative than it was.
rubidium <rubidium@openttd.org>
parents:
7428
diff
changeset
|
772 } |
60cf5845f300
(svn r10890) -Fix [FS#1125]: removing road with the road removal tool would also work with a negative bank account, making the bank account even more negative than it was.
rubidium <rubidium@openttd.org>
parents:
7428
diff
changeset
|
773 cost.AddCost(ret); |
60cf5845f300
(svn r10890) -Fix [FS#1125]: removing road with the road removal tool would also work with a negative bank account, making the bank account even more negative than it was.
rubidium <rubidium@openttd.org>
parents:
7428
diff
changeset
|
774 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
775 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
776 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
777 if (tile == end_tile) break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
778 |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7857
diff
changeset
|
779 tile += HasBit(p2, 2) ? TileDiffXY(0, 1) : TileDiffXY(1, 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
|
780 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
781 |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6946
diff
changeset
|
782 return (cost.GetCost() == 0) ? CMD_ERROR : cost; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
783 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
784 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
785 /** Build a road depot. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
786 * @param tile tile where to build the depot |
6483
f7bd49098924
(svn r9664) -Documentation: Doxygen corrections,errors and omissions
belugas <belugas@openttd.org>
parents:
6427
diff
changeset
|
787 * @param flags operation to perform |
6134 | 788 * @param p1 bit 0..1 entrance direction (DiagDirection) |
6662
baa28c8cfe84
(svn r9893) -Fix (r9892): various small bugs that only act up when using something different than plain roads.
rubidium <rubidium@openttd.org>
parents:
6661
diff
changeset
|
789 * bit 2..3 road 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
|
790 * @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
|
791 * |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
792 * @todo When checking for the tile slope, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
793 * distingush between "Flat land required" and "land sloped in wrong direction" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
794 */ |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6857
diff
changeset
|
795 CommandCost CmdBuildRoadDepot(TileIndex 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
|
796 { |
6134 | 797 DiagDirection dir = Extract<DiagDirection, 0>(p1); |
6662
baa28c8cfe84
(svn r9893) -Fix (r9892): various small bugs that only act up when using something different than plain roads.
rubidium <rubidium@openttd.org>
parents:
6661
diff
changeset
|
798 RoadType rt = (RoadType)GB(p1, 2, 2); |
baa28c8cfe84
(svn r9893) -Fix (r9892): various small bugs that only act up when using something different than plain roads.
rubidium <rubidium@openttd.org>
parents:
6661
diff
changeset
|
799 |
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
|
800 if (!IsValidRoadType(rt) || !ValParamRoadType(rt)) 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
|
801 |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
802 Slope tileh = GetTileSlope(tile, NULL); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
803 if (tileh != SLOPE_FLAT && ( |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
804 !_patches.build_on_slopes || |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
805 IsSteepSlope(tileh) || |
6134 | 806 !CanBuildDepotByTileh(dir, 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
|
807 )) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
808 return_cmd_error(STR_0007_FLAT_LAND_REQUIRED); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
809 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
810 |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
811 CommandCost cost = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
812 if (CmdFailed(cost)) 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
|
813 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
814 if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) 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
|
815 |
7389
63f05f10a3c1
(svn r10758) -Codechange: make the depot struct use the pool item class as super class.
rubidium <rubidium@openttd.org>
parents:
7370
diff
changeset
|
816 Depot *dep = new Depot(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 if (dep == NULL) return CMD_ERROR; |
7389
63f05f10a3c1
(svn r10758) -Codechange: make the depot struct use the pool item class as super class.
rubidium <rubidium@openttd.org>
parents:
7370
diff
changeset
|
818 AutoPtrT<Depot> d_auto_delete = dep; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
819 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
820 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
|
821 dep->town_index = ClosestTownFromTile(tile, (uint)-1)->index; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
822 |
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:
6626
diff
changeset
|
823 MakeRoadDepot(tile, _current_player, dir, rt); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
824 MarkTileDirtyByTile(tile); |
7389
63f05f10a3c1
(svn r10758) -Codechange: make the depot struct use the pool item class as super class.
rubidium <rubidium@openttd.org>
parents:
7370
diff
changeset
|
825 d_auto_delete.Detach(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
826 } |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6946
diff
changeset
|
827 return cost.AddCost(_price.build_road_depot); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
828 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
829 |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6857
diff
changeset
|
830 static CommandCost RemoveRoadDepot(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
|
831 { |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
832 if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) 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
|
833 |
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:
7730
diff
changeset
|
834 if (!EnsureNoVehicleOnGround(tile)) 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
|
835 |
7389
63f05f10a3c1
(svn r10758) -Codechange: make the depot struct use the pool item class as super class.
rubidium <rubidium@openttd.org>
parents:
7370
diff
changeset
|
836 if (flags & DC_EXEC) { |
63f05f10a3c1
(svn r10758) -Codechange: make the depot struct use the pool item class as super class.
rubidium <rubidium@openttd.org>
parents:
7370
diff
changeset
|
837 DoClearSquare(tile); |
63f05f10a3c1
(svn r10758) -Codechange: make the depot struct use the pool item class as super class.
rubidium <rubidium@openttd.org>
parents:
7370
diff
changeset
|
838 delete GetDepotByTile(tile); |
63f05f10a3c1
(svn r10758) -Codechange: make the depot struct use the pool item class as super class.
rubidium <rubidium@openttd.org>
parents:
7370
diff
changeset
|
839 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
840 |
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
|
841 return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_road_depot); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
842 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
843 |
6943
fd42cb9816c6
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium <rubidium@openttd.org>
parents:
6857
diff
changeset
|
844 static CommandCost ClearTile_Road(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
|
845 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
846 switch (GetRoadTileType(tile)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
847 case ROAD_TILE_NORMAL: { |
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:
6626
diff
changeset
|
848 RoadBits b = GetAllRoadBits(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
|
849 |
5637
2ea5b88a8a32
(svn r8096) -Codechange: Invert the check if you are allowed to clear a road tile so there are not so many negations (too confusing) and added some comments to further clarify what happens.
Darkvater <Darkvater@openttd.org>
parents:
5587
diff
changeset
|
850 /* Clear the road if only one piece is on the tile OR the AI tries |
2ea5b88a8a32
(svn r8096) -Codechange: Invert the check if you are allowed to clear a road tile so there are not so many negations (too confusing) and added some comments to further clarify what happens.
Darkvater <Darkvater@openttd.org>
parents:
5587
diff
changeset
|
851 * to clear town road OR we are not using the DC_AUTO flag */ |
7832
1f9fb5d427f9
(svn r11382) -Codechange: renamed COUNTBITS to CountBits, as it is no longer a macro (skidd13)
truelight <truelight@openttd.org>
parents:
7819
diff
changeset
|
852 if ((CountBits(b) == 1 && GetRoadBits(tile, ROADTYPE_TRAM) == ROAD_NONE) || |
5637
2ea5b88a8a32
(svn r8096) -Codechange: Invert the check if you are allowed to clear a road tile so there are not so many negations (too confusing) and added some comments to further clarify what happens.
Darkvater <Darkvater@openttd.org>
parents:
5587
diff
changeset
|
853 ((flags & DC_AI_BUILDING) && IsTileOwner(tile, OWNER_TOWN)) || |
2ea5b88a8a32
(svn r8096) -Codechange: Invert the check if you are allowed to clear a road tile so there are not so many negations (too confusing) and added some comments to further clarify what happens.
Darkvater <Darkvater@openttd.org>
parents:
5587
diff
changeset
|
854 !(flags & DC_AUTO) |
2ea5b88a8a32
(svn r8096) -Codechange: Invert the check if you are allowed to clear a road tile so there are not so many negations (too confusing) and added some comments to further clarify what happens.
Darkvater <Darkvater@openttd.org>
parents:
5587
diff
changeset
|
855 ) { |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
856 RoadTypes rts = GetRoadTypes(tile); |
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
|
857 CommandCost ret(EXPENSES_CONSTRUCTION); |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
858 for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) { |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7857
diff
changeset
|
859 if (HasBit(rts, rt)) { |
8428
f92ccc2f6f17
(svn r11998) -Fix [FS#1692](r10053): possible remote assert by setting bit 6 of p1 for CMD_REMOVE_ROAD
smatz <smatz@openttd.org>
parents:
8413
diff
changeset
|
860 CommandCost tmp_ret = RemoveRoad(tile, flags, GetRoadBits(tile, rt), rt, true); |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
861 if (CmdFailed(tmp_ret)) return tmp_ret; |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6946
diff
changeset
|
862 ret.AddCost(tmp_ret); |
6679
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
863 } |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
864 } |
3e58cf5e349d
(svn r9910) -Codechange: prepare road building/removing commands for more road types.
rubidium <rubidium@openttd.org>
parents:
6666
diff
changeset
|
865 return 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
|
866 } |
5637
2ea5b88a8a32
(svn r8096) -Codechange: Invert the check if you are allowed to clear a road tile so there are not so many negations (too confusing) and added some comments to further clarify what happens.
Darkvater <Darkvater@openttd.org>
parents:
5587
diff
changeset
|
867 return_cmd_error(STR_1801_MUST_REMOVE_ROAD_FIRST); |
5643
00155b55016f
(svn r8102) -Cleanup: Remove unreachable code (r8096), useless cast
Darkvater <Darkvater@openttd.org>
parents:
5637
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 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
870 case ROAD_TILE_CROSSING: { |
6814
4cc8ebb6279d
(svn r10053) -Fix: could not clear a level-crossing tile with tram tracks.
rubidium <rubidium@openttd.org>
parents:
6768
diff
changeset
|
871 RoadTypes rts = GetRoadTypes(tile); |
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
|
872 CommandCost ret(EXPENSES_CONSTRUCTION); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
873 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
874 if (flags & DC_AUTO) return_cmd_error(STR_1801_MUST_REMOVE_ROAD_FIRST); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
875 |
6814
4cc8ebb6279d
(svn r10053) -Fix: could not clear a level-crossing tile with tram tracks.
rubidium <rubidium@openttd.org>
parents:
6768
diff
changeset
|
876 /* Must iterate over the roadtypes in a reverse manner because |
4cc8ebb6279d
(svn r10053) -Fix: could not clear a level-crossing tile with tram tracks.
rubidium <rubidium@openttd.org>
parents:
6768
diff
changeset
|
877 * tram tracks must be removed before the road bits. */ |
4cc8ebb6279d
(svn r10053) -Fix: could not clear a level-crossing tile with tram tracks.
rubidium <rubidium@openttd.org>
parents:
6768
diff
changeset
|
878 for (RoadType rt = ROADTYPE_HWAY; rt >= ROADTYPE_ROAD; rt--) { |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7857
diff
changeset
|
879 if (HasBit(rts, rt)) { |
8428
f92ccc2f6f17
(svn r11998) -Fix [FS#1692](r10053): possible remote assert by setting bit 6 of p1 for CMD_REMOVE_ROAD
smatz <smatz@openttd.org>
parents:
8413
diff
changeset
|
880 CommandCost tmp_ret = RemoveRoad(tile, flags, GetCrossingRoadBits(tile), rt, false); |
6814
4cc8ebb6279d
(svn r10053) -Fix: could not clear a level-crossing tile with tram tracks.
rubidium <rubidium@openttd.org>
parents:
6768
diff
changeset
|
881 if (CmdFailed(tmp_ret)) return tmp_ret; |
6950
d2846442a133
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium <rubidium@openttd.org>
parents:
6946
diff
changeset
|
882 ret.AddCost(tmp_ret); |
6814
4cc8ebb6279d
(svn r10053) -Fix: could not clear a level-crossing tile with tram tracks.
rubidium <rubidium@openttd.org>
parents:
6768
diff
changeset
|
883 } |
4cc8ebb6279d
(svn r10053) -Fix: could not clear a level-crossing tile with tram tracks.
rubidium <rubidium@openttd.org>
parents:
6768
diff
changeset
|
884 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
885 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
886 if (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
|
887 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
|
888 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
889 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
|
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 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
892 default: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
893 case ROAD_TILE_DEPOT: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
894 if (flags & DC_AUTO) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
895 return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
896 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
897 return RemoveRoadDepot(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
|
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 } |
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 |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6172
diff
changeset
|
902 struct DrawRoadTileStruct { |
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 uint16 image; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
904 byte subcoord_x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
905 byte subcoord_y; |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6172
diff
changeset
|
906 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
907 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
908 #include "table/road_land.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
909 |
8734
c370e9d5f5c4
(svn r12419) -Cleanup: of the internal road-piece building and removing.
skidd13 <skidd13@openttd.org>
parents:
8732
diff
changeset
|
910 /** |
c370e9d5f5c4
(svn r12419) -Cleanup: of the internal road-piece building and removing.
skidd13 <skidd13@openttd.org>
parents:
8732
diff
changeset
|
911 * Get the foundationtype of a RoadBits Slope combination |
c370e9d5f5c4
(svn r12419) -Cleanup: of the internal road-piece building and removing.
skidd13 <skidd13@openttd.org>
parents:
8732
diff
changeset
|
912 * |
c370e9d5f5c4
(svn r12419) -Cleanup: of the internal road-piece building and removing.
skidd13 <skidd13@openttd.org>
parents:
8732
diff
changeset
|
913 * @param tileh The Slope part |
c370e9d5f5c4
(svn r12419) -Cleanup: of the internal road-piece building and removing.
skidd13 <skidd13@openttd.org>
parents:
8732
diff
changeset
|
914 * @param bits The RoadBits part |
c370e9d5f5c4
(svn r12419) -Cleanup: of the internal road-piece building and removing.
skidd13 <skidd13@openttd.org>
parents:
8732
diff
changeset
|
915 * @return The resulting Foundation |
c370e9d5f5c4
(svn r12419) -Cleanup: of the internal road-piece building and removing.
skidd13 <skidd13@openttd.org>
parents:
8732
diff
changeset
|
916 */ |
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
|
917 Foundation GetRoadFoundation(Slope tileh, RoadBits bits) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
918 { |
8734
c370e9d5f5c4
(svn r12419) -Cleanup: of the internal road-piece building and removing.
skidd13 <skidd13@openttd.org>
parents:
8732
diff
changeset
|
919 /* Flat land and land without a road doesn't require a foundation */ |
c370e9d5f5c4
(svn r12419) -Cleanup: of the internal road-piece building and removing.
skidd13 <skidd13@openttd.org>
parents:
8732
diff
changeset
|
920 if (tileh == SLOPE_FLAT || bits == ROAD_NONE) return FOUNDATION_NONE; |
c370e9d5f5c4
(svn r12419) -Cleanup: of the internal road-piece building and removing.
skidd13 <skidd13@openttd.org>
parents:
8732
diff
changeset
|
921 |
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
|
922 if (!IsSteepSlope(tileh)) { |
8744
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
923 /* Leveled RoadBits on a slope */ |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
924 if ((_invalid_tileh_slopes_road[0][tileh] & bits) == ROAD_NONE) return FOUNDATION_LEVELED; |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
925 |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
926 /* Straight roads without foundation on a slope */ |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
927 if (!IsSlopeWithOneCornerRaised(tileh) && |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
928 (_invalid_tileh_slopes_road[1][tileh] & bits) == ROAD_NONE) |
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
929 return FOUNDATION_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
|
930 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
931 |
8744
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
932 /* Roads on steep Slopes or on Slopes with one corner raised */ |
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
|
933 return (bits == ROAD_X ? FOUNDATION_INCLINED_X : FOUNDATION_INCLINED_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
|
934 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
935 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
936 const byte _road_sloped_sprites[14] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
937 0, 0, 2, 0, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
938 0, 1, 0, 0, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
939 3, 0, 0, 0, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
940 0, 0 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
941 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
942 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
943 /** |
6541
b6b454522d0b
(svn r9730) -Feature: [NewGRF] Add support for miscellaneous grf feature bit 1 - paved roads on desert tiles.
maedhros <maedhros@openttd.org>
parents:
6491
diff
changeset
|
944 * Whether to draw unpaved roads regardless of the town zone. |
b6b454522d0b
(svn r9730) -Feature: [NewGRF] Add support for miscellaneous grf feature bit 1 - paved roads on desert tiles.
maedhros <maedhros@openttd.org>
parents:
6491
diff
changeset
|
945 * By default, OpenTTD always draws roads as unpaved if they are on a desert |
b6b454522d0b
(svn r9730) -Feature: [NewGRF] Add support for miscellaneous grf feature bit 1 - paved roads on desert tiles.
maedhros <maedhros@openttd.org>
parents:
6491
diff
changeset
|
946 * tile or above the snowline. Newgrf files, however, can set a bit that allows |
b6b454522d0b
(svn r9730) -Feature: [NewGRF] Add support for miscellaneous grf feature bit 1 - paved roads on desert tiles.
maedhros <maedhros@openttd.org>
parents:
6491
diff
changeset
|
947 * paved roads to be built on desert tiles as they would be on grassy tiles. |
b6b454522d0b
(svn r9730) -Feature: [NewGRF] Add support for miscellaneous grf feature bit 1 - paved roads on desert tiles.
maedhros <maedhros@openttd.org>
parents:
6491
diff
changeset
|
948 * |
b6b454522d0b
(svn r9730) -Feature: [NewGRF] Add support for miscellaneous grf feature bit 1 - paved roads on desert tiles.
maedhros <maedhros@openttd.org>
parents:
6491
diff
changeset
|
949 * @param tile The tile the road is on |
b6b454522d0b
(svn r9730) -Feature: [NewGRF] Add support for miscellaneous grf feature bit 1 - paved roads on desert tiles.
maedhros <maedhros@openttd.org>
parents:
6491
diff
changeset
|
950 * @param roadside What sort of road this is |
b6b454522d0b
(svn r9730) -Feature: [NewGRF] Add support for miscellaneous grf feature bit 1 - paved roads on desert tiles.
maedhros <maedhros@openttd.org>
parents:
6491
diff
changeset
|
951 * @return True if the road should be drawn unpaved regardless of the roadside. |
b6b454522d0b
(svn r9730) -Feature: [NewGRF] Add support for miscellaneous grf feature bit 1 - paved roads on desert tiles.
maedhros <maedhros@openttd.org>
parents:
6491
diff
changeset
|
952 */ |
b6b454522d0b
(svn r9730) -Feature: [NewGRF] Add support for miscellaneous grf feature bit 1 - paved roads on desert tiles.
maedhros <maedhros@openttd.org>
parents:
6491
diff
changeset
|
953 static bool AlwaysDrawUnpavedRoads(TileIndex tile, Roadside roadside) |
b6b454522d0b
(svn r9730) -Feature: [NewGRF] Add support for miscellaneous grf feature bit 1 - paved roads on desert tiles.
maedhros <maedhros@openttd.org>
parents:
6491
diff
changeset
|
954 { |
b6b454522d0b
(svn r9730) -Feature: [NewGRF] Add support for miscellaneous grf feature bit 1 - paved roads on desert tiles.
maedhros <maedhros@openttd.org>
parents:
6491
diff
changeset
|
955 return (IsOnSnow(tile) && |
b6b454522d0b
(svn r9730) -Feature: [NewGRF] Add support for miscellaneous grf feature bit 1 - paved roads on desert tiles.
maedhros <maedhros@openttd.org>
parents:
6491
diff
changeset
|
956 !(_opt.landscape == LT_TROPIC && HasGrfMiscBit(GMB_DESERT_PAVED_ROADS) && |
b6b454522d0b
(svn r9730) -Feature: [NewGRF] Add support for miscellaneous grf feature bit 1 - paved roads on desert tiles.
maedhros <maedhros@openttd.org>
parents:
6491
diff
changeset
|
957 roadside != ROADSIDE_BARREN && roadside != ROADSIDE_GRASS && roadside != ROADSIDE_GRASS_ROAD_WORKS)); |
b6b454522d0b
(svn r9730) -Feature: [NewGRF] Add support for miscellaneous grf feature bit 1 - paved roads on desert tiles.
maedhros <maedhros@openttd.org>
parents:
6491
diff
changeset
|
958 } |
b6b454522d0b
(svn r9730) -Feature: [NewGRF] Add support for miscellaneous grf feature bit 1 - paved roads on desert tiles.
maedhros <maedhros@openttd.org>
parents:
6491
diff
changeset
|
959 |
b6b454522d0b
(svn r9730) -Feature: [NewGRF] Add support for miscellaneous grf feature bit 1 - paved roads on desert tiles.
maedhros <maedhros@openttd.org>
parents:
6491
diff
changeset
|
960 /** |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
961 * Draws the catenary for the given tile |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
962 * @param ti information about the tile (slopes, height etc) |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
963 * @param tram the roadbits for the tram |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
964 */ |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
965 void DrawTramCatenary(const TileInfo *ti, RoadBits tram) |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
966 { |
8806
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8747
diff
changeset
|
967 /* Do not draw catenary if it is invisible */ |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8747
diff
changeset
|
968 if (IsInvisibilitySet(TO_CATENARY)) return; |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8747
diff
changeset
|
969 |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
970 /* Don't draw the catenary under a low bridge */ |
8528
58090cf32d23
(svn r12103) -Feature(tte): separate catenary transparency settings from building transparency settings
smatz <smatz@openttd.org>
parents:
8520
diff
changeset
|
971 if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !IsTransparencySet(TO_CATENARY)) { |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
972 uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile)); |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
973 |
6699
323f494a7076
(svn r9931) -Fix: some glitches with catenary and bridges.
rubidium <rubidium@openttd.org>
parents:
6697
diff
changeset
|
974 if (height <= GetTileMaxZ(ti->tile) + TILE_HEIGHT) return; |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
975 } |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
976 |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
977 SpriteID front; |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
978 SpriteID back; |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
979 |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
980 if (ti->tileh != SLOPE_FLAT) { |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
981 back = SPR_TRAMWAY_BACK_WIRES_SLOPED + _road_sloped_sprites[ti->tileh - 1]; |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
982 front = SPR_TRAMWAY_FRONT_WIRES_SLOPED + _road_sloped_sprites[ti->tileh - 1]; |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
983 } else { |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
984 back = SPR_TRAMWAY_BASE + _road_backpole_sprites_1[tram]; |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
985 front = SPR_TRAMWAY_BASE + _road_frontwire_sprites_1[tram]; |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
986 } |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
987 |
8528
58090cf32d23
(svn r12103) -Feature(tte): separate catenary transparency settings from building transparency settings
smatz <smatz@openttd.org>
parents:
8520
diff
changeset
|
988 AddSortableSpriteToDraw(back, PAL_NONE, ti->x, ti->y, 16, 16, TILE_HEIGHT + BB_HEIGHT_UNDER_BRIDGE, ti->z, IsTransparencySet(TO_CATENARY)); |
58090cf32d23
(svn r12103) -Feature(tte): separate catenary transparency settings from building transparency settings
smatz <smatz@openttd.org>
parents:
8520
diff
changeset
|
989 AddSortableSpriteToDraw(front, PAL_NONE, ti->x, ti->y, 16, 16, TILE_HEIGHT + BB_HEIGHT_UNDER_BRIDGE, ti->z, IsTransparencySet(TO_CATENARY)); |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
990 } |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
991 |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
992 /** |
6764
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
993 * Draws details on/around the road |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
994 * @param img the sprite to draw |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
995 * @param ti the tile to draw on |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
996 * @param dx the offset from the top of the BB of the tile |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
997 * @param dy the offset from the top of the BB of the tile |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
998 * @param h the height of the sprite to draw |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
999 */ |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
1000 static void DrawRoadDetail(SpriteID img, const TileInfo *ti, int dx, int dy, int h) |
6764
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
1001 { |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
1002 int x = ti->x | dx; |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
1003 int y = ti->y | dy; |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
1004 byte z = ti->z; |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
1005 if (ti->tileh != SLOPE_FLAT) z = GetSlopeZ(x, y); |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
1006 AddSortableSpriteToDraw(img, PAL_NONE, x, y, 2, 2, h, z); |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
1007 } |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
1008 |
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
1009 /** |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1010 * Draw ground sprite and road pieces |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1011 * @param ti TileInfo |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1012 */ |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
1013 static void DrawRoadBits(TileInfo *ti) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1014 { |
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:
6626
diff
changeset
|
1015 RoadBits road = GetRoadBits(ti->tile, ROADTYPE_ROAD); |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
1016 RoadBits tram = GetRoadBits(ti->tile, ROADTYPE_TRAM); |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
1017 |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5643
diff
changeset
|
1018 SpriteID image = 0; |
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5643
diff
changeset
|
1019 SpriteID pal = 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
|
1020 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1021 if (ti->tileh != SLOPE_FLAT) { |
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
|
1022 DrawFoundation(ti, GetRoadFoundation(ti->tileh, road | tram)); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1023 |
6393
ffd35446c110
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas <belugas@openttd.org>
parents:
6368
diff
changeset
|
1024 /* DrawFoundation() modifies ti. |
ffd35446c110
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas <belugas@openttd.org>
parents:
6368
diff
changeset
|
1025 * Default sloped sprites.. */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1026 if (ti->tileh != SLOPE_FLAT) image = _road_sloped_sprites[ti->tileh - 1] + 0x53F; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1027 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1028 |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
1029 if (image == 0) image = _road_tile_sprites_1[road != ROAD_NONE ? road : tram]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1030 |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
1031 Roadside roadside = GetRoadside(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
|
1032 |
6541
b6b454522d0b
(svn r9730) -Feature: [NewGRF] Add support for miscellaneous grf feature bit 1 - paved roads on desert tiles.
maedhros <maedhros@openttd.org>
parents:
6491
diff
changeset
|
1033 if (AlwaysDrawUnpavedRoads(ti->tile, roadside)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1034 image += 19; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1035 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1036 switch (roadside) { |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5643
diff
changeset
|
1037 case ROADSIDE_BARREN: pal = PALETTE_TO_BARE_LAND; 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
|
1038 case ROADSIDE_GRASS: break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1039 case ROADSIDE_GRASS_ROAD_WORKS: break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1040 default: image -= 19; break; // Paved |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1041 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1042 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1043 |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5643
diff
changeset
|
1044 DrawGroundSprite(image, pal); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1045 |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
1046 /* For tram we overlay the road graphics with either tram tracks only |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
1047 * (when there is actual road beneath the trams) or with tram tracks |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
1048 * and some dirts which hides the road graphics */ |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
1049 if (tram != ROAD_NONE) { |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
1050 if (ti->tileh != SLOPE_FLAT) { |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
1051 image = _road_sloped_sprites[ti->tileh - 1] + SPR_TRAMWAY_SLOPED_OFFSET; |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
1052 } else { |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
1053 image = _road_tile_sprites_1[tram] - SPR_ROAD_Y; |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
1054 } |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
1055 image += (road == ROAD_NONE) ? SPR_TRAMWAY_TRAM : SPR_TRAMWAY_OVERLAY; |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
1056 DrawGroundSprite(image, pal); |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
1057 } |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
1058 |
6965
1ab6e2557bef
(svn r10221) -Fix: the one way sprites weren't drawn in the correct order, so they could remove the tramtrack in some cases.
rubidium <rubidium@openttd.org>
parents:
6950
diff
changeset
|
1059 if (road != ROAD_NONE) { |
1ab6e2557bef
(svn r10221) -Fix: the one way sprites weren't drawn in the correct order, so they could remove the tramtrack in some cases.
rubidium <rubidium@openttd.org>
parents:
6950
diff
changeset
|
1060 DisallowedRoadDirections drd = GetDisallowedRoadDirections(ti->tile); |
1ab6e2557bef
(svn r10221) -Fix: the one way sprites weren't drawn in the correct order, so they could remove the tramtrack in some cases.
rubidium <rubidium@openttd.org>
parents:
6950
diff
changeset
|
1061 if (drd != DRD_NONE) { |
1ab6e2557bef
(svn r10221) -Fix: the one way sprites weren't drawn in the correct order, so they could remove the tramtrack in some cases.
rubidium <rubidium@openttd.org>
parents:
6950
diff
changeset
|
1062 DrawRoadDetail(SPR_ONEWAY_BASE + drd - 1 + ((road == ROAD_X) ? 0 : 3), ti, 8, 8, 0); |
1ab6e2557bef
(svn r10221) -Fix: the one way sprites weren't drawn in the correct order, so they could remove the tramtrack in some cases.
rubidium <rubidium@openttd.org>
parents:
6950
diff
changeset
|
1063 } |
1ab6e2557bef
(svn r10221) -Fix: the one way sprites weren't drawn in the correct order, so they could remove the tramtrack in some cases.
rubidium <rubidium@openttd.org>
parents:
6950
diff
changeset
|
1064 } |
1ab6e2557bef
(svn r10221) -Fix: the one way sprites weren't drawn in the correct order, so they could remove the tramtrack in some cases.
rubidium <rubidium@openttd.org>
parents:
6950
diff
changeset
|
1065 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1066 if (HasRoadWorks(ti->tile)) { |
6393
ffd35446c110
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas <belugas@openttd.org>
parents:
6368
diff
changeset
|
1067 /* Road works */ |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
1068 DrawGroundSprite((road | tram) & ROAD_X ? SPR_EXCAVATION_X : SPR_EXCAVATION_Y, 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
|
1069 return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1070 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1071 |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
1072 if (tram != ROAD_NONE) DrawTramCatenary(ti, tram); |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
1073 |
6393
ffd35446c110
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas <belugas@openttd.org>
parents:
6368
diff
changeset
|
1074 /* Return if full detail is disabled, or we are zoomed fully out. */ |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7857
diff
changeset
|
1075 if (!HasBit(_display_opt, DO_FULL_DETAIL) || _cur_dpi->zoom > ZOOM_LVL_DETAIL) return; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1076 |
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:
8571
diff
changeset
|
1077 /* Do not draw details (street lights, trees) under low 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:
8571
diff
changeset
|
1078 if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && (roadside == ROADSIDE_TREES || roadside == ROADSIDE_STREET_LIGHTS)) { |
86a968000cc9
(svn r12170) -Fix: do not draw trees along road and street lights under low bridges (spotted by _minime_)
smatz <smatz@openttd.org>
parents:
8571
diff
changeset
|
1079 uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile)); |
86a968000cc9
(svn r12170) -Fix: do not draw trees along road and street lights under low bridges (spotted by _minime_)
smatz <smatz@openttd.org>
parents:
8571
diff
changeset
|
1080 uint minz = GetTileMaxZ(ti->tile) + 2 * 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:
8571
diff
changeset
|
1081 |
86a968000cc9
(svn r12170) -Fix: do not draw trees along road and street lights under low bridges (spotted by _minime_)
smatz <smatz@openttd.org>
parents:
8571
diff
changeset
|
1082 if (roadside == ROADSIDE_TREES) minz += 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:
8571
diff
changeset
|
1083 |
86a968000cc9
(svn r12170) -Fix: do not draw trees along road and street lights under low bridges (spotted by _minime_)
smatz <smatz@openttd.org>
parents:
8571
diff
changeset
|
1084 if (height < minz) return; |
86a968000cc9
(svn r12170) -Fix: do not draw trees along road and street lights under low bridges (spotted by _minime_)
smatz <smatz@openttd.org>
parents:
8571
diff
changeset
|
1085 } |
86a968000cc9
(svn r12170) -Fix: do not draw trees along road and street lights under low bridges (spotted by _minime_)
smatz <smatz@openttd.org>
parents:
8571
diff
changeset
|
1086 |
8647
16c86989601a
(svn r12290) -Fix[FS#1807]: Do not draw trees nor lamps between tram tracks.(Roujin)
belugas <belugas@openttd.org>
parents:
8616
diff
changeset
|
1087 /* If there are no road bits, return, as there is nothing left to do */ |
16c86989601a
(svn r12290) -Fix[FS#1807]: Do not draw trees nor lamps between tram tracks.(Roujin)
belugas <belugas@openttd.org>
parents:
8616
diff
changeset
|
1088 if (CountBits(road) < 2) return; |
16c86989601a
(svn r12290) -Fix[FS#1807]: Do not draw trees nor lamps between tram tracks.(Roujin)
belugas <belugas@openttd.org>
parents:
8616
diff
changeset
|
1089 |
6393
ffd35446c110
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas <belugas@openttd.org>
parents:
6368
diff
changeset
|
1090 /* Draw extra details. */ |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
1091 for (const DrawRoadTileStruct *drts = _road_display_table[roadside][road | tram]; drts->image != 0; drts++) { |
6764
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
1092 DrawRoadDetail(drts->image, ti, drts->subcoord_x, drts->subcoord_y, 0x10); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1093 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1094 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1095 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1096 static void DrawTile_Road(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
|
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 switch (GetRoadTileType(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
|
1099 case ROAD_TILE_NORMAL: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1100 DrawRoadBits(ti); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1101 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1102 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1103 case ROAD_TILE_CROSSING: { |
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
|
1104 if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, FOUNDATION_LEVELED); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1105 |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
1106 SpriteID image = GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.crossing; |
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
1107 SpriteID pal = 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
|
1108 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1109 if (GetCrossingRoadAxis(ti->tile) == AXIS_X) image++; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1110 if (IsCrossingBarred(ti->tile)) image += 2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1111 |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
1112 Roadside roadside = GetRoadside(ti->tile); |
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
1113 |
6541
b6b454522d0b
(svn r9730) -Feature: [NewGRF] Add support for miscellaneous grf feature bit 1 - paved roads on desert tiles.
maedhros <maedhros@openttd.org>
parents:
6491
diff
changeset
|
1114 if (AlwaysDrawUnpavedRoads(ti->tile, roadside)) { |
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 image += 8; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1116 } else { |
6541
b6b454522d0b
(svn r9730) -Feature: [NewGRF] Add support for miscellaneous grf feature bit 1 - paved roads on desert tiles.
maedhros <maedhros@openttd.org>
parents:
6491
diff
changeset
|
1117 switch (roadside) { |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5643
diff
changeset
|
1118 case ROADSIDE_BARREN: pal = PALETTE_TO_BARE_LAND; 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
|
1119 case ROADSIDE_GRASS: break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1120 default: image += 4; break; // Paved |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1121 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1122 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1123 |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5643
diff
changeset
|
1124 DrawGroundSprite(image, pal); |
8563
992fa65afba1
(svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents:
8560
diff
changeset
|
1125 if (HasTileRoadType(ti->tile, ROADTYPE_TRAM)) { |
6697
398474f3706e
(svn r9929) -Fix [FS#803]: fix several drawing issues.
rubidium <rubidium@openttd.org>
parents:
6691
diff
changeset
|
1126 DrawGroundSprite(SPR_TRAMWAY_OVERLAY + (GetCrossingRoadAxis(ti->tile) ^ 1), pal); |
398474f3706e
(svn r9929) -Fix [FS#803]: fix several drawing issues.
rubidium <rubidium@openttd.org>
parents:
6691
diff
changeset
|
1127 DrawTramCatenary(ti, GetCrossingRoadBits(ti->tile)); |
398474f3706e
(svn r9929) -Fix [FS#803]: fix several drawing issues.
rubidium <rubidium@openttd.org>
parents:
6691
diff
changeset
|
1128 } |
8732
813d23b5c9a3
(svn r12410) -Codechange: abstract out the test for catenary on electric rails
peter1138 <peter1138@openttd.org>
parents:
8690
diff
changeset
|
1129 if (HasCatenary(GetRailType(ti->tile))) DrawCatenary(ti); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1130 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 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1133 default: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1134 case ROAD_TILE_DEPOT: { |
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
|
1135 if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, FOUNDATION_LEVELED); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1136 |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
1137 SpriteID palette = PLAYER_SPRITE_COLOR(GetTileOwner(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
|
1138 |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
1139 const DrawTileSprites *dts; |
8563
992fa65afba1
(svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents:
8560
diff
changeset
|
1140 if (HasTileRoadType(ti->tile, ROADTYPE_TRAM)) { |
6691
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
1141 dts = &_tram_depot[GetRoadDepotDirection(ti->tile)]; |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
1142 } else { |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
1143 dts = &_road_depot[GetRoadDepotDirection(ti->tile)]; |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
1144 } |
d2fb32d942f7
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium <rubidium@openttd.org>
parents:
6689
diff
changeset
|
1145 |
8571
b611278e4fed
(svn r12149) -Codechange: Merge 'ground_sprite' and 'ground_pal' of DrawTileSprites into one PalSpriteID
frosch <frosch@openttd.org>
parents:
8570
diff
changeset
|
1146 DrawGroundSprite(dts->ground.sprite, 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
|
1147 |
8806
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8747
diff
changeset
|
1148 /* End now if buildings are invisible */ |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8747
diff
changeset
|
1149 if (IsInvisibilitySet(TO_BUILDINGS)) break; |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8747
diff
changeset
|
1150 |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
1151 for (const DrawTileSeqStruct *dtss = dts->seq; dtss->image.sprite != 0; dtss++) { |
8570
2b1397dd930a
(svn r12148) -Codechange: Merge 'image' and 'pal' of DrawTileSeqStruct into one PalSpriteID
frosch <frosch@openttd.org>
parents:
8563
diff
changeset
|
1152 SpriteID image = dtss->image.sprite; |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5643
diff
changeset
|
1153 SpriteID pal; |
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 |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7857
diff
changeset
|
1155 if (!IsTransparencySet(TO_BUILDINGS) && HasBit(image, PALETTE_MODIFIER_COLOR)) { |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5643
diff
changeset
|
1156 pal = palette; |
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5643
diff
changeset
|
1157 } else { |
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5643
diff
changeset
|
1158 pal = 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
|
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 AddSortableSpriteToDraw( |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5643
diff
changeset
|
1162 image, pal, |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1163 ti->x + dtss->delta_x, ti->y + dtss->delta_y, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1164 dtss->size_x, dtss->size_y, |
7333
7110c41ab174
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium <rubidium@openttd.org>
parents:
7332
diff
changeset
|
1165 dtss->size_z, ti->z, |
7849
e6ee8bfd9045
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas <belugas@openttd.org>
parents:
7832
diff
changeset
|
1166 IsTransparencySet(TO_BUILDINGS) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1167 ); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1168 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1169 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1170 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1171 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1172 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
|
1173 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1174 |
6666
61e17c4bac25
(svn r9897) -Codechange: prepare the toolbar for more road types.
rubidium <rubidium@openttd.org>
parents:
6662
diff
changeset
|
1175 void DrawRoadDepotSprite(int x, int y, DiagDirection dir, RoadType rt) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1176 { |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5643
diff
changeset
|
1177 SpriteID palette = PLAYER_SPRITE_COLOR(_local_player); |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
1178 const DrawTileSprites *dts = (rt == ROADTYPE_TRAM) ? &_tram_depot[dir] : &_road_depot[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
|
1179 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1180 x += 33; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1181 y += 17; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1182 |
8571
b611278e4fed
(svn r12149) -Codechange: Merge 'ground_sprite' and 'ground_pal' of DrawTileSprites into one PalSpriteID
frosch <frosch@openttd.org>
parents:
8570
diff
changeset
|
1183 DrawSprite(dts->ground.sprite, PAL_NONE, x, 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
|
1184 |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
1185 for (const DrawTileSeqStruct *dtss = dts->seq; dtss->image.sprite != 0; dtss++) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1186 Point pt = RemapCoords(dtss->delta_x, dtss->delta_y, dtss->delta_z); |
8570
2b1397dd930a
(svn r12148) -Codechange: Merge 'image' and 'pal' of DrawTileSeqStruct into one PalSpriteID
frosch <frosch@openttd.org>
parents:
8563
diff
changeset
|
1187 SpriteID image = dtss->image.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
|
1188 |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7857
diff
changeset
|
1189 DrawSprite(image, HasBit(image, PALETTE_MODIFIER_COLOR) ? palette : PAL_NONE, x + pt.x, y + pt.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
|
1190 } |
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 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1193 static uint GetSlopeZ_Road(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
|
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 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
|
1196 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
|
1197 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1198 if (tileh == SLOPE_FLAT) return z; |
8563
992fa65afba1
(svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents:
8560
diff
changeset
|
1199 if (IsNormalRoad(tile)) { |
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
|
1200 Foundation f = GetRoadFoundation(tileh, GetAllRoadBits(tile)); |
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
|
1201 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
|
1202 return z + GetPartialZ(x & 0xF, y & 0xF, tileh); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1203 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1204 return z + TILE_HEIGHT; |
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 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1207 |
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
|
1208 static Foundation GetFoundation_Road(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
|
1209 { |
8563
992fa65afba1
(svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents:
8560
diff
changeset
|
1210 if (IsNormalRoad(tile)) { |
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
|
1211 return GetRoadFoundation(tileh, GetAllRoadBits(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
|
1212 } else { |
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
|
1213 return FlatteningFoundation(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
|
1214 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1215 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1216 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1217 static void GetAcceptedCargo_Road(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
|
1218 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1219 /* 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
|
1220 } |
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 static void AnimateTile_Road(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
|
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 if (IsLevelCrossing(tile)) 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
|
1225 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1226 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1227 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1228 static const Roadside _town_road_types[][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 { ROADSIDE_GRASS, ROADSIDE_GRASS }, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1230 { ROADSIDE_PAVED, ROADSIDE_PAVED }, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1231 { ROADSIDE_PAVED, ROADSIDE_PAVED }, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1232 { ROADSIDE_TREES, ROADSIDE_TREES }, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1233 { ROADSIDE_STREET_LIGHTS, ROADSIDE_PAVED } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1234 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1235 |
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 Roadside _town_road_types_2[][2] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1237 { ROADSIDE_GRASS, ROADSIDE_GRASS }, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1238 { ROADSIDE_PAVED, ROADSIDE_PAVED }, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1239 { ROADSIDE_STREET_LIGHTS, ROADSIDE_PAVED }, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1240 { ROADSIDE_STREET_LIGHTS, ROADSIDE_PAVED }, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1241 { ROADSIDE_STREET_LIGHTS, ROADSIDE_PAVED } |
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 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1244 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1245 static void TileLoop_Road(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
|
1246 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1247 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
|
1248 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
|
1249 if (IsOnSnow(tile) != (GetTileZ(tile) > GetSnowLine())) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1250 ToggleSnow(tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1251 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
|
1252 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1253 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1254 |
6357
96b1652c6011
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas <belugas@openttd.org>
parents:
6343
diff
changeset
|
1255 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
|
1256 if (GetTropicZone(tile) == TROPICZONE_DESERT && !IsOnDesert(tile)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1257 ToggleDesert(tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1258 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
|
1259 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1260 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1261 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1262 |
8563
992fa65afba1
(svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents:
8560
diff
changeset
|
1263 if (IsRoadDepot(tile)) return; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1264 |
8821
2589a14c08fb
(svn r12569) -Cleanup: variable scope and coding style in road*.cpp
smatz <smatz@openttd.org>
parents:
8806
diff
changeset
|
1265 const Town *t = ClosestTownFromTile(tile, (uint)-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
|
1266 if (!HasRoadWorks(tile)) { |
8308
e9042729a5c5
(svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas <belugas@openttd.org>
parents:
8264
diff
changeset
|
1267 HouseZonesBits grp = HZB_TOWN_EDGE; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1268 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1269 if (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
|
1270 grp = GetTownRadiusGroup(t, tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1271 |
6393
ffd35446c110
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas <belugas@openttd.org>
parents:
6368
diff
changeset
|
1272 /* Show an animation to indicate road work */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1273 if (t->road_build_months != 0 && |
8308
e9042729a5c5
(svn r11873) -Codechange: less a few magical numbers and a tiny bit more comments on town zones
belugas <belugas@openttd.org>
parents:
8264
diff
changeset
|
1274 (DistanceManhattan(t->xy, tile) < 8 || grp != HZB_TOWN_EDGE) && |
8563
992fa65afba1
(svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents:
8560
diff
changeset
|
1275 IsNormalRoad(tile) && CountBits(GetAllRoadBits(tile)) > 1 ) { |
7967
e30c5ec2d272
(svn r11523) -Codechange: Move the CHANCE macros to core/random_func.cpp cause they depend on Random()
skidd13 <skidd13@openttd.org>
parents:
7954
diff
changeset
|
1276 if (GetTileSlope(tile, NULL) == SLOPE_FLAT && EnsureNoVehicleOnGround(tile) && Chance16(1, 40)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1277 StartRoadWorks(tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1278 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1279 SndPlayTileFx(SND_21_JACKHAMMER, tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1280 CreateEffectVehicleAbove( |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1281 TileX(tile) * TILE_SIZE + 7, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1282 TileY(tile) * TILE_SIZE + 7, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1283 0, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1284 EV_BULLDOZER); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1285 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
|
1286 return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1287 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1288 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1289 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1290 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1291 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1292 /* Adjust road ground type depending on 'grp' (grp is the distance to the center) */ |
6357
96b1652c6011
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas <belugas@openttd.org>
parents:
6343
diff
changeset
|
1293 const Roadside* new_rs = (_opt.landscape == LT_TOYLAND) ? _town_road_types_2[grp] : _town_road_types[grp]; |
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 Roadside cur_rs = GetRoadside(tile); |
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 /* We have our desired type, do nothing */ |
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 (cur_rs == new_rs[0]) return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1298 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1299 /* We have the pre-type of the desired type, switch to the desired type */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1300 if (cur_rs == new_rs[1]) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1301 cur_rs = new_rs[0]; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1302 /* We have barren land, install the pre-type */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1303 } else if (cur_rs == ROADSIDE_BARREN) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1304 cur_rs = new_rs[1]; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1305 /* We're totally off limits, remove any installation and make barren land */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1306 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1307 cur_rs = ROADSIDE_BARREN; |
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 SetRoadside(tile, cur_rs); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1310 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
|
1311 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1312 } else if (IncreaseRoadWorksCounter(tile)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1313 TerminateRoadWorks(tile); |
7641
5e3cd60f89c4
(svn r11172) -Codechange: rewrite of town road building and addition of the possibility to clean up unconnected road bits during the local road reconstructions. Based on a patch by skidd13.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
1314 |
5e3cd60f89c4
(svn r11172) -Codechange: rewrite of town road building and addition of the possibility to clean up unconnected road bits during the local road reconstructions. Based on a patch by skidd13.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
1315 if (_patches.mod_road_rebuild) { |
5e3cd60f89c4
(svn r11172) -Codechange: rewrite of town road building and addition of the possibility to clean up unconnected road bits during the local road reconstructions. Based on a patch by skidd13.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
1316 /* Generate a nicer town surface */ |
5e3cd60f89c4
(svn r11172) -Codechange: rewrite of town road building and addition of the possibility to clean up unconnected road bits during the local road reconstructions. Based on a patch by skidd13.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
1317 const RoadBits old_rb = GetAnyRoadBits(tile, ROADTYPE_ROAD); |
5e3cd60f89c4
(svn r11172) -Codechange: rewrite of town road building and addition of the possibility to clean up unconnected road bits during the local road reconstructions. Based on a patch by skidd13.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
1318 const RoadBits new_rb = CleanUpRoadBits(tile, old_rb); |
5e3cd60f89c4
(svn r11172) -Codechange: rewrite of town road building and addition of the possibility to clean up unconnected road bits during the local road reconstructions. Based on a patch by skidd13.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
1319 |
5e3cd60f89c4
(svn r11172) -Codechange: rewrite of town road building and addition of the possibility to clean up unconnected road bits during the local road reconstructions. Based on a patch by skidd13.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
1320 if (old_rb != new_rb) { |
8428
f92ccc2f6f17
(svn r11998) -Fix [FS#1692](r10053): possible remote assert by setting bit 6 of p1 for CMD_REMOVE_ROAD
smatz <smatz@openttd.org>
parents:
8413
diff
changeset
|
1321 RemoveRoad(tile, DC_EXEC | DC_AUTO | DC_NO_WATER, (old_rb ^ new_rb), ROADTYPE_ROAD, true); |
7641
5e3cd60f89c4
(svn r11172) -Codechange: rewrite of town road building and addition of the possibility to clean up unconnected road bits during the local road reconstructions. Based on a patch by skidd13.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
1322 } |
5e3cd60f89c4
(svn r11172) -Codechange: rewrite of town road building and addition of the possibility to clean up unconnected road bits during the local road reconstructions. Based on a patch by skidd13.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
1323 } |
5e3cd60f89c4
(svn r11172) -Codechange: rewrite of town road building and addition of the possibility to clean up unconnected road bits during the local road reconstructions. Based on a patch by skidd13.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
1324 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1325 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
|
1326 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1327 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1328 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1329 static void ClickTile_Road(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
|
1330 { |
8563
992fa65afba1
(svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents:
8560
diff
changeset
|
1331 if (IsRoadDepot(tile)) ShowDepotWindow(tile, 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
|
1332 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1333 |
8616
9e46ac001a8c
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch <frosch@openttd.org>
parents:
8603
diff
changeset
|
1334 /* Converts RoadBits to TrackBits */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1335 static const byte _road_trackbits[16] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1336 0x0, 0x0, 0x0, 0x10, 0x0, 0x2, 0x8, 0x1A, 0x0, 0x4, 0x1, 0x15, 0x20, 0x26, 0x29, 0x3F, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1337 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1338 |
8616
9e46ac001a8c
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch <frosch@openttd.org>
parents:
8603
diff
changeset
|
1339 static TrackStatus GetTileTrackStatus_Road(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
|
1340 { |
8616
9e46ac001a8c
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch <frosch@openttd.org>
parents:
8603
diff
changeset
|
1341 TrackdirBits trackdirbits = TRACKDIR_BIT_NONE; |
9e46ac001a8c
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch <frosch@openttd.org>
parents:
8603
diff
changeset
|
1342 TrackdirBits red_signals = TRACKDIR_BIT_NONE; // crossing barred |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1343 switch (mode) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1344 case TRANSPORT_RAIL: |
8616
9e46ac001a8c
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch <frosch@openttd.org>
parents:
8603
diff
changeset
|
1345 if (IsLevelCrossing(tile)) trackdirbits = TrackBitsToTrackdirBits(GetCrossingRailBits(tile)); |
9e46ac001a8c
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch <frosch@openttd.org>
parents:
8603
diff
changeset
|
1346 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
|
1347 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1348 case TRANSPORT_ROAD: |
8616
9e46ac001a8c
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch <frosch@openttd.org>
parents:
8603
diff
changeset
|
1349 if ((GetRoadTypes(tile) & sub_mode) == 0) 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
|
1350 switch (GetRoadTileType(tile)) { |
6683
6984c0dbbb07
(svn r9914) -Codechange: prepare GTTS and the pathfinders to handle multiple road types on a single tile.
rubidium <rubidium@openttd.org>
parents:
6679
diff
changeset
|
1351 case ROAD_TILE_NORMAL: { |
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:
8589
diff
changeset
|
1352 const uint drd_to_multiplier[DRD_END] = { 0x101, 0x100, 0x1, 0x0 }; |
6683
6984c0dbbb07
(svn r9914) -Codechange: prepare GTTS and the pathfinders to handle multiple road types on a single tile.
rubidium <rubidium@openttd.org>
parents:
6679
diff
changeset
|
1353 RoadType rt = (RoadType)FindFirstBit(sub_mode); |
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:
8589
diff
changeset
|
1354 RoadBits bits = GetRoadBits(tile, rt); |
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:
8589
diff
changeset
|
1355 |
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:
8589
diff
changeset
|
1356 /* no roadbit at this side of tile, return 0 */ |
8616
9e46ac001a8c
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch <frosch@openttd.org>
parents:
8603
diff
changeset
|
1357 if (side != INVALID_DIAGDIR && (DiagDirToRoadBits(side) & bits) == 0) break; |
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:
8589
diff
changeset
|
1358 |
6764
6ce333c8fd7e
(svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents:
6761
diff
changeset
|
1359 uint multiplier = drd_to_multiplier[rt == ROADTYPE_TRAM ? DRD_NONE : GetDisallowedRoadDirections(tile)]; |
8616
9e46ac001a8c
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch <frosch@openttd.org>
parents:
8603
diff
changeset
|
1360 if (!HasRoadWorks(tile)) trackdirbits = (TrackdirBits)(_road_trackbits[bits] * multiplier); |
9e46ac001a8c
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch <frosch@openttd.org>
parents:
8603
diff
changeset
|
1361 break; |
6683
6984c0dbbb07
(svn r9914) -Codechange: prepare GTTS and the pathfinders to handle multiple road types on a single tile.
rubidium <rubidium@openttd.org>
parents:
6679
diff
changeset
|
1362 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1363 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1364 case ROAD_TILE_CROSSING: { |
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:
8589
diff
changeset
|
1365 Axis axis = GetCrossingRoadAxis(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
|
1366 |
8616
9e46ac001a8c
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch <frosch@openttd.org>
parents:
8603
diff
changeset
|
1367 if (side != INVALID_DIAGDIR && axis != DiagDirToAxis(side)) break; |
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:
8589
diff
changeset
|
1368 |
8616
9e46ac001a8c
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch <frosch@openttd.org>
parents:
8603
diff
changeset
|
1369 trackdirbits = TrackBitsToTrackdirBits(AxisToTrackBits(axis)); |
9e46ac001a8c
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch <frosch@openttd.org>
parents:
8603
diff
changeset
|
1370 if (IsCrossingBarred(tile)) red_signals = trackdirbits; |
9e46ac001a8c
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch <frosch@openttd.org>
parents:
8603
diff
changeset
|
1371 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
|
1372 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1373 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1374 default: |
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:
8589
diff
changeset
|
1375 case ROAD_TILE_DEPOT: { |
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:
8589
diff
changeset
|
1376 DiagDirection dir = GetRoadDepotDirection(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:
8589
diff
changeset
|
1377 |
8616
9e46ac001a8c
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch <frosch@openttd.org>
parents:
8603
diff
changeset
|
1378 if (side != INVALID_DIAGDIR && side != dir) break; |
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:
8589
diff
changeset
|
1379 |
8616
9e46ac001a8c
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch <frosch@openttd.org>
parents:
8603
diff
changeset
|
1380 trackdirbits = TrackBitsToTrackdirBits(AxisToTrackBits(DiagDirToAxis(dir))); |
9e46ac001a8c
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch <frosch@openttd.org>
parents:
8603
diff
changeset
|
1381 break; |
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:
8589
diff
changeset
|
1382 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1383 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1384 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1385 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1386 default: break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1387 } |
8616
9e46ac001a8c
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch <frosch@openttd.org>
parents:
8603
diff
changeset
|
1388 return CombineTrackStatus(trackdirbits, red_signals); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1389 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1390 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1391 static const StringID _road_tile_strings[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1392 STR_1814_ROAD, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1393 STR_1814_ROAD, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1394 STR_1814_ROAD, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1395 STR_1815_ROAD_WITH_STREETLIGHTS, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1396 STR_1814_ROAD, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1397 STR_1816_TREE_LINED_ROAD, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1398 STR_1814_ROAD, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1399 STR_1814_ROAD, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1400 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1401 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1402 static void GetTileDesc_Road(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
|
1403 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1404 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
|
1405 switch (GetRoadTileType(tile)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1406 case ROAD_TILE_CROSSING: td->str = STR_1818_ROAD_RAIL_LEVEL_CROSSING; break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1407 case ROAD_TILE_DEPOT: td->str = STR_1817_ROAD_VEHICLE_DEPOT; break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1408 default: td->str = _road_tile_strings[GetRoadside(tile)]; break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1409 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1410 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1411 |
6723
331e72ee78e5
(svn r9955) -Codechange: Make _roadveh_enter_depot_unk0 slightly less mysterious.
maedhros <maedhros@openttd.org>
parents:
6719
diff
changeset
|
1412 /** |
331e72ee78e5
(svn r9955) -Codechange: Make _roadveh_enter_depot_unk0 slightly less mysterious.
maedhros <maedhros@openttd.org>
parents:
6719
diff
changeset
|
1413 * Given the direction the road depot is pointing, this is the direction the |
331e72ee78e5
(svn r9955) -Codechange: Make _roadveh_enter_depot_unk0 slightly less mysterious.
maedhros <maedhros@openttd.org>
parents:
6719
diff
changeset
|
1414 * vehicle should be travelling in in order to enter the depot. |
331e72ee78e5
(svn r9955) -Codechange: Make _roadveh_enter_depot_unk0 slightly less mysterious.
maedhros <maedhros@openttd.org>
parents:
6719
diff
changeset
|
1415 */ |
331e72ee78e5
(svn r9955) -Codechange: Make _roadveh_enter_depot_unk0 slightly less mysterious.
maedhros <maedhros@openttd.org>
parents:
6719
diff
changeset
|
1416 static const byte _roadveh_enter_depot_dir[4] = { |
331e72ee78e5
(svn r9955) -Codechange: Make _roadveh_enter_depot_unk0 slightly less mysterious.
maedhros <maedhros@openttd.org>
parents:
6719
diff
changeset
|
1417 TRACKDIR_X_SW, TRACKDIR_Y_NW, TRACKDIR_X_NE, TRACKDIR_Y_SE |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1418 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1419 |
8119
b6ec923e9fa8
(svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium <rubidium@openttd.org>
parents:
8116
diff
changeset
|
1420 static VehicleEnterTileStatus VehicleEnter_Road(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
|
1421 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1422 switch (GetRoadTileType(tile)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1423 case ROAD_TILE_CROSSING: |
8342
441cda3cfbdb
(svn r11908) -Fix: update crossing when merging a company, when building a crossing and after loading older savegame
smatz <smatz@openttd.org>
parents:
8308
diff
changeset
|
1424 if (v->type == VEH_TRAIN) { |
441cda3cfbdb
(svn r11908) -Fix: update crossing when merging a company, when building a crossing and after loading older savegame
smatz <smatz@openttd.org>
parents:
8308
diff
changeset
|
1425 /* it should be barred */ |
441cda3cfbdb
(svn r11908) -Fix: update crossing when merging a company, when building a crossing and after loading older savegame
smatz <smatz@openttd.org>
parents:
8308
diff
changeset
|
1426 assert(IsCrossingBarred(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
|
1427 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1428 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1429 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1430 case ROAD_TILE_DEPOT: |
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:
6256
diff
changeset
|
1431 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
|
1432 v->u.road.frame == 11 && |
6723
331e72ee78e5
(svn r9955) -Codechange: Make _roadveh_enter_depot_unk0 slightly less mysterious.
maedhros <maedhros@openttd.org>
parents:
6719
diff
changeset
|
1433 _roadveh_enter_depot_dir[GetRoadDepotDirection(tile)] == v->u.road.state) { |
6857
0005a9ed1903
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros <maedhros@openttd.org>
parents:
6814
diff
changeset
|
1434 v->u.road.state = RVSB_IN_DEPOT; |
0005a9ed1903
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros <maedhros@openttd.org>
parents:
6814
diff
changeset
|
1435 v->vehstatus |= VS_HIDDEN; |
0005a9ed1903
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros <maedhros@openttd.org>
parents:
6814
diff
changeset
|
1436 v->direction = ReverseDir(v->direction); |
7492
09743324277c
(svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium <rubidium@openttd.org>
parents:
7442
diff
changeset
|
1437 if (v->Next() == NULL) VehicleEnterDepot(v); |
6857
0005a9ed1903
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros <maedhros@openttd.org>
parents:
6814
diff
changeset
|
1438 v->tile = tile; |
0005a9ed1903
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros <maedhros@openttd.org>
parents:
6814
diff
changeset
|
1439 |
0005a9ed1903
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros <maedhros@openttd.org>
parents:
6814
diff
changeset
|
1440 InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile); |
5991
1b793d99b5ba
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium <rubidium@openttd.org>
parents:
5942
diff
changeset
|
1441 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
|
1442 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1443 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1444 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1445 default: break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1446 } |
5991
1b793d99b5ba
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium <rubidium@openttd.org>
parents:
5942
diff
changeset
|
1447 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
|
1448 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1449 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1450 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1451 static void ChangeTileOwner_Road(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
|
1452 { |
8563
992fa65afba1
(svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents:
8560
diff
changeset
|
1453 if (IsRoadDepot(tile)) { |
6717
754723a35f2b
(svn r9949) -Fix: (road) depots got deowned on bankrupts.
rubidium <rubidium@openttd.org>
parents:
6716
diff
changeset
|
1454 if (GetTileOwner(tile) == old_player) { |
754723a35f2b
(svn r9949) -Fix: (road) depots got deowned on bankrupts.
rubidium <rubidium@openttd.org>
parents:
6716
diff
changeset
|
1455 if (new_player == PLAYER_SPECTATOR) { |
8519
0e4b2a37af1f
(svn r12094) -Codechange: use DC_BANKRUPT command flag when removing player property to allow further fixes
smatz <smatz@openttd.org>
parents:
8428
diff
changeset
|
1456 DoCommand(tile, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR); |
6717
754723a35f2b
(svn r9949) -Fix: (road) depots got deowned on bankrupts.
rubidium <rubidium@openttd.org>
parents:
6716
diff
changeset
|
1457 } else { |
754723a35f2b
(svn r9949) -Fix: (road) depots got deowned on bankrupts.
rubidium <rubidium@openttd.org>
parents:
6716
diff
changeset
|
1458 SetTileOwner(tile, new_player); |
754723a35f2b
(svn r9949) -Fix: (road) depots got deowned on bankrupts.
rubidium <rubidium@openttd.org>
parents:
6716
diff
changeset
|
1459 } |
6689
c8daf1a1ec28
(svn r9921) -Fix (r9892): ownership wasn't properly propagated on owner changes.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
1460 } |
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:
6626
diff
changeset
|
1461 return; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1462 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1463 |
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:
6626
diff
changeset
|
1464 for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) { |
8520
c777304e2098
(svn r12095) -Fix [FS#1703]: when a company bankrupts, remove drive-through road stops, ship depots and buoys too. Update owners of water and road.
smatz <smatz@openttd.org>
parents:
8519
diff
changeset
|
1465 /* ROADTYPE_ROAD denotes the tile owner, so update it too */ |
8563
992fa65afba1
(svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents:
8560
diff
changeset
|
1466 if (rt != ROADTYPE_ROAD && !HasTileRoadType(tile, rt)) 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
|
1467 |
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:
6626
diff
changeset
|
1468 if (GetRoadOwner(tile, rt) == old_player) { |
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:
6626
diff
changeset
|
1469 SetRoadOwner(tile, rt, new_player == PLAYER_SPECTATOR ? OWNER_NONE : new_player); |
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:
6626
diff
changeset
|
1470 } |
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:
6626
diff
changeset
|
1471 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1472 |
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:
6626
diff
changeset
|
1473 if (IsLevelCrossing(tile)) { |
6689
c8daf1a1ec28
(svn r9921) -Fix (r9892): ownership wasn't properly propagated on owner changes.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
1474 if (GetTileOwner(tile) == old_player) { |
c8daf1a1ec28
(svn r9921) -Fix (r9892): ownership wasn't properly propagated on owner changes.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
1475 if (new_player == PLAYER_SPECTATOR) { |
8598
ef2c93a9589d
(svn r12179) -Codechange: use GetCrossingRailTrack() and GetCrossingRailAxis() to improve code readability
smatz <smatz@openttd.org>
parents:
8596
diff
changeset
|
1476 DoCommand(tile, 0, GetCrossingRailTrack(tile), DC_EXEC | DC_BANKRUPT, CMD_REMOVE_SINGLE_RAIL); |
6689
c8daf1a1ec28
(svn r9921) -Fix (r9892): ownership wasn't properly propagated on owner changes.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
1477 } else { |
c8daf1a1ec28
(svn r9921) -Fix (r9892): ownership wasn't properly propagated on owner changes.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
1478 SetTileOwner(tile, new_player); |
c8daf1a1ec28
(svn r9921) -Fix (r9892): ownership wasn't properly propagated on owner changes.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
1479 } |
c8daf1a1ec28
(svn r9921) -Fix (r9892): ownership wasn't properly propagated on owner changes.
rubidium <rubidium@openttd.org>
parents:
6683
diff
changeset
|
1480 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1481 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1482 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1483 |
7494
3f6f5fcc079a
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium <rubidium@openttd.org>
parents:
7492
diff
changeset
|
1484 static CommandCost TerraformTile_Road(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:
7492
diff
changeset
|
1485 { |
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:
7539
diff
changeset
|
1486 if (_patches.build_on_slopes && AutoslopeEnabled()) { |
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:
7539
diff
changeset
|
1487 switch (GetRoadTileType(tile)) { |
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:
7539
diff
changeset
|
1488 case ROAD_TILE_CROSSING: |
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
|
1489 if (!IsSteepSlope(tileh_new) && (GetTileMaxZ(tile) == z_new + GetSlopeMaxZ(tileh_new)) && HasBit(VALID_LEVEL_CROSSING_SLOPES, 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:
7539
diff
changeset
|
1490 break; |
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:
7539
diff
changeset
|
1491 |
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:
7539
diff
changeset
|
1492 case ROAD_TILE_DEPOT: |
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
|
1493 if (AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, GetRoadDepotDirection(tile))) 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:
7539
diff
changeset
|
1494 break; |
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:
7539
diff
changeset
|
1495 |
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:
7539
diff
changeset
|
1496 case ROAD_TILE_NORMAL: { |
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:
7539
diff
changeset
|
1497 RoadBits bits = GetAllRoadBits(tile); |
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:
7539
diff
changeset
|
1498 RoadBits bits_copy = bits; |
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:
7539
diff
changeset
|
1499 /* Check if the slope-road_bits combination is valid at all, i.e. it is save to call GetRoadFoundation(). */ |
8744
bcc06c9be6ef
(svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents:
8734
diff
changeset
|
1500 if (!CmdFailed(CheckRoadSlope(tileh_new, &bits_copy, ROAD_NONE, ROAD_NONE))) { |
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:
7539
diff
changeset
|
1501 /* CheckRoadSlope() sometimes changes the road_bits, if it does not agree with them. */ |
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:
7539
diff
changeset
|
1502 if (bits == bits_copy) { |
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:
7539
diff
changeset
|
1503 uint z_old; |
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:
7539
diff
changeset
|
1504 Slope tileh_old = GetTileSlope(tile, &z_old); |
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:
7539
diff
changeset
|
1505 |
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:
7539
diff
changeset
|
1506 /* Get the slope on top of the foundation */ |
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:
7539
diff
changeset
|
1507 z_old += ApplyFoundationToSlope(GetRoadFoundation(tileh_old, bits), &tileh_old); |
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:
7539
diff
changeset
|
1508 z_new += ApplyFoundationToSlope(GetRoadFoundation(tileh_new, bits), &tileh_new); |
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:
7539
diff
changeset
|
1509 |
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:
7539
diff
changeset
|
1510 /* The surface slope must not be changed */ |
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
|
1511 if ((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:
7539
diff
changeset
|
1512 } |
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:
7539
diff
changeset
|
1513 } |
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:
7539
diff
changeset
|
1514 break; |
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:
7539
diff
changeset
|
1515 } |
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:
7539
diff
changeset
|
1516 |
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:
7539
diff
changeset
|
1517 default: NOT_REACHED(); |
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:
7539
diff
changeset
|
1518 } |
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:
7539
diff
changeset
|
1519 } |
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:
7539
diff
changeset
|
1520 |
7494
3f6f5fcc079a
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium <rubidium@openttd.org>
parents:
7492
diff
changeset
|
1521 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:
7492
diff
changeset
|
1522 } |
3f6f5fcc079a
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium <rubidium@openttd.org>
parents:
7492
diff
changeset
|
1523 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1524 |
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
|
1525 extern const TileTypeProcs _tile_type_road_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
|
1526 DrawTile_Road, /* 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
|
1527 GetSlopeZ_Road, /* 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
|
1528 ClearTile_Road, /* 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
|
1529 GetAcceptedCargo_Road, /* 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
|
1530 GetTileDesc_Road, /* 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
|
1531 GetTileTrackStatus_Road, /* 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
|
1532 ClickTile_Road, /* 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
|
1533 AnimateTile_Road, /* 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
|
1534 TileLoop_Road, /* 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
|
1535 ChangeTileOwner_Road, /* 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
|
1536 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
|
1537 VehicleEnter_Road, /* 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
|
1538 GetFoundation_Road, /* 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:
7492
diff
changeset
|
1539 TerraformTile_Road, /* 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
|
1540 }; |