author | rubidium |
Sun, 13 Jan 2008 01:21:35 +0000 | |
changeset 8760 | ce0891c412ce |
parent 8750 | fdd6054e7bae |
child 8793 | b6c63a092c8f |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6443
b8f06d8eb7be
(svn r8853) -Cleanup: doxygen changes. Correct forgotten c files to cpp files with the @file tag as well as a few general comments style
belugas
parents:
6432
diff
changeset
|
3 |
/** @file tunnelbridge_cmd.cpp |
2262
bd59b2d8d75f
(svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
2261
diff
changeset
|
4 |
* This file deals with tunnels and bridges (non-gui stuff) |
bd59b2d8d75f
(svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
2261
diff
changeset
|
5 |
* @todo seperate this file into two |
bd59b2d8d75f
(svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
2261
diff
changeset
|
6 |
*/ |
bd59b2d8d75f
(svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
2261
diff
changeset
|
7 |
|
0 | 8 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1884
diff
changeset
|
9 |
#include "openttd.h" |
3189
1af302c5abd0
(svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
3188
diff
changeset
|
10 |
#include "bridge_map.h" |
3187
0813719b05a9
(svn r3837) Partially unmagicfy restoring the tiles when deleting a bridge
tron
parents:
3184
diff
changeset
|
11 |
#include "rail_map.h" |
3144
426b825578f9
(svn r3763) Adapt to the new 'map accessors go in foo_map.h'-scheme
tron
parents:
3069
diff
changeset
|
12 |
#include "road_map.h" |
8615
6b91ca653bad
(svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
8612
diff
changeset
|
13 |
#include "tile_cmd.h" |
6669
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6585
diff
changeset
|
14 |
#include "landscape.h" |
3154 | 15 |
#include "tunnel_map.h" |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
16 |
#include "unmovable_map.h" |
8720
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8700
diff
changeset
|
17 |
#include "viewport_func.h" |
8612
6414fc21c2f3
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
8610
diff
changeset
|
18 |
#include "command_func.h" |
0 | 19 |
#include "town.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2150
diff
changeset
|
20 |
#include "variables.h" |
2262
bd59b2d8d75f
(svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
2261
diff
changeset
|
21 |
#include "bridge.h" |
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
2663
diff
changeset
|
22 |
#include "train.h" |
3187
0813719b05a9
(svn r3837) Partially unmagicfy restoring the tiles when deleting a bridge
tron
parents:
3184
diff
changeset
|
23 |
#include "water_map.h" |
3900
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3881
diff
changeset
|
24 |
#include "yapf/yapf.h" |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4559
diff
changeset
|
25 |
#include "newgrf_sound.h" |
8078
bdf94bf88568
(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
parents:
8044
diff
changeset
|
26 |
#include "autoslope.h" |
8345
6caa3fdb972c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
8341
diff
changeset
|
27 |
#include "transparency.h" |
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
28 |
#include "tunnelbridge_map.h" |
8610
17cc343a23dd
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8604
diff
changeset
|
29 |
#include "strings_func.h" |
8636
2b158acb649c
(svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents:
8635
diff
changeset
|
30 |
#include "date_func.h" |
8627
448ebf3a8291
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8615
diff
changeset
|
31 |
#include "functions.h" |
8640
1e93b81e96d2
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents:
8636
diff
changeset
|
32 |
#include "vehicle_func.h" |
8653
a83f7a536919
(svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium
parents:
8640
diff
changeset
|
33 |
#include "sound_func.h" |
8734
b7fc8c6fd379
(svn r11802) -Fix [FS#716]: do not crash trains when leaving depot to a very long track
smatz
parents:
8732
diff
changeset
|
34 |
#include "signal_func.h" |
0 | 35 |
|
8760
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
36 |
#include "table/sprites.h" |
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
37 |
#include "table/strings.h" |
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
38 |
#include "table/bridge_land.h" |
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2260
diff
changeset
|
39 |
|
2478
16b05f1de6bb
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2436
diff
changeset
|
40 |
const Bridge orig_bridge[] = { |
2262
bd59b2d8d75f
(svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
2261
diff
changeset
|
41 |
/* |
4293
2c24234a7aec
(svn r5926) -Codechange: make _cur_year contain the full year, instead of the offset since 1920
rubidium
parents:
4291
diff
changeset
|
42 |
year of availablity |
2c24234a7aec
(svn r5926) -Codechange: make _cur_year contain the full year, instead of the offset since 1920
rubidium
parents:
4291
diff
changeset
|
43 |
| minimum length |
2c24234a7aec
(svn r5926) -Codechange: make _cur_year contain the full year, instead of the offset since 1920
rubidium
parents:
4291
diff
changeset
|
44 |
| | maximum length |
2c24234a7aec
(svn r5926) -Codechange: make _cur_year contain the full year, instead of the offset since 1920
rubidium
parents:
4291
diff
changeset
|
45 |
| | | price |
2c24234a7aec
(svn r5926) -Codechange: make _cur_year contain the full year, instead of the offset since 1920
rubidium
parents:
4291
diff
changeset
|
46 |
| | | | maximum speed |
2c24234a7aec
(svn r5926) -Codechange: make _cur_year contain the full year, instead of the offset since 1920
rubidium
parents:
4291
diff
changeset
|
47 |
| | | | | sprite to use in GUI string with description |
2c24234a7aec
(svn r5926) -Codechange: make _cur_year contain the full year, instead of the offset since 1920
rubidium
parents:
4291
diff
changeset
|
48 |
| | | | | | | */ |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
49 |
{ 0, 0, 16, 80, 32, 0xA24, PAL_NONE , STR_5012_WOODEN , NULL, 0 }, |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
50 |
{ 0, 0, 2, 112, 48, 0xA26, PALETTE_TO_STRUCT_RED , STR_5013_CONCRETE , NULL, 0 }, |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
51 |
{ 1930, 0, 5, 144, 64, 0xA25, PAL_NONE , STR_500F_GIRDER_STEEL , NULL, 0 }, |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
52 |
{ 0, 2, 10, 168, 80, 0xA22, PALETTE_TO_STRUCT_CONCRETE, STR_5011_SUSPENSION_CONCRETE, NULL, 0 }, |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
53 |
{ 1930, 3, 16, 185, 96, 0xA22, PAL_NONE , STR_500E_SUSPENSION_STEEL , NULL, 0 }, |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
54 |
{ 1930, 3, 16, 192, 112, 0xA22, PALETTE_TO_STRUCT_YELLOW , STR_500E_SUSPENSION_STEEL , NULL, 0 }, |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
55 |
{ 1930, 3, 7, 224, 160, 0xA23, PAL_NONE , STR_5010_CANTILEVER_STEEL , NULL, 0 }, |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
56 |
{ 1930, 3, 8, 232, 208, 0xA23, PALETTE_TO_STRUCT_BROWN , STR_5010_CANTILEVER_STEEL , NULL, 0 }, |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
57 |
{ 1930, 3, 9, 248, 240, 0xA23, PALETTE_TO_STRUCT_RED , STR_5010_CANTILEVER_STEEL , NULL, 0 }, |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
58 |
{ 1930, 0, 2, 240, 256, 0xA27, PAL_NONE , STR_500F_GIRDER_STEEL , NULL, 0 }, |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
59 |
{ 1995, 2, 16, 255, 320, 0xA28, PAL_NONE , STR_5014_TUBULAR_STEEL , NULL, 0 }, |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
60 |
{ 2005, 2, 32, 380, 512, 0xA28, PALETTE_TO_STRUCT_YELLOW , STR_5014_TUBULAR_STEEL , NULL, 0 }, |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
61 |
{ 2010, 2, 32, 510, 608, 0xA28, PALETTE_TO_STRUCT_GREY , STR_BRIDGE_TUBULAR_SILICON , NULL, 0 } |
0 | 62 |
}; |
63 |
||
2763 | 64 |
Bridge _bridge[MAX_BRIDGES]; |
65 |
||
66 |
||
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6902
diff
changeset
|
67 |
/** calculate the price factor for building a long bridge. |
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6902
diff
changeset
|
68 |
* basically the cost delta is 1,1, 1, 2,2, 3,3,3, 4,4,4,4, 5,5,5,5,5, 6,6,6,6,6,6, 7,7,7,7,7,7,7, 8,8,8,8,8,8,8,8, |
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6902
diff
changeset
|
69 |
*/ |
0 | 70 |
int CalcBridgeLenCostFactor(int x) |
71 |
{ |
|
2639 | 72 |
int n; |
73 |
int r; |
|
74 |
||
0 | 75 |
if (x < 2) return x; |
76 |
x -= 2; |
|
2639 | 77 |
for (n = 0, r = 2;; n++) { |
0 | 78 |
if (x <= n) return r + x * n; |
79 |
r += n * n; |
|
80 |
x -= n; |
|
81 |
} |
|
82 |
} |
|
83 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3556
diff
changeset
|
84 |
#define M(x) (1 << (x)) |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6539
diff
changeset
|
85 |
enum BridgeFoundation { |
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6902
diff
changeset
|
86 |
/* foundation, whole tile is leveled up --> 3 corners raised */ |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3556
diff
changeset
|
87 |
BRIDGE_FULL_LEVELED_FOUNDATION = M(SLOPE_WSE) | M(SLOPE_NWS) | M(SLOPE_ENW) | M(SLOPE_SEN), |
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6902
diff
changeset
|
88 |
/* foundation, tile is partly leveled up --> 1 corner raised */ |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3556
diff
changeset
|
89 |
BRIDGE_PARTLY_LEVELED_FOUNDATION = M(SLOPE_W) | M(SLOPE_S) | M(SLOPE_E) | M(SLOPE_N), |
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6902
diff
changeset
|
90 |
/* no foundations (X,Y direction) */ |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3556
diff
changeset
|
91 |
BRIDGE_NO_FOUNDATION = M(SLOPE_FLAT) | M(SLOPE_SW) | M(SLOPE_SE) | M(SLOPE_NW) | M(SLOPE_NE), |
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3556
diff
changeset
|
92 |
BRIDGE_HORZ_RAMP = (BRIDGE_PARTLY_LEVELED_FOUNDATION | BRIDGE_NO_FOUNDATION) & ~M(SLOPE_FLAT) |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6539
diff
changeset
|
93 |
}; |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3556
diff
changeset
|
94 |
#undef M |
0 | 95 |
|
2478
16b05f1de6bb
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2436
diff
changeset
|
96 |
static inline const PalSpriteID *GetBridgeSpriteTable(int index, byte table) |
16b05f1de6bb
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2436
diff
changeset
|
97 |
{ |
16b05f1de6bb
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2436
diff
changeset
|
98 |
const Bridge *bridge = &_bridge[index]; |
16b05f1de6bb
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2436
diff
changeset
|
99 |
assert(table < 7); |
16b05f1de6bb
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2436
diff
changeset
|
100 |
if (bridge->sprite_table == NULL || bridge->sprite_table[table] == NULL) { |
16b05f1de6bb
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2436
diff
changeset
|
101 |
return _bridge_sprite_table[index][table]; |
16b05f1de6bb
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2436
diff
changeset
|
102 |
} else { |
16b05f1de6bb
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2436
diff
changeset
|
103 |
return bridge->sprite_table[table]; |
16b05f1de6bb
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2436
diff
changeset
|
104 |
} |
16b05f1de6bb
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2436
diff
changeset
|
105 |
} |
16b05f1de6bb
(svn r3004) -Feature, NewGRF: Support loading of bridge attributes and tables from GRF. Currently drawing tall pillars uses old data.
peter1138
parents:
2436
diff
changeset
|
106 |
|
3556
d25b35568c48
(svn r4430) - NewGRF: Use the bridge's sprite layout for drawing high pillars. This fixes newgrf's high-bridge pillars drawing. Also remove the now obsolete _bridge_poles_table which was already integrated into the bridge sprite tables
Darkvater
parents:
3539
diff
changeset
|
107 |
static inline byte GetBridgeFlags(int index) { return _bridge[index].flags;} |
2262
bd59b2d8d75f
(svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
2261
diff
changeset
|
108 |
|
0 | 109 |
|
4239
9ec74a9b8b58
(svn r5809) Turn the tests for valid bridge ramp slopes into something comprehensible
tron
parents:
4231
diff
changeset
|
110 |
/** Check the slope at the bridge ramps in three easy steps: |
9ec74a9b8b58
(svn r5809) Turn the tests for valid bridge ramp slopes into something comprehensible
tron
parents:
4231
diff
changeset
|
111 |
* - valid slopes without foundation |
9ec74a9b8b58
(svn r5809) Turn the tests for valid bridge ramp slopes into something comprehensible
tron
parents:
4231
diff
changeset
|
112 |
* - valid slopes with foundation |
9ec74a9b8b58
(svn r5809) Turn the tests for valid bridge ramp slopes into something comprehensible
tron
parents:
4231
diff
changeset
|
113 |
* - rest is invalid |
9ec74a9b8b58
(svn r5809) Turn the tests for valid bridge ramp slopes into something comprehensible
tron
parents:
4231
diff
changeset
|
114 |
*/ |
9ec74a9b8b58
(svn r5809) Turn the tests for valid bridge ramp slopes into something comprehensible
tron
parents:
4231
diff
changeset
|
115 |
#define M(x) (1 << (x)) |
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7353
diff
changeset
|
116 |
static CommandCost CheckBridgeSlopeNorth(Axis axis, Slope tileh) |
4239
9ec74a9b8b58
(svn r5809) Turn the tests for valid bridge ramp slopes into something comprehensible
tron
parents:
4231
diff
changeset
|
117 |
{ |
9ec74a9b8b58
(svn r5809) Turn the tests for valid bridge ramp slopes into something comprehensible
tron
parents:
4231
diff
changeset
|
118 |
uint32 valid; |
0 | 119 |
|
4239
9ec74a9b8b58
(svn r5809) Turn the tests for valid bridge ramp slopes into something comprehensible
tron
parents:
4231
diff
changeset
|
120 |
valid = M(SLOPE_FLAT) | (axis == AXIS_X ? M(SLOPE_NE) : M(SLOPE_NW)); |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8419
diff
changeset
|
121 |
if (HasBit(valid, tileh)) return CommandCost(); |
0 | 122 |
|
4239
9ec74a9b8b58
(svn r5809) Turn the tests for valid bridge ramp slopes into something comprehensible
tron
parents:
4231
diff
changeset
|
123 |
valid = |
4246
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4239
diff
changeset
|
124 |
BRIDGE_FULL_LEVELED_FOUNDATION | M(SLOPE_N) | M(SLOPE_STEEP_N) | |
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4239
diff
changeset
|
125 |
(axis == AXIS_X ? M(SLOPE_E) | M(SLOPE_STEEP_E) : M(SLOPE_W) | M(SLOPE_STEEP_W)); |
8726
5ae45b46506b
(svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium
parents:
8720
diff
changeset
|
126 |
if (HasBit(valid, tileh)) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); |
2639 | 127 |
|
0 | 128 |
return CMD_ERROR; |
129 |
} |
|
130 |
||
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7353
diff
changeset
|
131 |
static CommandCost CheckBridgeSlopeSouth(Axis axis, Slope tileh) |
4239
9ec74a9b8b58
(svn r5809) Turn the tests for valid bridge ramp slopes into something comprehensible
tron
parents:
4231
diff
changeset
|
132 |
{ |
9ec74a9b8b58
(svn r5809) Turn the tests for valid bridge ramp slopes into something comprehensible
tron
parents:
4231
diff
changeset
|
133 |
uint32 valid; |
9ec74a9b8b58
(svn r5809) Turn the tests for valid bridge ramp slopes into something comprehensible
tron
parents:
4231
diff
changeset
|
134 |
|
9ec74a9b8b58
(svn r5809) Turn the tests for valid bridge ramp slopes into something comprehensible
tron
parents:
4231
diff
changeset
|
135 |
valid = M(SLOPE_FLAT) | (axis == AXIS_X ? M(SLOPE_SW) : M(SLOPE_SE)); |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8419
diff
changeset
|
136 |
if (HasBit(valid, tileh)) return CommandCost(); |
4239
9ec74a9b8b58
(svn r5809) Turn the tests for valid bridge ramp slopes into something comprehensible
tron
parents:
4231
diff
changeset
|
137 |
|
9ec74a9b8b58
(svn r5809) Turn the tests for valid bridge ramp slopes into something comprehensible
tron
parents:
4231
diff
changeset
|
138 |
valid = |
4246
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4239
diff
changeset
|
139 |
BRIDGE_FULL_LEVELED_FOUNDATION | M(SLOPE_S) | M(SLOPE_STEEP_S) | |
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4239
diff
changeset
|
140 |
(axis == AXIS_X ? M(SLOPE_W) | M(SLOPE_STEEP_W) : M(SLOPE_E) | M(SLOPE_STEEP_E)); |
8726
5ae45b46506b
(svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium
parents:
8720
diff
changeset
|
141 |
if (HasBit(valid, tileh)) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); |
4239
9ec74a9b8b58
(svn r5809) Turn the tests for valid bridge ramp slopes into something comprehensible
tron
parents:
4231
diff
changeset
|
142 |
|
9ec74a9b8b58
(svn r5809) Turn the tests for valid bridge ramp slopes into something comprehensible
tron
parents:
4231
diff
changeset
|
143 |
return CMD_ERROR; |
9ec74a9b8b58
(svn r5809) Turn the tests for valid bridge ramp slopes into something comprehensible
tron
parents:
4231
diff
changeset
|
144 |
} |
9ec74a9b8b58
(svn r5809) Turn the tests for valid bridge ramp slopes into something comprehensible
tron
parents:
4231
diff
changeset
|
145 |
#undef M |
9ec74a9b8b58
(svn r5809) Turn the tests for valid bridge ramp slopes into something comprehensible
tron
parents:
4231
diff
changeset
|
146 |
|
9ec74a9b8b58
(svn r5809) Turn the tests for valid bridge ramp slopes into something comprehensible
tron
parents:
4231
diff
changeset
|
147 |
|
0 | 148 |
uint32 GetBridgeLength(TileIndex begin, TileIndex end) |
149 |
{ |
|
2639 | 150 |
int x1 = TileX(begin); |
151 |
int y1 = TileY(begin); |
|
152 |
int x2 = TileX(end); |
|
153 |
int y2 = TileY(end); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
154 |
|
2639 | 155 |
return abs(x2 + y2 - x1 - y1) - 1; |
0 | 156 |
} |
157 |
||
2639 | 158 |
bool CheckBridge_Stuff(byte bridge_type, uint bridge_len) |
0 | 159 |
{ |
2262
bd59b2d8d75f
(svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
2261
diff
changeset
|
160 |
const Bridge *b = &_bridge[bridge_type]; |
2639 | 161 |
uint max; // max possible length of a bridge (with patch 100) |
0 | 162 |
|
1781
92e08797c84b
(svn r2285) - Codechange: Fix up some of the missing things from server-checking; namely bridge-type, bridge-length, dragged end-tile (bridge/station), station_spread
Darkvater
parents:
1775
diff
changeset
|
163 |
if (bridge_type >= MAX_BRIDGES) return false; |
2262
bd59b2d8d75f
(svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
2261
diff
changeset
|
164 |
if (b->avail_year > _cur_year) return false; |
0 | 165 |
|
2262
bd59b2d8d75f
(svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
2261
diff
changeset
|
166 |
max = b->max_length; |
2639 | 167 |
if (max >= 16 && _patches.longbridges) max = 100; |
0 | 168 |
|
2639 | 169 |
return b->min_length <= bridge_len && bridge_len <= max; |
0 | 170 |
} |
171 |
||
1775
08ff0f12ccdc
(svn r2279) - Fix: Check the parameters of the first 10 Commands. While there also add proper comments for the functions and fix up CmdFailed()
Darkvater
parents:
1587
diff
changeset
|
172 |
/** Build a Bridge |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3435
diff
changeset
|
173 |
* @param end_tile end tile |
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6902
diff
changeset
|
174 |
* @param flags type of operation |
1775
08ff0f12ccdc
(svn r2279) - Fix: Check the parameters of the first 10 Commands. While there also add proper comments for the functions and fix up CmdFailed()
Darkvater
parents:
1587
diff
changeset
|
175 |
* @param p1 packed start tile coords (~ dx) |
08ff0f12ccdc
(svn r2279) - Fix: Check the parameters of the first 10 Commands. While there also add proper comments for the functions and fix up CmdFailed()
Darkvater
parents:
1587
diff
changeset
|
176 |
* @param p2 various bitstuffed elements |
08ff0f12ccdc
(svn r2279) - Fix: Check the parameters of the first 10 Commands. While there also add proper comments for the functions and fix up CmdFailed()
Darkvater
parents:
1587
diff
changeset
|
177 |
* - p2 = (bit 0- 7) - bridge type (hi bh) |
7157
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7033
diff
changeset
|
178 |
* - p2 = (bit 8-..) - rail type or road types. |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7033
diff
changeset
|
179 |
* - p2 = (bit 15 ) - set means road bridge. |
0 | 180 |
*/ |
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7353
diff
changeset
|
181 |
CommandCost CmdBuildBridge(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 182 |
{ |
6181
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
183 |
uint bridge_type; |
3180
2123f8062a2d
(svn r3820) Be a bit more strict with types: use special types instead of generic byte and don't fill arbitrary data into inappropriate types
tron
parents:
3178
diff
changeset
|
184 |
RailType railtype; |
7157
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7033
diff
changeset
|
185 |
RoadTypes roadtypes; |
3853
c49992ab497b
(svn r4881) -Codechange: Be a little more strict about types and remove some null-operations
celestar
parents:
3794
diff
changeset
|
186 |
uint x; |
c49992ab497b
(svn r4881) -Codechange: Be a little more strict about types and remove some null-operations
celestar
parents:
3794
diff
changeset
|
187 |
uint y; |
c49992ab497b
(svn r4881) -Codechange: Be a little more strict about types and remove some null-operations
celestar
parents:
3794
diff
changeset
|
188 |
uint sx; |
c49992ab497b
(svn r4881) -Codechange: Be a little more strict about types and remove some null-operations
celestar
parents:
3794
diff
changeset
|
189 |
uint sy; |
3301
4ac662c79ad3
(svn r4047) Remove two calls to FindLandscapeHeight() and some confusing use of the comma operator
tron
parents:
3267
diff
changeset
|
190 |
TileIndex tile_start; |
4ac662c79ad3
(svn r4047) Remove two calls to FindLandscapeHeight() and some confusing use of the comma operator
tron
parents:
3267
diff
changeset
|
191 |
TileIndex tile_end; |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3556
diff
changeset
|
192 |
Slope tileh_start; |
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3556
diff
changeset
|
193 |
Slope tileh_end; |
3301
4ac662c79ad3
(svn r4047) Remove two calls to FindLandscapeHeight() and some confusing use of the comma operator
tron
parents:
3267
diff
changeset
|
194 |
uint z_start; |
4ac662c79ad3
(svn r4047) Remove two calls to FindLandscapeHeight() and some confusing use of the comma operator
tron
parents:
3267
diff
changeset
|
195 |
uint z_end; |
3178
c275826135da
(svn r3814) Remove another call to FindLandscapeHeight()
tron
parents:
3172
diff
changeset
|
196 |
TileIndex tile; |
c275826135da
(svn r3814) Remove another call to FindLandscapeHeight()
tron
parents:
3172
diff
changeset
|
197 |
TileIndexDiff delta; |
2639 | 198 |
uint bridge_len; |
3157
40de8616c04c
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3156
diff
changeset
|
199 |
Axis direction; |
8726
5ae45b46506b
(svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium
parents:
8720
diff
changeset
|
200 |
CommandCost cost(EXPENSES_CONSTRUCTION); |
5ae45b46506b
(svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium
parents:
8720
diff
changeset
|
201 |
CommandCost terraformcost, ret; |
1585
3dc279e97623
(svn r2089) - Codechange: Simplify slopes check in CmdBuildBridge(). Inspired by st3wis' patch 1144746.
pasky
parents:
1562
diff
changeset
|
202 |
bool allow_on_slopes; |
6181
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
203 |
bool replace_bridge = false; |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
204 |
uint replaced_bridge_type; |
0 | 205 |
|
206 |
/* unpack parameters */ |
|
2140
d708eb80ab8b
(svn r2650) Convert many explicit shifts+ands to extract bits to invocations of GB - should be a bit nicer to read
tron
parents:
2133
diff
changeset
|
207 |
bridge_type = GB(p2, 0, 8); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
208 |
|
2934
3b7eef9871f8
(svn r3490) -Fix: A bunch (10) of off-by-one errors when checking if a TileIndex points to a tile on the map
tron
parents:
2931
diff
changeset
|
209 |
if (p1 >= MapSize()) return CMD_ERROR; |
1775
08ff0f12ccdc
(svn r2279) - Fix: Check the parameters of the first 10 Commands. While there also add proper comments for the functions and fix up CmdFailed()
Darkvater
parents:
1587
diff
changeset
|
210 |
|
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6902
diff
changeset
|
211 |
/* type of bridge */ |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8419
diff
changeset
|
212 |
if (HasBit(p2, 15)) { |
6103 | 213 |
railtype = INVALID_RAILTYPE; // road bridge |
7159
aec2b7823dc6
(svn r9894) -Fix (r9892): catenary was drawn on road bridges ;)
rubidium
parents:
7157
diff
changeset
|
214 |
roadtypes = (RoadTypes)GB(p2, 8, 3); |
8353
49a1d9b9d937
(svn r11407) -Fix: do not allow building of tram-tracks when they are not available (SmatZ)
truelight
parents:
8345
diff
changeset
|
215 |
if (!AreValidRoadTypes(roadtypes) || !HasRoadTypesAvail(_current_player, roadtypes)) return CMD_ERROR; |
0 | 216 |
} else { |
8732
b18f578f7c16
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8728
diff
changeset
|
217 |
if (!ValParamRailtype((RailType)GB(p2, 8, 8))) return CMD_ERROR; |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
218 |
railtype = (RailType)GB(p2, 8, 8); |
7159
aec2b7823dc6
(svn r9894) -Fix (r9892): catenary was drawn on road bridges ;)
rubidium
parents:
7157
diff
changeset
|
219 |
roadtypes = ROADTYPES_NONE; |
0 | 220 |
} |
221 |
||
3493
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
222 |
x = TileX(end_tile); |
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
223 |
y = TileY(end_tile); |
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
224 |
sx = TileX(p1); |
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
225 |
sy = TileY(p1); |
0 | 226 |
|
227 |
/* check if valid, and make sure that (x,y) are smaller than (sx,sy) */ |
|
228 |
if (x == sx) { |
|
2639 | 229 |
if (y == sy) return_cmd_error(STR_5008_CANNOT_START_AND_END_ON); |
3157
40de8616c04c
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3156
diff
changeset
|
230 |
direction = AXIS_Y; |
6432 | 231 |
if (y > sy) Swap(y, sy); |
0 | 232 |
} else if (y == sy) { |
3157
40de8616c04c
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3156
diff
changeset
|
233 |
direction = AXIS_X; |
6432 | 234 |
if (x > sx) Swap(x, sx); |
2639 | 235 |
} else { |
0 | 236 |
return_cmd_error(STR_500A_START_AND_END_MUST_BE_IN); |
2639 | 237 |
} |
0 | 238 |
|
1781
92e08797c84b
(svn r2285) - Codechange: Fix up some of the missing things from server-checking; namely bridge-type, bridge-length, dragged end-tile (bridge/station), station_spread
Darkvater
parents:
1775
diff
changeset
|
239 |
/* set and test bridge length, availability */ |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3996
diff
changeset
|
240 |
bridge_len = sx + sy - x - y - 1; |
1781
92e08797c84b
(svn r2285) - Codechange: Fix up some of the missing things from server-checking; namely bridge-type, bridge-length, dragged end-tile (bridge/station), station_spread
Darkvater
parents:
1775
diff
changeset
|
241 |
if (!CheckBridge_Stuff(bridge_type, bridge_len)) return_cmd_error(STR_5015_CAN_T_BUILD_BRIDGE_HERE); |
92e08797c84b
(svn r2285) - Codechange: Fix up some of the missing things from server-checking; namely bridge-type, bridge-length, dragged end-tile (bridge/station), station_spread
Darkvater
parents:
1775
diff
changeset
|
242 |
|
0 | 243 |
/* retrieve landscape height and ensure it's on land */ |
3493
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
244 |
tile_start = TileXY(x, y); |
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
245 |
tile_end = TileXY(sx, sy); |
8235
fc75e5ad02b6
(svn r11276) -Codechange: be more consistent with naming of some accessors.
rubidium
parents:
8226
diff
changeset
|
246 |
if (IsWaterTile(tile_start) || IsWaterTile(tile_end)) { |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3996
diff
changeset
|
247 |
return_cmd_error(STR_02A0_ENDS_OF_BRIDGE_MUST_BOTH); |
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3996
diff
changeset
|
248 |
} |
0 | 249 |
|
3301
4ac662c79ad3
(svn r4047) Remove two calls to FindLandscapeHeight() and some confusing use of the comma operator
tron
parents:
3267
diff
changeset
|
250 |
tileh_start = GetTileSlope(tile_start, &z_start); |
4ac662c79ad3
(svn r4047) Remove two calls to FindLandscapeHeight() and some confusing use of the comma operator
tron
parents:
3267
diff
changeset
|
251 |
tileh_end = GetTileSlope(tile_end, &z_end); |
4ac662c79ad3
(svn r4047) Remove two calls to FindLandscapeHeight() and some confusing use of the comma operator
tron
parents:
3267
diff
changeset
|
252 |
|
4246
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4239
diff
changeset
|
253 |
if (IsSteepSlope(tileh_start)) z_start += TILE_HEIGHT; |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8419
diff
changeset
|
254 |
if (HasBit(BRIDGE_FULL_LEVELED_FOUNDATION, tileh_start)) z_start += TILE_HEIGHT; |
0 | 255 |
|
4246
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4239
diff
changeset
|
256 |
if (IsSteepSlope(tileh_end)) z_end += TILE_HEIGHT; |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8419
diff
changeset
|
257 |
if (HasBit(BRIDGE_FULL_LEVELED_FOUNDATION, tileh_end)) z_end += TILE_HEIGHT; |
0 | 258 |
|
8178
85fdbc7ffa9f
(svn r11213) -Fix [FS#1298]: confusing messages when trying to build a bridge.
rubidium
parents:
8173
diff
changeset
|
259 |
if (z_start != z_end) return_cmd_error(STR_BRIDGEHEADS_NOT_SAME_HEIGHT); |
1585
3dc279e97623
(svn r2089) - Codechange: Simplify slopes check in CmdBuildBridge(). Inspired by st3wis' patch 1144746.
pasky
parents:
1562
diff
changeset
|
260 |
|
2422
914a12dee832
(svn r2948) -Fix: the old AI needs a special flag that triggers all kind of special
truelight
parents:
2314
diff
changeset
|
261 |
allow_on_slopes = (!_is_old_ai_player |
8341
a7fef35fe38b
(svn r11395) -Fix: allow town-bridges to be build on slopes (Rafal Rzepecki)
truelight
parents:
8254
diff
changeset
|
262 |
&& _patches.build_on_slopes); |
1585
3dc279e97623
(svn r2089) - Codechange: Simplify slopes check in CmdBuildBridge(). Inspired by st3wis' patch 1144746.
pasky
parents:
1562
diff
changeset
|
263 |
|
6181
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
264 |
TransportType transport_type = railtype == INVALID_RAILTYPE ? TRANSPORT_ROAD : TRANSPORT_RAIL; |
0 | 265 |
|
6181
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
266 |
if (IsBridgeTile(tile_start) && IsBridgeTile(tile_end) && |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
267 |
GetOtherBridgeEnd(tile_start) == tile_end && |
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
268 |
GetTunnelBridgeTransportType(tile_start) == transport_type) { |
6181
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
269 |
/* Replace a current bridge. */ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
270 |
|
6181
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
271 |
/* If this is a railway bridge, make sure the railtypes match. */ |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
272 |
if (transport_type == TRANSPORT_RAIL && GetRailType(tile_start) != railtype) { |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
273 |
return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
274 |
} |
0 | 275 |
|
6181
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
276 |
/* Do not replace town bridges with lower speed bridges. */ |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
277 |
if (!(flags & DC_QUERY_COST) && IsTileOwner(tile_start, OWNER_TOWN) && |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
278 |
_bridge[bridge_type].speed < _bridge[GetBridgeType(tile_start)].speed) { |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
279 |
Town *t = ClosestTownFromTile(tile_start, UINT_MAX); |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
280 |
|
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
281 |
if (t == NULL) { |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
282 |
return CMD_ERROR; |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
283 |
} else { |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
284 |
SetDParam(0, t->index); |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
285 |
return_cmd_error(STR_2009_LOCAL_AUTHORITY_REFUSES); |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
286 |
} |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
287 |
} |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
288 |
|
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
289 |
/* Do not replace the bridge with the same bridge type. */ |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
290 |
if (!(flags & DC_QUERY_COST) && bridge_type == GetBridgeType(tile_start)) { |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
291 |
return_cmd_error(STR_1007_ALREADY_BUILT); |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
292 |
} |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
293 |
|
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
294 |
/* Do not allow replacing another player's bridges. */ |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
295 |
if (!IsTileOwner(tile_start, _current_player) && !IsTileOwner(tile_start, OWNER_TOWN)) { |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
296 |
return_cmd_error(STR_1024_AREA_IS_OWNED_BY_ANOTHER); |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
297 |
} |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
298 |
|
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
299 |
cost.AddCost((bridge_len + 1) * _price.clear_bridge); // The cost of clearing the current bridge. |
6181
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
300 |
replace_bridge = true; |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
301 |
replaced_bridge_type = GetBridgeType(tile_start); |
7204
7a9f8ded0504
(svn r9940) -Fix [FS#805]: upgrading a bridge removed roadtypes.
rubidium
parents:
7195
diff
changeset
|
302 |
|
7a9f8ded0504
(svn r9940) -Fix [FS#805]: upgrading a bridge removed roadtypes.
rubidium
parents:
7195
diff
changeset
|
303 |
/* Do not remove road types when upgrading a bridge */ |
7a9f8ded0504
(svn r9940) -Fix [FS#805]: upgrading a bridge removed roadtypes.
rubidium
parents:
7195
diff
changeset
|
304 |
roadtypes |= GetRoadTypes(tile_start); |
6181
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
305 |
} else { |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
306 |
/* Build a new bridge. */ |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
307 |
|
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
308 |
/* Try and clear the start landscape */ |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
309 |
ret = DoCommand(tile_start, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
310 |
if (CmdFailed(ret)) return ret; |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
311 |
cost = ret; |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
312 |
|
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
313 |
terraformcost = CheckBridgeSlopeNorth(direction, tileh_start); |
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
314 |
if (CmdFailed(terraformcost) || (terraformcost.GetCost() != 0 && !allow_on_slopes)) |
6181
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
315 |
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
316 |
cost.AddCost(terraformcost); |
6181
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
317 |
|
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
318 |
/* Try and clear the end landscape */ |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
319 |
ret = DoCommand(tile_end, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
320 |
if (CmdFailed(ret)) return ret; |
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
321 |
cost.AddCost(ret); |
6181
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
322 |
|
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6902
diff
changeset
|
323 |
/* false - end tile slope check */ |
6181
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
324 |
terraformcost = CheckBridgeSlopeSouth(direction, tileh_end); |
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
325 |
if (CmdFailed(terraformcost) || (terraformcost.GetCost() != 0 && !allow_on_slopes)) |
6181
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
326 |
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
327 |
cost.AddCost(terraformcost); |
6181
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
328 |
} |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
329 |
|
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
330 |
if (!replace_bridge) { |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
331 |
TileIndex Heads[] = {tile_start, tile_end}; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
332 |
int i; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
333 |
|
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
334 |
for (i = 0; i < 2; i++) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
335 |
if (MayHaveBridgeAbove(Heads[i])) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
336 |
if (IsBridgeAbove(Heads[i])) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
337 |
TileIndex north_head = GetNorthernBridgeEnd(Heads[i]); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
338 |
|
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
339 |
if (direction == GetBridgeAxis(Heads[i])) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
340 |
|
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
341 |
if (z_start + TILE_HEIGHT == GetBridgeHeight(north_head)) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
342 |
return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
343 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
344 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
345 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
346 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
347 |
} |
0 | 348 |
|
349 |
/* do the drill? */ |
|
350 |
if (flags & DC_EXEC) { |
|
3209
e0b7d48351a3
(svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents:
3196
diff
changeset
|
351 |
DiagDirection dir = AxisToDiagDir(direction); |
6181
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
352 |
Owner owner = (replace_bridge && IsTileOwner(tile_start, OWNER_TOWN)) ? OWNER_TOWN : _current_player; |
0 | 353 |
|
6103 | 354 |
if (railtype != INVALID_RAILTYPE) { |
6181
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
355 |
MakeRailBridgeRamp(tile_start, owner, bridge_type, dir, railtype); |
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
356 |
MakeRailBridgeRamp(tile_end, owner, bridge_type, ReverseDiagDir(dir), railtype); |
3209
e0b7d48351a3
(svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents:
3196
diff
changeset
|
357 |
} else { |
7157
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7033
diff
changeset
|
358 |
MakeRoadBridgeRamp(tile_start, owner, bridge_type, dir, roadtypes); |
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7033
diff
changeset
|
359 |
MakeRoadBridgeRamp(tile_end, owner, bridge_type, ReverseDiagDir(dir), roadtypes); |
3209
e0b7d48351a3
(svn r3877) Add functions to turn a tile into a rail/road bridge ramp/middle part
tron
parents:
3196
diff
changeset
|
360 |
} |
3301
4ac662c79ad3
(svn r4047) Remove two calls to FindLandscapeHeight() and some confusing use of the comma operator
tron
parents:
3267
diff
changeset
|
361 |
MarkTileDirtyByTile(tile_start); |
4ac662c79ad3
(svn r4047) Remove two calls to FindLandscapeHeight() and some confusing use of the comma operator
tron
parents:
3267
diff
changeset
|
362 |
MarkTileDirtyByTile(tile_end); |
0 | 363 |
} |
364 |
||
3178
c275826135da
(svn r3814) Remove another call to FindLandscapeHeight()
tron
parents:
3172
diff
changeset
|
365 |
delta = (direction == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1)); |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
366 |
for (tile = tile_start + delta; tile != tile_end; tile += delta) { |
3178
c275826135da
(svn r3814) Remove another call to FindLandscapeHeight()
tron
parents:
3172
diff
changeset
|
367 |
uint z; |
0 | 368 |
|
8178
85fdbc7ffa9f
(svn r11213) -Fix [FS#1298]: confusing messages when trying to build a bridge.
rubidium
parents:
8173
diff
changeset
|
369 |
if (GetTileSlope(tile, &z) != SLOPE_FLAT && z >= z_start) return_cmd_error(STR_BRIDGE_TOO_LOW_FOR_TERRAIN); |
0 | 370 |
|
6181
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
371 |
if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile) && !replace_bridge) { |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
372 |
/* Disallow crossing bridges for the time being */ |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
373 |
return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
3183
cf71bd234ebd
(svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents:
3181
diff
changeset
|
374 |
} |
0 | 375 |
|
3178
c275826135da
(svn r3814) Remove another call to FindLandscapeHeight()
tron
parents:
3172
diff
changeset
|
376 |
switch (GetTileType(tile)) { |
3065 | 377 |
case MP_WATER: |
8254
5de2bbd26163
(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
parents:
8235
diff
changeset
|
378 |
if (!EnsureNoVehicleOnGround(tile)) return_cmd_error(STR_980E_SHIP_IN_THE_WAY); |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3996
diff
changeset
|
379 |
if (!IsWater(tile) && !IsCoast(tile)) goto not_valid_below; |
3065 | 380 |
break; |
0 | 381 |
|
3065 | 382 |
case MP_RAILWAY: |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
383 |
if (!IsPlainRailTile(tile)) goto not_valid_below; |
3065 | 384 |
break; |
385 |
||
7866
e19fda04e8d3
(svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium
parents:
7831
diff
changeset
|
386 |
case MP_ROAD: |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
387 |
if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) goto not_valid_below; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
388 |
break; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
389 |
|
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
390 |
case MP_TUNNELBRIDGE: |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
391 |
if (IsTunnel(tile)) break; |
6181
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
392 |
if (replace_bridge) break; |
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
393 |
if (direction == DiagDirToAxis(GetTunnelBridgeDirection(tile))) goto not_valid_below; |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
394 |
if (z_start < GetBridgeHeight(tile)) goto not_valid_below; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
395 |
break; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
396 |
|
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
397 |
case MP_UNMOVABLE: |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
398 |
if (!IsOwnedLand(tile)) goto not_valid_below; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
399 |
break; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
400 |
|
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
401 |
case MP_CLEAR: |
6181
b43f7753f4c3
(svn r8567) -Feature: Allow upgrading bridges by building a new bridge over the top. (Based on a patch by gigajum)
maedhros
parents:
6103
diff
changeset
|
402 |
if (!replace_bridge && IsBridgeAbove(tile)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
3065 | 403 |
break; |
404 |
||
405 |
default: |
|
0 | 406 |
not_valid_below:; |
3065 | 407 |
/* try and clear the middle landscape */ |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3435
diff
changeset
|
408 |
ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
3183
cf71bd234ebd
(svn r3829) Reduce the use of _error_message by directly returning error codes instead of using this global variable
tron
parents:
3181
diff
changeset
|
409 |
if (CmdFailed(ret)) return ret; |
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
410 |
cost.AddCost(ret); |
3065 | 411 |
break; |
0 | 412 |
} |
413 |
||
414 |
if (flags & DC_EXEC) { |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
415 |
SetBridgeMiddle(tile, direction); |
3178
c275826135da
(svn r3814) Remove another call to FindLandscapeHeight()
tron
parents:
3172
diff
changeset
|
416 |
MarkTileDirtyByTile(tile); |
0 | 417 |
} |
418 |
} |
|
419 |
||
8700
05e6ee04b2b6
(svn r11767) -Fix: do not call rail specific functions when building road bridge
smatz
parents:
8683
diff
changeset
|
420 |
if (flags & DC_EXEC && railtype != INVALID_RAILTYPE) { |
5812
cfb97d0d3ffd
(svn r7966) -Fix (r7936): Eh AxisToTrack returns Track not Axis, thanks KUDr
Darkvater
parents:
5805
diff
changeset
|
421 |
Track track = AxisToTrack(direction); |
8734
b7fc8c6fd379
(svn r11802) -Fix [FS#716]: do not crash trains when leaving depot to a very long track
smatz
parents:
8732
diff
changeset
|
422 |
UpdateSignalsOnSegment(tile_start, INVALID_DIAGDIR); |
5812
cfb97d0d3ffd
(svn r7966) -Fix (r7936): Eh AxisToTrack returns Track not Axis, thanks KUDr
Darkvater
parents:
5805
diff
changeset
|
423 |
YapfNotifyTrackLayoutChange(tile_start, track); |
5805
94cb5895c923
(svn r7936) -Fix (r4987, old-rev): Only update the signals and YAPF cache on a DC_EXEC action for bridge-building
Darkvater
parents:
5726
diff
changeset
|
424 |
} |
0 | 425 |
|
4434
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4344
diff
changeset
|
426 |
/* for human player that builds the bridge he gets a selection to choose from bridges (DC_QUERY_COST) |
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4344
diff
changeset
|
427 |
* It's unnecessary to execute this command every time for every bridge. So it is done only |
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4344
diff
changeset
|
428 |
* and cost is computed in "bridge_gui.c". For AI, Towns this has to be of course calculated |
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4344
diff
changeset
|
429 |
*/ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
430 |
if (!(flags & DC_QUERY_COST)) { |
2262
bd59b2d8d75f
(svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
2261
diff
changeset
|
431 |
const Bridge *b = &_bridge[bridge_type]; |
bd59b2d8d75f
(svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
2261
diff
changeset
|
432 |
|
4434
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4344
diff
changeset
|
433 |
bridge_len += 2; // begin and end tiles/ramps |
0 | 434 |
|
4850
b4e9be22945f
(svn r6776) -Codechange: Use IsValidPlayer() function to determine of a PlayerID is an
Darkvater
parents:
4849
diff
changeset
|
435 |
if (IsValidPlayer(_current_player) && !_is_old_ai_player) |
0 | 436 |
bridge_len = CalcBridgeLenCostFactor(bridge_len); |
437 |
||
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
438 |
cost.AddCost((int64)bridge_len * _price.build_bridge * b->price >> 8); |
0 | 439 |
} |
440 |
||
441 |
return cost; |
|
442 |
} |
|
443 |
||
444 |
||
1782
0ac16ff36293
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1781
diff
changeset
|
445 |
/** Build Tunnel. |
6980
6b5dee376733
(svn r9665) -Documentation: Doxygen corrections,errors, corrections of corrections...
belugas
parents:
6923
diff
changeset
|
446 |
* @param start_tile start tile of tunnel |
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6902
diff
changeset
|
447 |
* @param flags type of operation |
7157
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7033
diff
changeset
|
448 |
* @param p1 railtype or roadtypes. bit 9 set means road tunnel |
2639 | 449 |
* @param p2 unused |
0 | 450 |
*/ |
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7353
diff
changeset
|
451 |
CommandCost CmdBuildTunnel(TileIndex start_tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 452 |
{ |
3063
794656a0856e
(svn r3652) Rewrite CmdBuildTunnel in the hope to make it a bit more comprehensible
tron
parents:
3056
diff
changeset
|
453 |
TileIndexDiff delta; |
794656a0856e
(svn r3652) Rewrite CmdBuildTunnel in the hope to make it a bit more comprehensible
tron
parents:
3056
diff
changeset
|
454 |
TileIndex end_tile; |
794656a0856e
(svn r3652) Rewrite CmdBuildTunnel in the hope to make it a bit more comprehensible
tron
parents:
3056
diff
changeset
|
455 |
DiagDirection direction; |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3556
diff
changeset
|
456 |
Slope start_tileh; |
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3556
diff
changeset
|
457 |
Slope end_tileh; |
3063
794656a0856e
(svn r3652) Rewrite CmdBuildTunnel in the hope to make it a bit more comprehensible
tron
parents:
3056
diff
changeset
|
458 |
uint start_z; |
794656a0856e
(svn r3652) Rewrite CmdBuildTunnel in the hope to make it a bit more comprehensible
tron
parents:
3056
diff
changeset
|
459 |
uint end_z; |
8726
5ae45b46506b
(svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium
parents:
8720
diff
changeset
|
460 |
CommandCost cost(EXPENSES_CONSTRUCTION); |
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7353
diff
changeset
|
461 |
CommandCost ret; |
0 | 462 |
|
3063
794656a0856e
(svn r3652) Rewrite CmdBuildTunnel in the hope to make it a bit more comprehensible
tron
parents:
3056
diff
changeset
|
463 |
_build_tunnel_endtile = 0; |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8419
diff
changeset
|
464 |
if (!HasBit(p1, 9)) { |
8732
b18f578f7c16
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8728
diff
changeset
|
465 |
if (!ValParamRailtype((RailType)p1)) return CMD_ERROR; |
8353
49a1d9b9d937
(svn r11407) -Fix: do not allow building of tram-tracks when they are not available (SmatZ)
truelight
parents:
8345
diff
changeset
|
466 |
} else { |
49a1d9b9d937
(svn r11407) -Fix: do not allow building of tram-tracks when they are not available (SmatZ)
truelight
parents:
8345
diff
changeset
|
467 |
const RoadTypes rts = (RoadTypes)GB(p1, 0, 3); |
49a1d9b9d937
(svn r11407) -Fix: do not allow building of tram-tracks when they are not available (SmatZ)
truelight
parents:
8345
diff
changeset
|
468 |
if (!AreValidRoadTypes(rts) || !HasRoadTypesAvail(_current_player, rts)) return CMD_ERROR; |
7157
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
7033
diff
changeset
|
469 |
} |
1782
0ac16ff36293
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1781
diff
changeset
|
470 |
|
3063
794656a0856e
(svn r3652) Rewrite CmdBuildTunnel in the hope to make it a bit more comprehensible
tron
parents:
3056
diff
changeset
|
471 |
start_tileh = GetTileSlope(start_tile, &start_z); |
0 | 472 |
|
3063
794656a0856e
(svn r3652) Rewrite CmdBuildTunnel in the hope to make it a bit more comprehensible
tron
parents:
3056
diff
changeset
|
473 |
switch (start_tileh) { |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3556
diff
changeset
|
474 |
case SLOPE_SW: direction = DIAGDIR_SW; break; |
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3556
diff
changeset
|
475 |
case SLOPE_SE: direction = DIAGDIR_SE; break; |
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3556
diff
changeset
|
476 |
case SLOPE_NW: direction = DIAGDIR_NW; break; |
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3556
diff
changeset
|
477 |
case SLOPE_NE: direction = DIAGDIR_NE; break; |
3063
794656a0856e
(svn r3652) Rewrite CmdBuildTunnel in the hope to make it a bit more comprehensible
tron
parents:
3056
diff
changeset
|
478 |
default: return_cmd_error(STR_500B_SITE_UNSUITABLE_FOR_TUNNEL); |
2639 | 479 |
} |
0 | 480 |
|
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3435
diff
changeset
|
481 |
ret = DoCommand(start_tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
3063
794656a0856e
(svn r3652) Rewrite CmdBuildTunnel in the hope to make it a bit more comprehensible
tron
parents:
3056
diff
changeset
|
482 |
if (CmdFailed(ret)) return ret; |
0 | 483 |
|
4273
6467c2c54d58
(svn r5901) -Fix [FS#253]: Differing price calculation for tunnels depending on starting point
Darkvater
parents:
4261
diff
changeset
|
484 |
/* XXX - do NOT change 'ret' in the loop, as it is used as the price |
6467c2c54d58
(svn r5901) -Fix [FS#253]: Differing price calculation for tunnels depending on starting point
Darkvater
parents:
4261
diff
changeset
|
485 |
* for the clearing of the entrance of the tunnel. Assigning it to |
6467c2c54d58
(svn r5901) -Fix [FS#253]: Differing price calculation for tunnels depending on starting point
Darkvater
parents:
4261
diff
changeset
|
486 |
* cost before the loop will yield different costs depending on start- |
6467c2c54d58
(svn r5901) -Fix [FS#253]: Differing price calculation for tunnels depending on starting point
Darkvater
parents:
4261
diff
changeset
|
487 |
* position, because of increased-cost-by-length: 'cost += cost >> 3' */ |
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
488 |
|
4559
c853d2440065
(svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents:
4549
diff
changeset
|
489 |
delta = TileOffsByDiagDir(direction); |
7498
ce6588257e8d
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
7488
diff
changeset
|
490 |
DiagDirection tunnel_in_way_dir; |
ce6588257e8d
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
7488
diff
changeset
|
491 |
if (OtherAxis(DiagDirToAxis(direction)) == AXIS_X) { |
ce6588257e8d
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
7488
diff
changeset
|
492 |
tunnel_in_way_dir = (TileX(start_tile) < (MapMaxX() / 2)) ? DIAGDIR_SW : DIAGDIR_NE; |
ce6588257e8d
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
7488
diff
changeset
|
493 |
} else { |
ce6588257e8d
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
7488
diff
changeset
|
494 |
tunnel_in_way_dir = (TileY(start_tile) < (MapMaxX() / 2)) ? DIAGDIR_SE : DIAGDIR_NW; |
ce6588257e8d
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
7488
diff
changeset
|
495 |
} |
ce6588257e8d
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
7488
diff
changeset
|
496 |
|
3063
794656a0856e
(svn r3652) Rewrite CmdBuildTunnel in the hope to make it a bit more comprehensible
tron
parents:
3056
diff
changeset
|
497 |
end_tile = start_tile; |
7591
824ca6dcf1fb
(svn r10362) -Codechange: make tunnel costs less exponential for (very) long tunnels.
rubidium
parents:
7540
diff
changeset
|
498 |
|
824ca6dcf1fb
(svn r10362) -Codechange: make tunnel costs less exponential for (very) long tunnels.
rubidium
parents:
7540
diff
changeset
|
499 |
/** Tile shift coeficient. Will decrease for very long tunnels to avoid exponential growth of price*/ |
824ca6dcf1fb
(svn r10362) -Codechange: make tunnel costs less exponential for (very) long tunnels.
rubidium
parents:
7540
diff
changeset
|
500 |
int tiles_coef = 3; |
824ca6dcf1fb
(svn r10362) -Codechange: make tunnel costs less exponential for (very) long tunnels.
rubidium
parents:
7540
diff
changeset
|
501 |
/** Number of tiles from start of tunnel */ |
824ca6dcf1fb
(svn r10362) -Codechange: make tunnel costs less exponential for (very) long tunnels.
rubidium
parents:
7540
diff
changeset
|
502 |
int tiles = 0; |
7804
e21275451ca6
(svn r10660) -Codechange: simplified tunnel cost algorithm (bilbo)
truelight
parents:
7762
diff
changeset
|
503 |
/** Number of tiles at which the cost increase coefficient per tile is halved */ |
e21275451ca6
(svn r10660) -Codechange: simplified tunnel cost algorithm (bilbo)
truelight
parents:
7762
diff
changeset
|
504 |
int tiles_bump = 25; |
7591
824ca6dcf1fb
(svn r10362) -Codechange: make tunnel costs less exponential for (very) long tunnels.
rubidium
parents:
7540
diff
changeset
|
505 |
|
3063
794656a0856e
(svn r3652) Rewrite CmdBuildTunnel in the hope to make it a bit more comprehensible
tron
parents:
3056
diff
changeset
|
506 |
for (;;) { |
794656a0856e
(svn r3652) Rewrite CmdBuildTunnel in the hope to make it a bit more comprehensible
tron
parents:
3056
diff
changeset
|
507 |
end_tile += delta; |
794656a0856e
(svn r3652) Rewrite CmdBuildTunnel in the hope to make it a bit more comprehensible
tron
parents:
3056
diff
changeset
|
508 |
end_tileh = GetTileSlope(end_tile, &end_z); |
0 | 509 |
|
3063
794656a0856e
(svn r3652) Rewrite CmdBuildTunnel in the hope to make it a bit more comprehensible
tron
parents:
3056
diff
changeset
|
510 |
if (start_z == end_z) break; |
794656a0856e
(svn r3652) Rewrite CmdBuildTunnel in the hope to make it a bit more comprehensible
tron
parents:
3056
diff
changeset
|
511 |
|
7498
ce6588257e8d
(svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents:
7488
diff
changeset
|
512 |
if (!_cheats.crossing_tunnels.value && IsTunnelInWayDir(end_tile, start_z, tunnel_in_way_dir)) { |
3156
028b6756b279
(svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents:
3154
diff
changeset
|
513 |
return_cmd_error(STR_5003_ANOTHER_TUNNEL_IN_THE_WAY); |
3063
794656a0856e
(svn r3652) Rewrite CmdBuildTunnel in the hope to make it a bit more comprehensible
tron
parents:
3056
diff
changeset
|
514 |
} |
794656a0856e
(svn r3652) Rewrite CmdBuildTunnel in the hope to make it a bit more comprehensible
tron
parents:
3056
diff
changeset
|
515 |
|
7591
824ca6dcf1fb
(svn r10362) -Codechange: make tunnel costs less exponential for (very) long tunnels.
rubidium
parents:
7540
diff
changeset
|
516 |
tiles++; |
7804
e21275451ca6
(svn r10660) -Codechange: simplified tunnel cost algorithm (bilbo)
truelight
parents:
7762
diff
changeset
|
517 |
if (tiles == tiles_bump) { |
e21275451ca6
(svn r10660) -Codechange: simplified tunnel cost algorithm (bilbo)
truelight
parents:
7762
diff
changeset
|
518 |
tiles_coef++; |
e21275451ca6
(svn r10660) -Codechange: simplified tunnel cost algorithm (bilbo)
truelight
parents:
7762
diff
changeset
|
519 |
tiles_bump *= 2; |
e21275451ca6
(svn r10660) -Codechange: simplified tunnel cost algorithm (bilbo)
truelight
parents:
7762
diff
changeset
|
520 |
} |
7591
824ca6dcf1fb
(svn r10362) -Codechange: make tunnel costs less exponential for (very) long tunnels.
rubidium
parents:
7540
diff
changeset
|
521 |
|
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
522 |
cost.AddCost(_price.build_tunnel); |
7591
824ca6dcf1fb
(svn r10362) -Codechange: make tunnel costs less exponential for (very) long tunnels.
rubidium
parents:
7540
diff
changeset
|
523 |
cost.AddCost(cost.GetCost() >> tiles_coef); // add a multiplier for longer tunnels |
0 | 524 |
} |
525 |
||
4273
6467c2c54d58
(svn r5901) -Fix [FS#253]: Differing price calculation for tunnels depending on starting point
Darkvater
parents:
4261
diff
changeset
|
526 |
/* Add the cost of the entrance */ |
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
527 |
cost.AddCost(_price.build_tunnel); |
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
528 |
cost.AddCost(ret); |
4273
6467c2c54d58
(svn r5901) -Fix [FS#253]: Differing price calculation for tunnels depending on starting point
Darkvater
parents:
4261
diff
changeset
|
529 |
|
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6902
diff
changeset
|
530 |
/* if the command fails from here on we want the end tile to be highlighted */ |
3063
794656a0856e
(svn r3652) Rewrite CmdBuildTunnel in the hope to make it a bit more comprehensible
tron
parents:
3056
diff
changeset
|
531 |
_build_tunnel_endtile = end_tile; |
794656a0856e
(svn r3652) Rewrite CmdBuildTunnel in the hope to make it a bit more comprehensible
tron
parents:
3056
diff
changeset
|
532 |
|
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6902
diff
changeset
|
533 |
/* slope of end tile must be complementary to the slope of the start tile */ |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3556
diff
changeset
|
534 |
if (end_tileh != ComplementSlope(start_tileh)) { |
8173
a631134b69e5
(svn r11208) -Fix [FS#1300]: tunnel excavation could disown somebody elses owned land. Patch by frosch.
rubidium
parents:
8097
diff
changeset
|
535 |
/* Check if there is a structure on the terraformed tile. Do not add the cost, that will be done by the terraforming */ |
a631134b69e5
(svn r11208) -Fix [FS#1300]: tunnel excavation could disown somebody elses owned land. Patch by frosch.
rubidium
parents:
8097
diff
changeset
|
536 |
ret = DoCommand(end_tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR); |
a631134b69e5
(svn r11208) -Fix [FS#1300]: tunnel excavation could disown somebody elses owned land. Patch by frosch.
rubidium
parents:
8097
diff
changeset
|
537 |
if (CmdFailed(ret)) return_cmd_error(STR_5005_UNABLE_TO_EXCAVATE_LAND); |
7538
f0361b346f02
(svn r10306) -Fix [FS#890]: the fix in r10219 was not enough to stop this bug from happening.
rubidium
parents:
7499
diff
changeset
|
538 |
|
8173
a631134b69e5
(svn r11208) -Fix [FS#1300]: tunnel excavation could disown somebody elses owned land. Patch by frosch.
rubidium
parents:
8097
diff
changeset
|
539 |
ret = DoCommand(end_tile, end_tileh & start_tileh, 0, flags, CMD_TERRAFORM_LAND); |
a631134b69e5
(svn r11208) -Fix [FS#1300]: tunnel excavation could disown somebody elses owned land. Patch by frosch.
rubidium
parents:
8097
diff
changeset
|
540 |
if (CmdFailed(ret)) return_cmd_error(STR_5005_UNABLE_TO_EXCAVATE_LAND); |
3063
794656a0856e
(svn r3652) Rewrite CmdBuildTunnel in the hope to make it a bit more comprehensible
tron
parents:
3056
diff
changeset
|
541 |
} else { |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3435
diff
changeset
|
542 |
ret = DoCommand(end_tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
3063
794656a0856e
(svn r3652) Rewrite CmdBuildTunnel in the hope to make it a bit more comprehensible
tron
parents:
3056
diff
changeset
|
543 |
if (CmdFailed(ret)) return ret; |
794656a0856e
(svn r3652) Rewrite CmdBuildTunnel in the hope to make it a bit more comprehensible
tron
parents:
3056
diff
changeset
|
544 |
} |
7446
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
545 |
cost.AddCost(_price.build_tunnel); |
1c4d469f986e
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
7439
diff
changeset
|
546 |
cost.AddCost(ret); |
3063
794656a0856e
(svn r3652) Rewrite CmdBuildTunnel in the hope to make it a bit more comprehensible
tron
parents:
3056
diff
changeset
|
547 |
|
794656a0856e
(svn r3652) Rewrite CmdBuildTunnel in the hope to make it a bit more comprehensible
tron
parents:
3056
diff
changeset
|
548 |
if (flags & DC_EXEC) { |
3154 | 549 |
if (GB(p1, 9, 1) == TRANSPORT_RAIL) { |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
550 |
MakeRailTunnel(start_tile, _current_player, direction, (RailType)GB(p1, 0, 4)); |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
551 |
MakeRailTunnel(end_tile, _current_player, ReverseDiagDir(direction), (RailType)GB(p1, 0, 4)); |
8734
b7fc8c6fd379
(svn r11802) -Fix [FS#716]: do not crash trains when leaving depot to a very long track
smatz
parents:
8732
diff
changeset
|
552 |
UpdateSignalsOnSegment(start_tile, INVALID_DIAGDIR); |
4158 | 553 |
YapfNotifyTrackLayoutChange(start_tile, AxisToTrack(DiagDirToAxis(direction))); |
3154 | 554 |
} else { |
7159
aec2b7823dc6
(svn r9894) -Fix (r9892): catenary was drawn on road bridges ;)
rubidium
parents:
7157
diff
changeset
|
555 |
MakeRoadTunnel(start_tile, _current_player, direction, (RoadTypes)GB(p1, 0, 3)); |
aec2b7823dc6
(svn r9894) -Fix (r9892): catenary was drawn on road bridges ;)
rubidium
parents:
7157
diff
changeset
|
556 |
MakeRoadTunnel(end_tile, _current_player, ReverseDiagDir(direction), (RoadTypes)GB(p1, 0, 3)); |
3154 | 557 |
} |
3063
794656a0856e
(svn r3652) Rewrite CmdBuildTunnel in the hope to make it a bit more comprehensible
tron
parents:
3056
diff
changeset
|
558 |
} |
794656a0856e
(svn r3652) Rewrite CmdBuildTunnel in the hope to make it a bit more comprehensible
tron
parents:
3056
diff
changeset
|
559 |
|
794656a0856e
(svn r3652) Rewrite CmdBuildTunnel in the hope to make it a bit more comprehensible
tron
parents:
3056
diff
changeset
|
560 |
return cost; |
0 | 561 |
} |
562 |
||
563 |
||
5009
437645a303b4
(svn r7028) -Fix [FS#200]: Scenario bridges/tunnels cannot be demolished; now it's possible to
Darkvater
parents:
4850
diff
changeset
|
564 |
static inline bool CheckAllowRemoveTunnelBridge(TileIndex tile) |
437645a303b4
(svn r7028) -Fix [FS#200]: Scenario bridges/tunnels cannot be demolished; now it's possible to
Darkvater
parents:
4850
diff
changeset
|
565 |
{ |
437645a303b4
(svn r7028) -Fix [FS#200]: Scenario bridges/tunnels cannot be demolished; now it's possible to
Darkvater
parents:
4850
diff
changeset
|
566 |
/* Floods can remove anything as well as the scenario editor */ |
437645a303b4
(svn r7028) -Fix [FS#200]: Scenario bridges/tunnels cannot be demolished; now it's possible to
Darkvater
parents:
4850
diff
changeset
|
567 |
if (_current_player == OWNER_WATER || _game_mode == GM_EDITOR) return true; |
437645a303b4
(svn r7028) -Fix [FS#200]: Scenario bridges/tunnels cannot be demolished; now it's possible to
Darkvater
parents:
4850
diff
changeset
|
568 |
/* Obviously if the bridge/tunnel belongs to us, or no-one, we can remove it */ |
437645a303b4
(svn r7028) -Fix [FS#200]: Scenario bridges/tunnels cannot be demolished; now it's possible to
Darkvater
parents:
4850
diff
changeset
|
569 |
if (CheckTileOwnership(tile) || IsTileOwner(tile, OWNER_NONE)) return true; |
437645a303b4
(svn r7028) -Fix [FS#200]: Scenario bridges/tunnels cannot be demolished; now it's possible to
Darkvater
parents:
4850
diff
changeset
|
570 |
/* Otherwise we can only remove town-owned stuff with extra patch-settings, or cheat */ |
437645a303b4
(svn r7028) -Fix [FS#200]: Scenario bridges/tunnels cannot be demolished; now it's possible to
Darkvater
parents:
4850
diff
changeset
|
571 |
if (IsTileOwner(tile, OWNER_TOWN) && (_patches.extra_dynamite || _cheats.magic_bulldozer.value)) return true; |
437645a303b4
(svn r7028) -Fix [FS#200]: Scenario bridges/tunnels cannot be demolished; now it's possible to
Darkvater
parents:
4850
diff
changeset
|
572 |
return false; |
437645a303b4
(svn r7028) -Fix [FS#200]: Scenario bridges/tunnels cannot be demolished; now it's possible to
Darkvater
parents:
4850
diff
changeset
|
573 |
} |
437645a303b4
(svn r7028) -Fix [FS#200]: Scenario bridges/tunnels cannot be demolished; now it's possible to
Darkvater
parents:
4850
diff
changeset
|
574 |
|
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7353
diff
changeset
|
575 |
static CommandCost DoClearTunnel(TileIndex tile, uint32 flags) |
0 | 576 |
{ |
5009
437645a303b4
(svn r7028) -Fix [FS#200]: Scenario bridges/tunnels cannot be demolished; now it's possible to
Darkvater
parents:
4850
diff
changeset
|
577 |
Town *t = NULL; |
1782
0ac16ff36293
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1781
diff
changeset
|
578 |
TileIndex endtile; |
0 | 579 |
|
5009
437645a303b4
(svn r7028) -Fix [FS#200]: Scenario bridges/tunnels cannot be demolished; now it's possible to
Darkvater
parents:
4850
diff
changeset
|
580 |
if (!CheckAllowRemoveTunnelBridge(tile)) return CMD_ERROR; |
0 | 581 |
|
8568
a82225425c24
(svn r11633) -Codechange: merge CheckTunnelEmpty and IsVehicleOnBridge into GetVehicleTunnelBridge
smatz
parents:
8539
diff
changeset
|
582 |
endtile = GetOtherTunnelEnd(tile); |
a82225425c24
(svn r11633) -Codechange: merge CheckTunnelEmpty and IsVehicleOnBridge into GetVehicleTunnelBridge
smatz
parents:
8539
diff
changeset
|
583 |
|
a82225425c24
(svn r11633) -Codechange: merge CheckTunnelEmpty and IsVehicleOnBridge into GetVehicleTunnelBridge
smatz
parents:
8539
diff
changeset
|
584 |
if (GetVehicleTunnelBridge(tile, endtile) != NULL) return CMD_ERROR; |
0 | 585 |
|
586 |
_build_tunnel_endtile = endtile; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
587 |
|
1901
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
588 |
if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) { |
5009
437645a303b4
(svn r7028) -Fix [FS#200]: Scenario bridges/tunnels cannot be demolished; now it's possible to
Darkvater
parents:
4850
diff
changeset
|
589 |
t = ClosestTownFromTile(tile, (uint)-1); // town penalty rating |
437645a303b4
(svn r7028) -Fix [FS#200]: Scenario bridges/tunnels cannot be demolished; now it's possible to
Darkvater
parents:
4850
diff
changeset
|
590 |
|
437645a303b4
(svn r7028) -Fix [FS#200]: Scenario bridges/tunnels cannot be demolished; now it's possible to
Darkvater
parents:
4850
diff
changeset
|
591 |
/* Check if you are allowed to remove the tunnel owned by a town |
437645a303b4
(svn r7028) -Fix [FS#200]: Scenario bridges/tunnels cannot be demolished; now it's possible to
Darkvater
parents:
4850
diff
changeset
|
592 |
* Removal depends on difficulty settings */ |
2958
3f8946daf55f
(svn r3520) Remove unused parameters from some functions
tron
parents:
2952
diff
changeset
|
593 |
if (!CheckforTownRating(flags, t, TUNNELBRIDGE_REMOVE)) { |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
511
diff
changeset
|
594 |
SetDParam(0, t->index); |
0 | 595 |
return_cmd_error(STR_2009_LOCAL_AUTHORITY_REFUSES); |
596 |
} |
|
597 |
} |
|
598 |
||
8728
26930bbf9bee
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx
parents:
8726
diff
changeset
|
599 |
/* checks if the owner is town then decrease town rating by RATING_TUNNEL_BRIDGE_DOWN_STEP until |
26930bbf9bee
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx
parents:
8726
diff
changeset
|
600 |
* you have a "Poor" (0) town rating */ |
26930bbf9bee
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx
parents:
8726
diff
changeset
|
601 |
if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) { |
26930bbf9bee
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx
parents:
8726
diff
changeset
|
602 |
ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM); |
26930bbf9bee
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx
parents:
8726
diff
changeset
|
603 |
} |
26930bbf9bee
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx
parents:
8726
diff
changeset
|
604 |
|
0 | 605 |
if (flags & DC_EXEC) { |
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6902
diff
changeset
|
606 |
/* We first need to request the direction before calling DoClearSquare |
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6902
diff
changeset
|
607 |
* else the direction is always 0.. dah!! ;) */ |
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
608 |
DiagDirection dir = GetTunnelBridgeDirection(tile); |
4158 | 609 |
Track track; |
2870
32c980d2b8e9
(svn r3418) - Fix: When removing a town-owned tunnel the player's rating was not reduced, as it checked the ownership of the tunnel after clearing it. Now we perform the rating adjustment before clearing the tiles. (spotted by glx)
peter1138
parents:
2843
diff
changeset
|
610 |
|
0 | 611 |
DoClearSquare(tile); |
612 |
DoClearSquare(endtile); |
|
3172
1605cb59ccd9
(svn r3803) Change the second parameter of UpdateSignalsOnSegment() from Direction to DiagDirection as that's what it really operates on
tron
parents:
3157
diff
changeset
|
613 |
UpdateSignalsOnSegment(tile, ReverseDiagDir(dir)); |
1605cb59ccd9
(svn r3803) Change the second parameter of UpdateSignalsOnSegment() from Direction to DiagDirection as that's what it really operates on
tron
parents:
3157
diff
changeset
|
614 |
UpdateSignalsOnSegment(endtile, dir); |
4158 | 615 |
track = AxisToTrack(DiagDirToAxis(dir)); |
616 |
YapfNotifyTrackLayoutChange(tile, track); |
|
617 |
YapfNotifyTrackLayoutChange(endtile, track); |
|
0 | 618 |
} |
8726
5ae45b46506b
(svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium
parents:
8720
diff
changeset
|
619 |
return CommandCost(EXPENSES_CONSTRUCTION, _price.clear_tunnel * (DistanceManhattan(tile, endtile) + 1)); |
0 | 620 |
} |
621 |
||
3977
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3938
diff
changeset
|
622 |
|
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7353
diff
changeset
|
623 |
static CommandCost DoClearBridge(TileIndex tile, uint32 flags) |
0 | 624 |
{ |
3227
8bb33a2299a5
(svn r3900) When clearing a bridge determine the bridge direction and tile offset once instead of all over the place; also use UpdateSignalsOnSegment() instead of SetSignalsOnBothDir(), because this is sufficient
tron
parents:
3226
diff
changeset
|
625 |
DiagDirection direction; |
8bb33a2299a5
(svn r3900) When clearing a bridge determine the bridge direction and tile offset once instead of all over the place; also use UpdateSignalsOnSegment() instead of SetSignalsOnBothDir(), because this is sufficient
tron
parents:
3226
diff
changeset
|
626 |
TileIndexDiff delta; |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1930
diff
changeset
|
627 |
TileIndex endtile; |
5009
437645a303b4
(svn r7028) -Fix [FS#200]: Scenario bridges/tunnels cannot be demolished; now it's possible to
Darkvater
parents:
4850
diff
changeset
|
628 |
Town *t = NULL; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
629 |
|
5009
437645a303b4
(svn r7028) -Fix [FS#200]: Scenario bridges/tunnels cannot be demolished; now it's possible to
Darkvater
parents:
4850
diff
changeset
|
630 |
if (!CheckAllowRemoveTunnelBridge(tile)) return CMD_ERROR; |
0 | 631 |
|
3228
270ab760cc16
(svn r3901) Remove the last user of FindEdgesOfBridge() by using functions with similar functionality
tron
parents:
3227
diff
changeset
|
632 |
endtile = GetOtherBridgeEnd(tile); |
270ab760cc16
(svn r3901) Remove the last user of FindEdgesOfBridge() by using functions with similar functionality
tron
parents:
3227
diff
changeset
|
633 |
|
8568
a82225425c24
(svn r11633) -Codechange: merge CheckTunnelEmpty and IsVehicleOnBridge into GetVehicleTunnelBridge
smatz
parents:
8539
diff
changeset
|
634 |
if (GetVehicleTunnelBridge(tile, endtile) != NULL) return CMD_ERROR; |
0 | 635 |
|
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
636 |
direction = GetTunnelBridgeDirection(tile); |
4559
c853d2440065
(svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents:
4549
diff
changeset
|
637 |
delta = TileOffsByDiagDir(direction); |
3227
8bb33a2299a5
(svn r3900) When clearing a bridge determine the bridge direction and tile offset once instead of all over the place; also use UpdateSignalsOnSegment() instead of SetSignalsOnBothDir(), because this is sufficient
tron
parents:
3226
diff
changeset
|
638 |
|
1901
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
639 |
if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) { |
5009
437645a303b4
(svn r7028) -Fix [FS#200]: Scenario bridges/tunnels cannot be demolished; now it's possible to
Darkvater
parents:
4850
diff
changeset
|
640 |
t = ClosestTownFromTile(tile, (uint)-1); // town penalty rating |
437645a303b4
(svn r7028) -Fix [FS#200]: Scenario bridges/tunnels cannot be demolished; now it's possible to
Darkvater
parents:
4850
diff
changeset
|
641 |
|
437645a303b4
(svn r7028) -Fix [FS#200]: Scenario bridges/tunnels cannot be demolished; now it's possible to
Darkvater
parents:
4850
diff
changeset
|
642 |
/* Check if you are allowed to remove the bridge owned by a town |
437645a303b4
(svn r7028) -Fix [FS#200]: Scenario bridges/tunnels cannot be demolished; now it's possible to
Darkvater
parents:
4850
diff
changeset
|
643 |
* Removal depends on difficulty settings */ |
437645a303b4
(svn r7028) -Fix [FS#200]: Scenario bridges/tunnels cannot be demolished; now it's possible to
Darkvater
parents:
4850
diff
changeset
|
644 |
if (!CheckforTownRating(flags, t, TUNNELBRIDGE_REMOVE)) { |
437645a303b4
(svn r7028) -Fix [FS#200]: Scenario bridges/tunnels cannot be demolished; now it's possible to
Darkvater
parents:
4850
diff
changeset
|
645 |
SetDParam(0, t->index); |
437645a303b4
(svn r7028) -Fix [FS#200]: Scenario bridges/tunnels cannot be demolished; now it's possible to
Darkvater
parents:
4850
diff
changeset
|
646 |
return_cmd_error(STR_2009_LOCAL_AUTHORITY_REFUSES); |
437645a303b4
(svn r7028) -Fix [FS#200]: Scenario bridges/tunnels cannot be demolished; now it's possible to
Darkvater
parents:
4850
diff
changeset
|
647 |
} |
0 | 648 |
} |
649 |
||
8728
26930bbf9bee
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx
parents:
8726
diff
changeset
|
650 |
/* checks if the owner is town then decrease town rating by RATING_TUNNEL_BRIDGE_DOWN_STEP until |
26930bbf9bee
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx
parents:
8726
diff
changeset
|
651 |
* you have a "Poor" (0) town rating */ |
26930bbf9bee
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx
parents:
8726
diff
changeset
|
652 |
if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) { |
26930bbf9bee
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx
parents:
8726
diff
changeset
|
653 |
ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM); |
26930bbf9bee
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx
parents:
8726
diff
changeset
|
654 |
} |
26930bbf9bee
(svn r11795) -Fix [FS#1616]: take town rating into account when testing if a command can be executed.
glx
parents:
8726
diff
changeset
|
655 |
|
0 | 656 |
if (flags & DC_EXEC) { |
3217
60f832048cd4
(svn r3890) Simplify deleting a bridge by handling the ramps outside of the removal loop
tron
parents:
3216
diff
changeset
|
657 |
TileIndex c; |
4158 | 658 |
Track track; |
0 | 659 |
|
3217
60f832048cd4
(svn r3890) Simplify deleting a bridge by handling the ramps outside of the removal loop
tron
parents:
3216
diff
changeset
|
660 |
DoClearSquare(tile); |
60f832048cd4
(svn r3890) Simplify deleting a bridge by handling the ramps outside of the removal loop
tron
parents:
3216
diff
changeset
|
661 |
DoClearSquare(endtile); |
60f832048cd4
(svn r3890) Simplify deleting a bridge by handling the ramps outside of the removal loop
tron
parents:
3216
diff
changeset
|
662 |
for (c = tile + delta; c != endtile; c += delta) { |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
663 |
ClearBridgeMiddle(c); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
664 |
MarkTileDirtyByTile(c); |
3217
60f832048cd4
(svn r3890) Simplify deleting a bridge by handling the ramps outside of the removal loop
tron
parents:
3216
diff
changeset
|
665 |
} |
0 | 666 |
|
3227
8bb33a2299a5
(svn r3900) When clearing a bridge determine the bridge direction and tile offset once instead of all over the place; also use UpdateSignalsOnSegment() instead of SetSignalsOnBothDir(), because this is sufficient
tron
parents:
3226
diff
changeset
|
667 |
UpdateSignalsOnSegment(tile, ReverseDiagDir(direction)); |
8bb33a2299a5
(svn r3900) When clearing a bridge determine the bridge direction and tile offset once instead of all over the place; also use UpdateSignalsOnSegment() instead of SetSignalsOnBothDir(), because this is sufficient
tron
parents:
3226
diff
changeset
|
668 |
UpdateSignalsOnSegment(endtile, direction); |
4158 | 669 |
track = AxisToTrack(DiagDirToAxis(direction)); |
670 |
YapfNotifyTrackLayoutChange(tile, track); |
|
671 |
YapfNotifyTrackLayoutChange(endtile, track); |
|
0 | 672 |
} |
673 |
||
8726
5ae45b46506b
(svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium
parents:
8720
diff
changeset
|
674 |
return CommandCost(EXPENSES_CONSTRUCTION, (DistanceManhattan(tile, endtile) + 1) * _price.clear_bridge); |
0 | 675 |
} |
676 |
||
7439
0c0e2945c890
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
7353
diff
changeset
|
677 |
static CommandCost ClearTile_TunnelBridge(TileIndex tile, byte flags) |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1930
diff
changeset
|
678 |
{ |
3184
7405329343ce
(svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents:
3183
diff
changeset
|
679 |
if (IsTunnel(tile)) { |
2639 | 680 |
if (flags & DC_AUTO) return_cmd_error(STR_5006_MUST_DEMOLISH_TUNNEL_FIRST); |
0 | 681 |
return DoClearTunnel(tile, flags); |
3234
986c30171e92
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3233
diff
changeset
|
682 |
} else if (IsBridge(tile)) { // XXX Is this necessary? |
2639 | 683 |
if (flags & DC_AUTO) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
1082
56a4c048c5c3
(svn r1583) -Fix: You should no longer be able to delete bridges on any type of underground when there is a vehicle on it
darkvater
parents:
1073
diff
changeset
|
684 |
return DoClearBridge(tile, flags); |
1109
1bab892228cd
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1095
diff
changeset
|
685 |
} |
1bab892228cd
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1095
diff
changeset
|
686 |
|
1082
56a4c048c5c3
(svn r1583) -Fix: You should no longer be able to delete bridges on any type of underground when there is a vehicle on it
darkvater
parents:
1073
diff
changeset
|
687 |
return CMD_ERROR; |
0 | 688 |
} |
689 |
||
6694
a10a42eefd52
(svn r9425) -Codechange/Fix (FS#689): Housekeeping in the convert rail functions: Changed the order of error checks to generate more meaningful error messages, added some doxygen comments and replaced bitshifting by proper mathematical operations
celestar
parents:
6683
diff
changeset
|
690 |
/** |
8224
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
691 |
* Draws the pillars under high bridges. |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
692 |
* |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
693 |
* @param psid Image and palette of a bridge pillar. |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
694 |
* @param ti #TileInfo of current bridge-middle-tile. |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
695 |
* @param axis Orientation of bridge. |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
696 |
* @param type Bridge type. |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
697 |
* @param x Sprite X position of front pillar. |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
698 |
* @param y Sprite Y position of front pillar. |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
699 |
* @param z_bridge Absolute height of bridge bottom. |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
700 |
*/ |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
701 |
static void DrawBridgePillars(const PalSpriteID *psid, const TileInfo* ti, Axis axis, uint type, int x, int y, int z_bridge) |
0 | 702 |
{ |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
703 |
SpriteID image = psid->sprite; |
0 | 704 |
if (image != 0) { |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8419
diff
changeset
|
705 |
bool drawfarpillar = !HasBit(GetBridgeFlags(type), 0); |
0 | 706 |
|
8224
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
707 |
/* "side" specifies the side the pillars stand on. |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
708 |
* The length of the pillars is then set to the height of the bridge over the corners of this edge. |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
709 |
* |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
710 |
* axis==AXIS_X axis==AXIS_Y |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
711 |
* side==false SW NW |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
712 |
* side==true NE SE |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
713 |
* |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
714 |
* I have no clue, why this was done this way. |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
715 |
*/ |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8419
diff
changeset
|
716 |
bool side = HasBit(image, 0); |
2262
bd59b2d8d75f
(svn r2782) -Codechange: Started cleaning the bridge code. Removed numerous global variables containing bridge information and joined them in a struct. Introduced GetBridgeType and GetBridgePiece and fixed some minor stuff (whitespace etc)
celestar
parents:
2261
diff
changeset
|
717 |
|
8224
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
718 |
/* "dir" means the edge the pillars stand on */ |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
719 |
DiagDirection dir = AxisToDiagDir(axis); |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
720 |
if (side != (axis == AXIS_Y)) dir = ReverseDiagDir(dir); |
0 | 721 |
|
8224
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
722 |
/* Determine ground height under pillars */ |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
723 |
int front_height = ti->z; |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
724 |
int back_height = ti->z; |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
725 |
GetSlopeZOnEdge(ti->tileh, dir, &front_height, &back_height); |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
726 |
|
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
727 |
/* x and y size of bounding-box of pillars */ |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
728 |
int w = (axis == AXIS_X ? 16 : 2); |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
729 |
int h = (axis == AXIS_X ? 2 : 16); |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
730 |
/* sprite position of back facing pillar */ |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
731 |
int x_back = x - (axis == AXIS_X ? 0 : 9); |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
732 |
int y_back = y - (axis == AXIS_X ? 9 : 0); |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
733 |
|
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
734 |
for (int cur_z = z_bridge; cur_z >= front_height || cur_z >= back_height; cur_z -= TILE_HEIGHT) { |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
735 |
/* Draw front facing pillar */ |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
736 |
if (cur_z >= front_height) { |
8345
6caa3fdb972c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
8341
diff
changeset
|
737 |
AddSortableSpriteToDraw(image, psid->pal, x, y, w, h, BB_HEIGHT_UNDER_BRIDGE - 5, cur_z, IsTransparencySet(TO_BRIDGES), 0, 0, -5); |
2952 | 738 |
} |
3556
d25b35568c48
(svn r4430) - NewGRF: Use the bridge's sprite layout for drawing high pillars. This fixes newgrf's high-bridge pillars drawing. Also remove the now obsolete _bridge_poles_table which was already integrated into the bridge sprite tables
Darkvater
parents:
3539
diff
changeset
|
739 |
|
8224
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
740 |
/* Draw back facing pillar, but not the highest part directly under the bridge-floor */ |
6260e98d1c6a
(svn r11263) -Codechange: Reduce code duplication between DrawBridgePillars and HasFoundation{NW|NE}. Patch by frosch.
rubidium
parents:
8193
diff
changeset
|
741 |
if (drawfarpillar && cur_z >= back_height && cur_z < z_bridge - TILE_HEIGHT) { |
8345
6caa3fdb972c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
8341
diff
changeset
|
742 |
AddSortableSpriteToDraw(image, psid->pal, x_back, y_back, w, h, BB_HEIGHT_UNDER_BRIDGE - 5, cur_z, IsTransparencySet(TO_BRIDGES), 0, 0, -5); |
2952 | 743 |
} |
0 | 744 |
} |
745 |
} |
|
746 |
} |
|
747 |
||
7831
5dded9b03500
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7829
diff
changeset
|
748 |
Foundation GetBridgeFoundation(Slope tileh, Axis axis) |
2639 | 749 |
{ |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8419
diff
changeset
|
750 |
if (HasBit(BRIDGE_NO_FOUNDATION, tileh)) return FOUNDATION_NONE; |
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8419
diff
changeset
|
751 |
if (HasBit(BRIDGE_FULL_LEVELED_FOUNDATION, tileh)) return FlatteningFoundation(tileh); |
7831
5dded9b03500
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7829
diff
changeset
|
752 |
return InclinedFoundation(axis); |
0 | 753 |
} |
754 |
||
2536
8c4e298f4886
(svn r3065) -Codechange/Add: Modified the bridge drawing code so that the basic offset is read from the RailTypeInfo struct. This is (hopefully) the last DrawTile change on the way to electrified railways. While being at it, de-mystified the function a bit and added some asserts.
celestar
parents:
2535
diff
changeset
|
755 |
/** |
7187
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
756 |
* Draws the trambits over an already drawn (lower end) of a bridge. |
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
757 |
* @param x the x of the bridge |
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
758 |
* @param y the y of the bridge |
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
759 |
* @param z the z of the bridge |
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
760 |
* @param offset number representing whether to level or sloped and the direction |
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
761 |
* @param overlay do we want to still see the road? |
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
762 |
*/ |
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
763 |
static void DrawBridgeTramBits(int x, int y, byte z, int offset, bool overlay) |
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
764 |
{ |
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
765 |
static const SpriteID tram_offsets[2][6] = { { 107, 108, 109, 110, 111, 112 }, { 4, 5, 15, 16, 17, 18 } }; |
7745
254e77476fbe
(svn r10549) -Fix [FS#1031]: wrong tram catenary poles drawn in some bridge directions.
rubidium
parents:
7591
diff
changeset
|
766 |
static const SpriteID back_offsets[6] = { 95, 96, 99, 102, 100, 101 }; |
7187
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
767 |
static const SpriteID front_offsets[6] = { 97, 98, 103, 106, 104, 105 }; |
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
768 |
|
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
769 |
static const uint size_x[6] = { 1, 16, 16, 1, 16, 1 }; |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
770 |
static const uint size_y[6] = { 16, 1, 1, 16, 1, 16 }; |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
771 |
static const uint front_bb_offset_x[6] = { 15, 0, 0, 15, 0, 15 }; |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
772 |
static const uint front_bb_offset_y[6] = { 0, 15, 15, 0, 15, 0 }; |
7195
6edfafb988be
(svn r9931) -Fix: some glitches with catenary and bridges.
rubidium
parents:
7187
diff
changeset
|
773 |
|
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
774 |
/* The sprites under the vehicles are drawn as SpriteCombine. StartSpriteCombine() has already been called |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
775 |
* The bounding boxes here are the same as for bridge front/roof */ |
8345
6caa3fdb972c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
8341
diff
changeset
|
776 |
AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + tram_offsets[overlay][offset], PAL_NONE, x, y, size_x[offset], size_y[offset], 0x28, z, IsTransparencySet(TO_BRIDGES)); |
7187
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
777 |
|
8345
6caa3fdb972c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
8341
diff
changeset
|
778 |
AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + back_offsets[offset], PAL_NONE, x, y, size_x[offset], size_y[offset], 0x28, z, IsTransparencySet(TO_BUILDINGS)); |
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
779 |
|
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
780 |
/* Start a new SpriteCombine for the front part */ |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
781 |
EndSpriteCombine(); |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
782 |
StartSpriteCombine(); |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
783 |
|
7187
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
784 |
/* For sloped sprites the bounding box needs to be higher, as the pylons stop on a higher point */ |
8345
6caa3fdb972c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
8341
diff
changeset
|
785 |
AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + front_offsets[offset], PAL_NONE, x, y, size_x[offset] + front_bb_offset_x[offset], size_y[offset] + front_bb_offset_y[offset], 0x28, z, IsTransparencySet(TO_BUILDINGS), front_bb_offset_x[offset], front_bb_offset_y[offset]); |
7187
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
786 |
} |
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
787 |
|
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
788 |
/** |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4434
diff
changeset
|
789 |
* Draws a tunnel of bridge tile. |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4434
diff
changeset
|
790 |
* For tunnels, this is rather simple, as you only needa draw the entrance. |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4434
diff
changeset
|
791 |
* Bridges are a bit more complex. base_offset is where the sprite selection comes into play |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4434
diff
changeset
|
792 |
* and it works a bit like a bitmask.<p> For bridge heads: |
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6902
diff
changeset
|
793 |
* @param ti TileInfo of the structure to draw |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4434
diff
changeset
|
794 |
* <ul><li>Bit 0: direction</li> |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4434
diff
changeset
|
795 |
* <li>Bit 1: northern or southern heads</li> |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4434
diff
changeset
|
796 |
* <li>Bit 2: Set if the bridge head is sloped</li> |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4434
diff
changeset
|
797 |
* <li>Bit 3 and more: Railtype Specific subset</li> |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4434
diff
changeset
|
798 |
* </ul> |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4434
diff
changeset
|
799 |
* Please note that in this code, "roads" are treated as railtype 1, whilst the real railtypes are 0, 2 and 3 |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4434
diff
changeset
|
800 |
*/ |
0 | 801 |
static void DrawTile_TunnelBridge(TileInfo *ti) |
802 |
{ |
|
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
803 |
SpriteID image; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
804 |
|
3184
7405329343ce
(svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents:
3183
diff
changeset
|
805 |
if (IsTunnel(ti->tile)) { |
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
806 |
/* Front view of tunnel bounding boxes: |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
807 |
* |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
808 |
* 122223 <- BB_Z_SEPARATOR |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
809 |
* 1 3 |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
810 |
* 1 3 1,3 = empty helper BB |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
811 |
* 1 3 2 = SpriteCombine of tunnel-roof and catenary (tram & elrail) |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
812 |
* |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
813 |
*/ |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
814 |
|
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
815 |
static const int _tunnel_BB[4][12] = { |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
816 |
/* tunnnel-roof | Z-separator | tram-catenary |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
817 |
* w h bb_x bb_y| x y w h |bb_x bb_y w h */ |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
818 |
{ 1, 0, -15, -14, 0, 15, 16, 1, 0, 1, 16, 15 }, // NE |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
819 |
{ 0, 1, -14, -15, 15, 0, 1, 16, 1, 0, 15, 16 }, // SE |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
820 |
{ 1, 0, -15, -14, 0, 15, 16, 1, 0, 1, 16, 15 }, // SW |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
821 |
{ 0, 1, -14, -15, 15, 0, 1, 16, 1, 0, 15, 16 }, // NW |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
822 |
}; |
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
823 |
const int *BB_data = _tunnel_BB[GetTunnelBridgeDirection(ti->tile)]; |
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
824 |
|
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
825 |
bool catenary = false; |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
826 |
|
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
827 |
if (GetTunnelBridgeTransportType(ti->tile) == TRANSPORT_RAIL) { |
3242
1cefa03f0d5e
(svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents:
3234
diff
changeset
|
828 |
image = GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.tunnel; |
2511
0a81d9ca79bc
(svn r3037) Don't deduce the sprites for tunnels and level crossings from magic numbers, but fetch them from the central rail info array. This is a preparation step for electrified rails
tron
parents:
2502
diff
changeset
|
829 |
} else { |
0a81d9ca79bc
(svn r3037) Don't deduce the sprites for tunnels and level crossings from magic numbers, but fetch them from the central rail info array. This is a preparation step for electrified rails
tron
parents:
2502
diff
changeset
|
830 |
image = SPR_TUNNEL_ENTRY_REAR_ROAD; |
0a81d9ca79bc
(svn r3037) Don't deduce the sprites for tunnels and level crossings from magic numbers, but fetch them from the central rail info array. This is a preparation step for electrified rails
tron
parents:
2502
diff
changeset
|
831 |
} |
0 | 832 |
|
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
833 |
if (HasTunnelBridgeSnowOrDesert(ti->tile)) image += 32; |
0 | 834 |
|
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
835 |
image += GetTunnelBridgeDirection(ti->tile) * 2; |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
836 |
DrawGroundSprite(image, PAL_NONE); |
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
837 |
if (GetTunnelBridgeTransportType(ti->tile) == TRANSPORT_ROAD) { |
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
838 |
DiagDirection dir = GetTunnelBridgeDirection(ti->tile); |
7187
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
839 |
RoadTypes rts = GetRoadTypes(ti->tile); |
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
840 |
|
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8419
diff
changeset
|
841 |
if (HasBit(rts, ROADTYPE_TRAM)) { |
7187
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
842 |
static const SpriteID tunnel_sprites[2][4] = { { 28, 78, 79, 27 }, { 5, 76, 77, 4 } }; |
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
843 |
|
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
844 |
DrawGroundSprite(SPR_TRAMWAY_BASE + tunnel_sprites[rts - ROADTYPES_TRAM][dir], PAL_NONE); |
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
845 |
|
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
846 |
catenary = true; |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
847 |
StartSpriteCombine(); |
8345
6caa3fdb972c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
8341
diff
changeset
|
848 |
AddSortableSpriteToDraw(SPR_TRAMWAY_TUNNEL_WIRES + dir, PAL_NONE, ti->x, ti->y, BB_data[10], BB_data[11], TILE_HEIGHT, ti->z, IsTransparencySet(TO_BUILDINGS), BB_data[8], BB_data[9], BB_Z_SEPARATOR); |
7187
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
849 |
} |
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
850 |
} else if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) { |
7159
aec2b7823dc6
(svn r9894) -Fix (r9892): catenary was drawn on road bridges ;)
rubidium
parents:
7157
diff
changeset
|
851 |
DrawCatenary(ti); |
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
852 |
|
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
853 |
catenary = true; |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
854 |
StartSpriteCombine(); |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
855 |
DrawCatenaryOnTunnel(ti); |
7159
aec2b7823dc6
(svn r9894) -Fix (r9892): catenary was drawn on road bridges ;)
rubidium
parents:
7157
diff
changeset
|
856 |
} |
0 | 857 |
|
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
858 |
AddSortableSpriteToDraw(image + 1, PAL_NONE, ti->x + TILE_SIZE - 1, ti->y + TILE_SIZE - 1, BB_data[0], BB_data[1], TILE_HEIGHT, ti->z, false, BB_data[2], BB_data[3], BB_Z_SEPARATOR); |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
859 |
|
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
860 |
if (catenary) EndSpriteCombine(); |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
861 |
|
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
862 |
/* Add helper BB for sprite sorting, that separate the tunnel from things beside of it */ |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
863 |
AddSortableSpriteToDraw(SPR_EMPTY_BOUNDING_BOX, PAL_NONE, ti->x , ti->y , BB_data[6], BB_data[7], TILE_HEIGHT, ti->z); |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
864 |
AddSortableSpriteToDraw(SPR_EMPTY_BOUNDING_BOX, PAL_NONE, ti->x + BB_data[4], ti->y + BB_data[5], BB_data[6], BB_data[7], TILE_HEIGHT, ti->z); |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
865 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
866 |
DrawBridgeMiddle(ti); |
3234
986c30171e92
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3233
diff
changeset
|
867 |
} else if (IsBridge(ti->tile)) { // XXX is this necessary? |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
868 |
const PalSpriteID *psid; |
2536
8c4e298f4886
(svn r3065) -Codechange/Add: Modified the bridge drawing code so that the basic offset is read from the RailTypeInfo struct. This is (hopefully) the last DrawTile change on the way to electrified railways. While being at it, de-mystified the function a bit and added some asserts.
celestar
parents:
2535
diff
changeset
|
869 |
int base_offset; |
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
870 |
bool ice = HasTunnelBridgeSnowOrDesert(ti->tile); |
0 | 871 |
|
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
872 |
if (GetTunnelBridgeTransportType(ti->tile) == TRANSPORT_RAIL) { |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
873 |
base_offset = GetRailTypeInfo(GetRailType(ti->tile))->bridge_offset; |
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6902
diff
changeset
|
874 |
assert(base_offset != 8); // This one is used for roads |
3234
986c30171e92
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3233
diff
changeset
|
875 |
} else { |
986c30171e92
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3233
diff
changeset
|
876 |
base_offset = 8; |
2536
8c4e298f4886
(svn r3065) -Codechange/Add: Modified the bridge drawing code so that the basic offset is read from the RailTypeInfo struct. This is (hopefully) the last DrawTile change on the way to electrified railways. While being at it, de-mystified the function a bit and added some asserts.
celestar
parents:
2535
diff
changeset
|
877 |
} |
8c4e298f4886
(svn r3065) -Codechange/Add: Modified the bridge drawing code so that the basic offset is read from the RailTypeInfo struct. This is (hopefully) the last DrawTile change on the way to electrified railways. While being at it, de-mystified the function a bit and added some asserts.
celestar
parents:
2535
diff
changeset
|
878 |
|
8c4e298f4886
(svn r3065) -Codechange/Add: Modified the bridge drawing code so that the basic offset is read from the RailTypeInfo struct. This is (hopefully) the last DrawTile change on the way to electrified railways. While being at it, de-mystified the function a bit and added some asserts.
celestar
parents:
2535
diff
changeset
|
879 |
/* as the lower 3 bits are used for other stuff, make sure they are clear */ |
8c4e298f4886
(svn r3065) -Codechange/Add: Modified the bridge drawing code so that the basic offset is read from the RailTypeInfo struct. This is (hopefully) the last DrawTile change on the way to electrified railways. While being at it, de-mystified the function a bit and added some asserts.
celestar
parents:
2535
diff
changeset
|
880 |
assert( (base_offset & 0x07) == 0x00); |
0 | 881 |
|
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
882 |
DrawFoundation(ti, GetBridgeFoundation(ti->tileh, DiagDirToAxis(GetTunnelBridgeDirection(ti->tile)))); |
3977
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3938
diff
changeset
|
883 |
|
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6902
diff
changeset
|
884 |
/* HACK Wizardry to convert the bridge ramp direction into a sprite offset */ |
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
885 |
base_offset += (6 - GetTunnelBridgeDirection(ti->tile)) % 4; |
3977
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3938
diff
changeset
|
886 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
887 |
if (ti->tileh == SLOPE_FLAT) base_offset += 4; // sloped bridge head |
3977
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3938
diff
changeset
|
888 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
889 |
/* Table number 6 always refers to the bridge heads for any bridge type */ |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
890 |
psid = &GetBridgeSpriteTable(GetBridgeType(ti->tile), 6)[base_offset]; |
3977
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3938
diff
changeset
|
891 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
892 |
if (!ice) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
893 |
DrawClearLandTile(ti, 3); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
894 |
} else { |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
895 |
DrawGroundSprite(SPR_FLAT_SNOWY_TILE + _tileh_to_sprite[ti->tileh], PAL_NONE); |
3977
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3938
diff
changeset
|
896 |
} |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
897 |
|
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6902
diff
changeset
|
898 |
/* draw ramp */ |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
899 |
|
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
900 |
/* Draw Trambits as SpriteCombine */ |
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
901 |
if (GetTunnelBridgeTransportType(ti->tile) == TRANSPORT_ROAD) StartSpriteCombine(); |
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
902 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
903 |
/* HACK set the height of the BB of a sloped ramp to 1 so a vehicle on |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
904 |
* it doesn't disappear behind it |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
905 |
*/ |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
906 |
AddSortableSpriteToDraw( |
8345
6caa3fdb972c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
8341
diff
changeset
|
907 |
psid->sprite, psid->pal, ti->x, ti->y, 16, 16, ti->tileh == SLOPE_FLAT ? 0 : 8, ti->z, IsTransparencySet(TO_BRIDGES) |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
908 |
); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
909 |
|
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
910 |
if (GetTunnelBridgeTransportType(ti->tile) == TRANSPORT_ROAD) { |
7187
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
911 |
RoadTypes rts = GetRoadTypes(ti->tile); |
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
912 |
|
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8419
diff
changeset
|
913 |
if (HasBit(rts, ROADTYPE_TRAM)) { |
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
914 |
uint offset = GetTunnelBridgeDirection(ti->tile); |
7208
25c522dd9cb1
(svn r9944) -Fix: tile selection drawn on the wrong height for some road bridges.
rubidium
parents:
7204
diff
changeset
|
915 |
uint z = ti->z; |
7187
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
916 |
if (ti->tileh != SLOPE_FLAT) { |
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
917 |
offset = (offset + 1) & 1; |
7208
25c522dd9cb1
(svn r9944) -Fix: tile selection drawn on the wrong height for some road bridges.
rubidium
parents:
7204
diff
changeset
|
918 |
z += TILE_HEIGHT; |
7187
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
919 |
} else { |
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
920 |
offset += 2; |
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
921 |
} |
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
922 |
/* DrawBridgeTramBits() calls EndSpriteCombine() and StartSpriteCombine() */ |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8419
diff
changeset
|
923 |
DrawBridgeTramBits(ti->x, ti->y, z, offset, HasBit(rts, ROADTYPE_ROAD)); |
7187
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
924 |
} |
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
925 |
EndSpriteCombine(); |
7187
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
926 |
} else if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) { |
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
927 |
DrawCatenary(ti); |
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
928 |
} |
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
929 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
930 |
DrawBridgeMiddle(ti); |
7539
eea0981e7f1a
(svn r10308) -Codechange: some "cleanup" chunks from B. N. SmatZ!' work on fixing FS#119.
rubidium
parents:
7538
diff
changeset
|
931 |
} else { |
eea0981e7f1a
(svn r10308) -Codechange: some "cleanup" chunks from B. N. SmatZ!' work on fixing FS#119.
rubidium
parents:
7538
diff
changeset
|
932 |
NOT_REACHED(); |
3933 | 933 |
} |
934 |
} |
|
935 |
||
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
936 |
|
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
937 |
/** Compute bridge piece. Computes the bridge piece to display depending on the position inside the bridge. |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
938 |
* bridges pieces sequence (middle parts) |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
939 |
* bridge len 1: 0 |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
940 |
* bridge len 2: 0 1 |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
941 |
* bridge len 3: 0 4 1 |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
942 |
* bridge len 4: 0 2 3 1 |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
943 |
* bridge len 5: 0 2 5 3 1 |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
944 |
* bridge len 6: 0 2 3 2 3 1 |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
945 |
* bridge len 7: 0 2 3 4 2 3 1 |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
946 |
* #0 - always as first, #1 - always as last (if len>1) |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
947 |
* #2,#3 are to pair in order |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
948 |
* for odd bridges: #5 is going in the bridge middle if on even position, #4 on odd (counting from 0) |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
949 |
* @param north Northernmost tile of bridge |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
950 |
* @param south Southernmost tile of bridge |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
951 |
* @return Index of bridge piece |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
952 |
*/ |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
953 |
static uint CalcBridgePiece(uint north, uint south) |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
954 |
{ |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
955 |
if (north == 1) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
956 |
return 0; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
957 |
} else if (south == 1) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
958 |
return 1; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
959 |
} else if (north < south) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
960 |
return north & 1 ? 3 : 2; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
961 |
} else if (north > south) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
962 |
return south & 1 ? 2 : 3; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
963 |
} else { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
964 |
return north & 1 ? 5 : 4; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
965 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
966 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
967 |
|
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
968 |
|
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
969 |
void DrawBridgeMiddle(const TileInfo* ti) |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
970 |
{ |
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
971 |
/* Sectional view of bridge bounding boxes: |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
972 |
* |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
973 |
* 1 2 1,2 = SpriteCombine of Bridge front/(back&floor) and TramCatenary |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
974 |
* 1 2 3 = empty helper BB |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
975 |
* 1 7 2 4,5 = pillars under higher bridges |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
976 |
* 1 6 88888 6 2 6 = elrail-pylons |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
977 |
* 1 6 88888 6 2 7 = elrail-wire |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
978 |
* 1 6 88888 6 2 <- TILE_HEIGHT 8 = rail-vehicle on bridge |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
979 |
* 3333333333333 <- BB_Z_SEPARATOR |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
980 |
* <- unused |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
981 |
* 4 5 <- BB_HEIGHT_UNDER_BRIDGE |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
982 |
* 4 5 |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
983 |
* 4 5 |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
984 |
* |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
985 |
*/ |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
986 |
|
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
987 |
/* Z position of the bridge sprites relative to bridge height (downwards) */ |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
988 |
static const int BRIDGE_Z_START = 3; |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
989 |
|
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
990 |
const PalSpriteID* psid; |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
991 |
uint base_offset; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
992 |
TileIndex rampnorth; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
993 |
TileIndex rampsouth; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
994 |
Axis axis; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
995 |
uint piece; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
996 |
uint type; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
997 |
int x; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
998 |
int y; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
999 |
uint z; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1000 |
|
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1001 |
if (!IsBridgeAbove(ti->tile)) return; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1002 |
|
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1003 |
rampnorth = GetNorthernBridgeEnd(ti->tile); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1004 |
rampsouth = GetSouthernBridgeEnd(ti->tile); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1005 |
|
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1006 |
axis = GetBridgeAxis(ti->tile); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1007 |
piece = CalcBridgePiece( |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1008 |
DistanceManhattan(ti->tile, rampnorth), |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1009 |
DistanceManhattan(ti->tile, rampsouth) |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1010 |
); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1011 |
type = GetBridgeType(rampsouth); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1012 |
|
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
1013 |
if (GetTunnelBridgeTransportType(rampsouth) == TRANSPORT_RAIL) { |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1014 |
base_offset = GetRailTypeInfo(GetRailType(rampsouth))->bridge_offset; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1015 |
} else { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1016 |
base_offset = 8; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1017 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1018 |
|
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
1019 |
psid = base_offset + GetBridgeSpriteTable(type, piece); |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
1020 |
if (axis != AXIS_X) psid += 4; |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1021 |
|
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1022 |
x = ti->x; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1023 |
y = ti->y; |
7187
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
1024 |
uint bridge_z = GetBridgeHeight(rampsouth); |
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
1025 |
z = bridge_z - BRIDGE_Z_START; |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1026 |
|
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
1027 |
/* Add a bounding box, that separates the bridge from things below it. */ |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
1028 |
AddSortableSpriteToDraw(SPR_EMPTY_BOUNDING_BOX, PAL_NONE, x, y, 16, 16, 1, bridge_z - TILE_HEIGHT + BB_Z_SEPARATOR); |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
1029 |
|
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
1030 |
/* Draw Trambits as SpriteCombine */ |
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
1031 |
if (GetTunnelBridgeTransportType(rampsouth) == TRANSPORT_ROAD) StartSpriteCombine(); |
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
1032 |
|
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
1033 |
/* Draw floor and far part of bridge*/ |
7829
88883899c9e6
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium
parents:
7804
diff
changeset
|
1034 |
if (axis == AXIS_X) { |
8345
6caa3fdb972c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
8341
diff
changeset
|
1035 |
AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 16, 1, 0x28, z, IsTransparencySet(TO_BRIDGES), 0, 0, BRIDGE_Z_START); |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1036 |
} else { |
8345
6caa3fdb972c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
8341
diff
changeset
|
1037 |
AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 1, 16, 0x28, z, IsTransparencySet(TO_BRIDGES), 0, 0, BRIDGE_Z_START); |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
1038 |
} |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
1039 |
|
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
1040 |
psid++; |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1041 |
|
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
1042 |
if (GetTunnelBridgeTransportType(rampsouth) == TRANSPORT_ROAD) { |
7187
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
1043 |
RoadTypes rts = GetRoadTypes(rampsouth); |
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
1044 |
|
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8419
diff
changeset
|
1045 |
if (HasBit(rts, ROADTYPE_TRAM)) { |
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
1046 |
/* DrawBridgeTramBits() calls EndSpriteCombine() and StartSpriteCombine() */ |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8419
diff
changeset
|
1047 |
DrawBridgeTramBits(x, y, bridge_z, axis ^ 1, HasBit(rts, ROADTYPE_ROAD)); |
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
1048 |
} else { |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
1049 |
EndSpriteCombine(); |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
1050 |
StartSpriteCombine(); |
7187
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
1051 |
} |
f7dc3204d457
(svn r9923) -Add: support for Action 0 Road vehicles, property 1C, bit 0.
rubidium
parents:
7183
diff
changeset
|
1052 |
} else if (GetRailType(rampsouth) == RAILTYPE_ELECTRIC) { |
7183
23b20a982228
(svn r9919) -Codechange: prepare some more places for more road types.
rubidium
parents:
7179
diff
changeset
|
1053 |
DrawCatenary(ti); |
23b20a982228
(svn r9919) -Codechange: prepare some more places for more road types.
rubidium
parents:
7179
diff
changeset
|
1054 |
} |
23b20a982228
(svn r9919) -Codechange: prepare some more places for more road types.
rubidium
parents:
7179
diff
changeset
|
1055 |
|
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6902
diff
changeset
|
1056 |
/* draw roof, the component of the bridge which is logically between the vehicle and the camera */ |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1057 |
if (axis == AXIS_X) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1058 |
y += 12; |
8345
6caa3fdb972c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
8341
diff
changeset
|
1059 |
if (psid->sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 16, 4, 0x28, z, IsTransparencySet(TO_BRIDGES), 0, 3, BRIDGE_Z_START); |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1060 |
} else { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1061 |
x += 12; |
8345
6caa3fdb972c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
8341
diff
changeset
|
1062 |
if (psid->sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 4, 16, 0x28, z, IsTransparencySet(TO_BRIDGES), 3, 0, BRIDGE_Z_START); |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1063 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1064 |
|
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
1065 |
/* Draw TramFront as SpriteCombine */ |
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
1066 |
if (GetTunnelBridgeTransportType(rampsouth) == TRANSPORT_ROAD) EndSpriteCombine(); |
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8083
diff
changeset
|
1067 |
|
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
1068 |
psid++; |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1069 |
if (ti->z + 5 == z) { |
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6902
diff
changeset
|
1070 |
/* draw poles below for small bridges */ |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
1071 |
if (psid->sprite != 0) { |
7829
88883899c9e6
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium
parents:
7804
diff
changeset
|
1072 |
SpriteID image = psid->sprite; |
88883899c9e6
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium
parents:
7804
diff
changeset
|
1073 |
SpriteID pal = psid->pal; |
8345
6caa3fdb972c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
8341
diff
changeset
|
1074 |
if (IsTransparencySet(TO_BRIDGES)) { |
8427
143b0be22af1
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents:
8425
diff
changeset
|
1075 |
SetBit(image, PALETTE_MODIFIER_TRANSPARENT); |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
1076 |
pal = PALETTE_TO_TRANSPARENT; |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
1077 |
} |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
1078 |
|
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
1079 |
DrawGroundSpriteAt(image, pal, x, y, z); |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1080 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1081 |
} else if (_patches.bridge_pillars) { |
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6902
diff
changeset
|
1082 |
/* draw pillars below for high bridges */ |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
1083 |
DrawBridgePillars(psid, ti, axis, type, x, y, z); |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1084 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1085 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1086 |
|
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1087 |
|
4231
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4191
diff
changeset
|
1088 |
static uint GetSlopeZ_TunnelBridge(TileIndex tile, uint x, uint y) |
2537 | 1089 |
{ |
4231
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4191
diff
changeset
|
1090 |
uint z; |
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4191
diff
changeset
|
1091 |
Slope tileh = GetTileSlope(tile, &z); |
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4191
diff
changeset
|
1092 |
|
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4191
diff
changeset
|
1093 |
x &= 0xF; |
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4191
diff
changeset
|
1094 |
y &= 0xF; |
0 | 1095 |
|
3517
76814013e912
(svn r4373) Rewrite GetSlopeZ_TunnelBridge() and slightly change its behavior:
tron
parents:
3493
diff
changeset
|
1096 |
if (IsTunnel(tile)) { |
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
1097 |
uint pos = (DiagDirToAxis(GetTunnelBridgeDirection(tile)) == AXIS_X ? y : x); |
0 | 1098 |
|
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6902
diff
changeset
|
1099 |
/* In the tunnel entrance? */ |
3517
76814013e912
(svn r4373) Rewrite GetSlopeZ_TunnelBridge() and slightly change its behavior:
tron
parents:
3493
diff
changeset
|
1100 |
if (5 <= pos && pos <= 10) return z; |
76814013e912
(svn r4373) Rewrite GetSlopeZ_TunnelBridge() and slightly change its behavior:
tron
parents:
3493
diff
changeset
|
1101 |
} else { |
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
1102 |
DiagDirection dir = GetTunnelBridgeDirection(tile); |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1103 |
uint pos = (DiagDirToAxis(dir) == AXIS_X ? y : x); |
3977
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3938
diff
changeset
|
1104 |
|
7831
5dded9b03500
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7829
diff
changeset
|
1105 |
z += ApplyFoundationToSlope(GetBridgeFoundation(tileh, DiagDirToAxis(dir)), &tileh); |
5dded9b03500
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7829
diff
changeset
|
1106 |
|
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6902
diff
changeset
|
1107 |
/* On the bridge ramp? */ |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1108 |
if (5 <= pos && pos <= 10) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1109 |
uint delta; |
4246
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4239
diff
changeset
|
1110 |
|
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8419
diff
changeset
|
1111 |
if (HasBit(BRIDGE_HORZ_RAMP, tileh)) return z + TILE_HEIGHT; |
3517
76814013e912
(svn r4373) Rewrite GetSlopeZ_TunnelBridge() and slightly change its behavior:
tron
parents:
3493
diff
changeset
|
1112 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1113 |
switch (dir) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1114 |
default: NOT_REACHED(); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1115 |
case DIAGDIR_NE: delta = (TILE_SIZE - 1 - x) / 2; break; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1116 |
case DIAGDIR_SE: delta = y / 2; break; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1117 |
case DIAGDIR_SW: delta = x / 2; break; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1118 |
case DIAGDIR_NW: delta = (TILE_SIZE - 1 - y) / 2; break; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1119 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1120 |
return z + 1 + delta; |
0 | 1121 |
} |
1122 |
} |
|
1123 |
||
3517
76814013e912
(svn r4373) Rewrite GetSlopeZ_TunnelBridge() and slightly change its behavior:
tron
parents:
3493
diff
changeset
|
1124 |
return z + GetPartialZ(x, y, tileh); |
0 | 1125 |
} |
1126 |
||
7831
5dded9b03500
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7829
diff
changeset
|
1127 |
static Foundation GetFoundation_TunnelBridge(TileIndex tile, Slope tileh) |
2639 | 1128 |
{ |
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
1129 |
return IsTunnel(tile) ? FOUNDATION_NONE : GetBridgeFoundation(tileh, DiagDirToAxis(GetTunnelBridgeDirection(tile))); |
39 | 1130 |
} |
1131 |
||
1132 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1930
diff
changeset
|
1133 |
static void GetAcceptedCargo_TunnelBridge(TileIndex tile, AcceptedCargo ac) |
0 | 1134 |
{ |
1135 |
/* not used */ |
|
1136 |
} |
|
1137 |
||
1138 |
static const StringID _bridge_tile_str[(MAX_BRIDGES + 3) + (MAX_BRIDGES + 3)] = { |
|
1139 |
STR_501F_WOODEN_RAIL_BRIDGE, |
|
1140 |
STR_5020_CONCRETE_RAIL_BRIDGE, |
|
1141 |
STR_501C_STEEL_GIRDER_RAIL_BRIDGE, |
|
1142 |
STR_501E_REINFORCED_CONCRETE_SUSPENSION, |
|
1143 |
STR_501B_STEEL_SUSPENSION_RAIL_BRIDGE, |
|
1144 |
STR_501B_STEEL_SUSPENSION_RAIL_BRIDGE, |
|
1145 |
STR_501D_STEEL_CANTILEVER_RAIL_BRIDGE, |
|
1146 |
STR_501D_STEEL_CANTILEVER_RAIL_BRIDGE, |
|
1147 |
STR_501D_STEEL_CANTILEVER_RAIL_BRIDGE, |
|
1148 |
STR_501C_STEEL_GIRDER_RAIL_BRIDGE, |
|
1149 |
STR_5027_TUBULAR_RAIL_BRIDGE, |
|
1150 |
STR_5027_TUBULAR_RAIL_BRIDGE, |
|
1151 |
STR_5027_TUBULAR_RAIL_BRIDGE, |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4304
diff
changeset
|
1152 |
0, 0, 0, |
0 | 1153 |
|
1154 |
STR_5025_WOODEN_ROAD_BRIDGE, |
|
1155 |
STR_5026_CONCRETE_ROAD_BRIDGE, |
|
1156 |
STR_5022_STEEL_GIRDER_ROAD_BRIDGE, |
|
1157 |
STR_5024_REINFORCED_CONCRETE_SUSPENSION, |
|
1158 |
STR_5021_STEEL_SUSPENSION_ROAD_BRIDGE, |
|
1159 |
STR_5021_STEEL_SUSPENSION_ROAD_BRIDGE, |
|
1160 |
STR_5023_STEEL_CANTILEVER_ROAD_BRIDGE, |
|
1161 |
STR_5023_STEEL_CANTILEVER_ROAD_BRIDGE, |
|
1162 |
STR_5023_STEEL_CANTILEVER_ROAD_BRIDGE, |
|
1163 |
STR_5022_STEEL_GIRDER_ROAD_BRIDGE, |
|
1164 |
STR_5028_TUBULAR_ROAD_BRIDGE, |
|
1165 |
STR_5028_TUBULAR_ROAD_BRIDGE, |
|
1166 |
STR_5028_TUBULAR_ROAD_BRIDGE, |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4304
diff
changeset
|
1167 |
0, 0, 0, |
0 | 1168 |
}; |
1169 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1930
diff
changeset
|
1170 |
static void GetTileDesc_TunnelBridge(TileIndex tile, TileDesc *td) |
0 | 1171 |
{ |
3184
7405329343ce
(svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents:
3183
diff
changeset
|
1172 |
if (IsTunnel(tile)) { |
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
1173 |
td->str = (GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) ? |
3154 | 1174 |
STR_5017_RAILROAD_TUNNEL : STR_5018_ROAD_TUNNEL; |
0 | 1175 |
} else { |
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
1176 |
td->str = _bridge_tile_str[GetTunnelBridgeTransportType(tile) << 4 | GetBridgeType(tile)]; |
0 | 1177 |
} |
1901
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
1178 |
td->owner = GetTileOwner(tile); |
0 | 1179 |
} |
1180 |
||
1181 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1930
diff
changeset
|
1182 |
static void AnimateTile_TunnelBridge(TileIndex tile) |
0 | 1183 |
{ |
1184 |
/* not used */ |
|
1185 |
} |
|
1186 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1930
diff
changeset
|
1187 |
static void TileLoop_TunnelBridge(TileIndex tile) |
0 | 1188 |
{ |
8584
a8b6dffead63
(svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz
parents:
8579
diff
changeset
|
1189 |
bool snow_or_desert = HasTunnelBridgeSnowOrDesert(tile); |
3017
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
1190 |
switch (_opt.landscape) { |
6683
7ec558346172
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6669
diff
changeset
|
1191 |
case LT_ARCTIC: |
6669
487ac09b95c4
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6585
diff
changeset
|
1192 |
if (snow_or_desert != (GetTileZ(tile) > GetSnowLine())) { |
8584
a8b6dffead63
(svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz
parents:
8579
diff
changeset
|
1193 |
SetTunnelBridgeSnowOrDesert(tile, !snow_or_desert); |
4160 | 1194 |
MarkTileDirtyByTile(tile); |
3017
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
1195 |
} |
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
1196 |
break; |
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
1197 |
|
6683
7ec558346172
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6669
diff
changeset
|
1198 |
case LT_TROPIC: |
5661
6c6145677e7c
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
rubidium
parents:
5573
diff
changeset
|
1199 |
if (GetTropicZone(tile) == TROPICZONE_DESERT && !snow_or_desert) { |
8584
a8b6dffead63
(svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz
parents:
8579
diff
changeset
|
1200 |
SetTunnelBridgeSnowOrDesert(tile, true); |
0 | 1201 |
MarkTileDirtyByTile(tile); |
1202 |
} |
|
3017
915fae59d5e0
(svn r3597) Miscellaneous (I like that word) changes: Fix some indentation, add consts, reduce indentation level by short-circuit logic, convert if cascades to switch, whitespace, bracing, plus some minor stuff
tron
parents:
2989
diff
changeset
|
1203 |
break; |
8584
a8b6dffead63
(svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz
parents:
8579
diff
changeset
|
1204 |
|
a8b6dffead63
(svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz
parents:
8579
diff
changeset
|
1205 |
default: |
a8b6dffead63
(svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz
parents:
8579
diff
changeset
|
1206 |
break; |
0 | 1207 |
} |
1208 |
} |
|
1209 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1930
diff
changeset
|
1210 |
static void ClickTile_TunnelBridge(TileIndex tile) |
0 | 1211 |
{ |
1212 |
/* not used */ |
|
1213 |
} |
|
1214 |
||
1215 |
||
7179
3e123c2b7c93
(svn r9914) -Codechange: prepare GTTS and the pathfinders to handle multiple road types on a single tile.
rubidium
parents:
7159
diff
changeset
|
1216 |
static uint32 GetTileTrackStatus_TunnelBridge(TileIndex tile, TransportType mode, uint sub_mode) |
0 | 1217 |
{ |
8584
a8b6dffead63
(svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz
parents:
8579
diff
changeset
|
1218 |
if (GetTunnelBridgeTransportType(tile) != mode) return 0; |
a8b6dffead63
(svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz
parents:
8579
diff
changeset
|
1219 |
if (GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD && (GetRoadTypes(tile) & sub_mode) == 0) return 0; |
a8b6dffead63
(svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz
parents:
8579
diff
changeset
|
1220 |
return AxisToTrackBits(DiagDirToAxis(GetTunnelBridgeDirection(tile))) * 0x101; |
0 | 1221 |
} |
1222 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2422
diff
changeset
|
1223 |
static void ChangeTileOwner_TunnelBridge(TileIndex tile, PlayerID old_player, PlayerID new_player) |
0 | 1224 |
{ |
1901
fb05044cf5c3
(svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron
parents:
1891
diff
changeset
|
1225 |
if (!IsTileOwner(tile, old_player)) return; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
1226 |
|
4848
56549aa3e234
(svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents:
4656
diff
changeset
|
1227 |
if (new_player != PLAYER_SPECTATOR) { |
1902 | 1228 |
SetTileOwner(tile, new_player); |
4434
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4344
diff
changeset
|
1229 |
} else { |
7230
a80428b3e1fa
(svn r9966) -Fix: bridges and tunnels were not always removed on bankruptcy, thus leaving tunnels/bridges with an invalid owner that would crash the game when clicking with the query tool on them.
rubidium
parents:
7208
diff
changeset
|
1230 |
if (CmdFailed(DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) { |
a80428b3e1fa
(svn r9966) -Fix: bridges and tunnels were not always removed on bankruptcy, thus leaving tunnels/bridges with an invalid owner that would crash the game when clicking with the query tool on them.
rubidium
parents:
7208
diff
changeset
|
1231 |
/* When clearing the bridge/tunnel failed there are still vehicles on/in |
a80428b3e1fa
(svn r9966) -Fix: bridges and tunnels were not always removed on bankruptcy, thus leaving tunnels/bridges with an invalid owner that would crash the game when clicking with the query tool on them.
rubidium
parents:
7208
diff
changeset
|
1232 |
* the bridge/tunnel. As all *our* vehicles are already removed, they |
a80428b3e1fa
(svn r9966) -Fix: bridges and tunnels were not always removed on bankruptcy, thus leaving tunnels/bridges with an invalid owner that would crash the game when clicking with the query tool on them.
rubidium
parents:
7208
diff
changeset
|
1233 |
* must be of another owner. Therefor this must be a road bridge/tunnel. |
a80428b3e1fa
(svn r9966) -Fix: bridges and tunnels were not always removed on bankruptcy, thus leaving tunnels/bridges with an invalid owner that would crash the game when clicking with the query tool on them.
rubidium
parents:
7208
diff
changeset
|
1234 |
* In that case we can safely reassign the ownership to OWNER_NONE. */ |
8584
a8b6dffead63
(svn r11649) -Codechange: some code can be simplified thanks to changes in r11642
smatz
parents:
8579
diff
changeset
|
1235 |
assert(GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD); |
7230
a80428b3e1fa
(svn r9966) -Fix: bridges and tunnels were not always removed on bankruptcy, thus leaving tunnels/bridges with an invalid owner that would crash the game when clicking with the query tool on them.
rubidium
parents:
7208
diff
changeset
|
1236 |
SetTileOwner(tile, OWNER_NONE); |
a80428b3e1fa
(svn r9966) -Fix: bridges and tunnels were not always removed on bankruptcy, thus leaving tunnels/bridges with an invalid owner that would crash the game when clicking with the query tool on them.
rubidium
parents:
7208
diff
changeset
|
1237 |
} |
0 | 1238 |
} |
1239 |
} |
|
1240 |
||
1241 |
||
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4304
diff
changeset
|
1242 |
static const byte _tunnel_fractcoord_1[4] = {0x8E, 0x18, 0x81, 0xE8}; |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4304
diff
changeset
|
1243 |
static const byte _tunnel_fractcoord_2[4] = {0x81, 0x98, 0x87, 0x38}; |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4304
diff
changeset
|
1244 |
static const byte _tunnel_fractcoord_3[4] = {0x82, 0x88, 0x86, 0x48}; |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4304
diff
changeset
|
1245 |
static const byte _exit_tunnel_track[4] = {1, 2, 1, 2}; |
0 | 1246 |
|
6326
c904c7ea1c8d
(svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents:
6319
diff
changeset
|
1247 |
/** Get the trackdir of the exit of a tunnel */ |
c904c7ea1c8d
(svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents:
6319
diff
changeset
|
1248 |
static const Trackdir _road_exit_tunnel_state[DIAGDIR_END] = { |
c904c7ea1c8d
(svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents:
6319
diff
changeset
|
1249 |
TRACKDIR_X_SW, TRACKDIR_Y_NW, TRACKDIR_X_NE, TRACKDIR_Y_SE |
c904c7ea1c8d
(svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents:
6319
diff
changeset
|
1250 |
}; |
0 | 1251 |
static const byte _road_exit_tunnel_frame[4] = {2, 7, 9, 4}; |
1252 |
||
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4304
diff
changeset
|
1253 |
static const byte _tunnel_fractcoord_4[4] = {0x52, 0x85, 0x98, 0x29}; |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4304
diff
changeset
|
1254 |
static const byte _tunnel_fractcoord_5[4] = {0x92, 0x89, 0x58, 0x25}; |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4304
diff
changeset
|
1255 |
static const byte _tunnel_fractcoord_6[4] = {0x92, 0x89, 0x56, 0x45}; |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4304
diff
changeset
|
1256 |
static const byte _tunnel_fractcoord_7[4] = {0x52, 0x85, 0x96, 0x49}; |
0 | 1257 |
|
8615
6b91ca653bad
(svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
8612
diff
changeset
|
1258 |
static VehicleEnterTileStatus VehicleEnter_TunnelBridge(Vehicle *v, TileIndex tile, int x, int y) |
0 | 1259 |
{ |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1260 |
int z = GetSlopeZ(x, y) - v->z_pos; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1261 |
|
8419
de9999f762d0
(svn r11476) -Codechange: rename the function myabs to abs to get rid of an unneeded define
skidd13
parents:
8353
diff
changeset
|
1262 |
if (abs(z) > 2) return VETSB_CANNOT_ENTER; |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1263 |
|
3184
7405329343ce
(svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents:
3183
diff
changeset
|
1264 |
if (IsTunnel(tile)) { |
2989 | 1265 |
byte fc; |
3153
301c1d71122b
(svn r3776) Replace many ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3144
diff
changeset
|
1266 |
DiagDirection dir; |
301c1d71122b
(svn r3776) Replace many ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3144
diff
changeset
|
1267 |
DiagDirection vdir; |
2989 | 1268 |
|
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6574
diff
changeset
|
1269 |
if (v->type == VEH_TRAIN) { |
2951 | 1270 |
fc = (x & 0xF) + (y << 4); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
1271 |
|
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
1272 |
dir = GetTunnelBridgeDirection(tile); |
3153
301c1d71122b
(svn r3776) Replace many ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3144
diff
changeset
|
1273 |
vdir = DirToDiagDir(v->direction); |
0 | 1274 |
|
6319
27e68b914d3d
(svn r8701) -Codechange: replace magic numbers with enums for u.rail.track.
rubidium
parents:
6317
diff
changeset
|
1275 |
if (v->u.rail.track != TRACK_BIT_WORMHOLE && dir == vdir) { |
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
2663
diff
changeset
|
1276 |
if (IsFrontEngine(v) && fc == _tunnel_fractcoord_1[dir]) { |
6539
6824b94ed21c
(svn r9009) -Fix (r1): Determine whether to play a sound or not when entering a tunnel based on engine type (only steam engines) instead of on spritenum which can be invalid for newgrf trains. DBSet(XL) or any other steam trains without newsounds should sound their horn now.
Darkvater
parents:
6467
diff
changeset
|
1277 |
if (!PlayVehicleSound(v, VSE_TUNNEL) && RailVehInfo(v->engine_type)->engclass == 0) { |
541 | 1278 |
SndPlayVehicleFx(SND_05_TRAIN_THROUGH_TUNNEL, v); |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4559
diff
changeset
|
1279 |
} |
6317
c73bda71ac16
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents:
6181
diff
changeset
|
1280 |
return VETSB_CONTINUE; |
0 | 1281 |
} |
1282 |
if (fc == _tunnel_fractcoord_2[dir]) { |
|
1283 |
v->tile = tile; |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1284 |
v->u.rail.track = TRACK_BIT_WORMHOLE; |
0 | 1285 |
v->vehstatus |= VS_HIDDEN; |
6317
c73bda71ac16
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents:
6181
diff
changeset
|
1286 |
return VETSB_ENTERED_WORMHOLE; |
0 | 1287 |
} |
1288 |
} |
|
1289 |
||
3153
301c1d71122b
(svn r3776) Replace many ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3144
diff
changeset
|
1290 |
if (dir == ReverseDiagDir(vdir) && fc == _tunnel_fractcoord_3[dir] && z == 0) { |
22 | 1291 |
/* We're at the tunnel exit ?? */ |
0 | 1292 |
v->tile = tile; |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1293 |
v->u.rail.track = (TrackBits)_exit_tunnel_track[dir]; |
1330
8a67d04016ce
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1209
diff
changeset
|
1294 |
assert(v->u.rail.track); |
0 | 1295 |
v->vehstatus &= ~VS_HIDDEN; |
6317
c73bda71ac16
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents:
6181
diff
changeset
|
1296 |
return VETSB_ENTERED_WORMHOLE; |
0 | 1297 |
} |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6574
diff
changeset
|
1298 |
} else if (v->type == VEH_ROAD) { |
2951 | 1299 |
fc = (x & 0xF) + (y << 4); |
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
1300 |
dir = GetTunnelBridgeDirection(tile); |
3153
301c1d71122b
(svn r3776) Replace many ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3144
diff
changeset
|
1301 |
vdir = DirToDiagDir(v->direction); |
0 | 1302 |
|
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6902
diff
changeset
|
1303 |
/* Enter tunnel? */ |
6326
c904c7ea1c8d
(svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents:
6319
diff
changeset
|
1304 |
if (v->u.road.state != RVSB_WORMHOLE && dir == vdir) { |
0 | 1305 |
if (fc == _tunnel_fractcoord_4[dir] || |
1306 |
fc == _tunnel_fractcoord_5[dir]) { |
|
1307 |
v->tile = tile; |
|
6326
c904c7ea1c8d
(svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents:
6319
diff
changeset
|
1308 |
v->u.road.state = RVSB_WORMHOLE; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
1309 |
v->vehstatus |= VS_HIDDEN; |
6317
c73bda71ac16
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents:
6181
diff
changeset
|
1310 |
return VETSB_ENTERED_WORMHOLE; |
0 | 1311 |
} else { |
6317
c73bda71ac16
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents:
6181
diff
changeset
|
1312 |
return VETSB_CONTINUE; |
0 | 1313 |
} |
1314 |
} |
|
1315 |
||
3153
301c1d71122b
(svn r3776) Replace many ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3144
diff
changeset
|
1316 |
if (dir == ReverseDiagDir(vdir) && ( |
2951 | 1317 |
/* We're at the tunnel exit ?? */ |
1318 |
fc == _tunnel_fractcoord_6[dir] || |
|
1319 |
fc == _tunnel_fractcoord_7[dir] |
|
1320 |
) && |
|
0 | 1321 |
z == 0) { |
1322 |
v->tile = tile; |
|
1323 |
v->u.road.state = _road_exit_tunnel_state[dir]; |
|
1324 |
v->u.road.frame = _road_exit_tunnel_frame[dir]; |
|
1325 |
v->vehstatus &= ~VS_HIDDEN; |
|
6317
c73bda71ac16
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents:
6181
diff
changeset
|
1326 |
return VETSB_ENTERED_WORMHOLE; |
0 | 1327 |
} |
1328 |
} |
|
3234
986c30171e92
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3233
diff
changeset
|
1329 |
} else if (IsBridge(tile)) { // XXX is this necessary? |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1330 |
DiagDirection dir; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1331 |
|
8044
72c3e2bc6429
(svn r11068) -Codechange: remove Vehicle::HasFront as all vehicles have the Vehicle::first pointer correctly set.
rubidium
parents:
8035
diff
changeset
|
1332 |
if (v->IsPrimaryVehicle()) { |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1333 |
/* modify speed of vehicle */ |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1334 |
uint16 spd = _bridge[GetBridgeType(tile)].speed; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1335 |
|
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6574
diff
changeset
|
1336 |
if (v->type == VEH_ROAD) spd *= 2; |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1337 |
if (v->cur_speed > spd) v->cur_speed = spd; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1338 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1339 |
|
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
1340 |
dir = GetTunnelBridgeDirection(tile); |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1341 |
if (DirToDiagDir(v->direction) == dir) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1342 |
switch (dir) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1343 |
default: NOT_REACHED(); |
6317
c73bda71ac16
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents:
6181
diff
changeset
|
1344 |
case DIAGDIR_NE: if ((x & 0xF) != 0) return VETSB_CONTINUE; break; |
c73bda71ac16
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents:
6181
diff
changeset
|
1345 |
case DIAGDIR_SE: if ((y & 0xF) != TILE_SIZE - 1) return VETSB_CONTINUE; break; |
c73bda71ac16
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents:
6181
diff
changeset
|
1346 |
case DIAGDIR_SW: if ((x & 0xF) != TILE_SIZE - 1) return VETSB_CONTINUE; break; |
c73bda71ac16
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents:
6181
diff
changeset
|
1347 |
case DIAGDIR_NW: if ((y & 0xF) != 0) return VETSB_CONTINUE; break; |
0 | 1348 |
} |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6574
diff
changeset
|
1349 |
if (v->type == VEH_TRAIN) { |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1350 |
v->u.rail.track = TRACK_BIT_WORMHOLE; |
8425
72a71d480c5f
(svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents:
8424
diff
changeset
|
1351 |
ClrBit(v->u.rail.flags, VRF_GOINGUP); |
72a71d480c5f
(svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents:
8424
diff
changeset
|
1352 |
ClrBit(v->u.rail.flags, VRF_GOINGDOWN); |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1353 |
} else { |
6326
c904c7ea1c8d
(svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents:
6319
diff
changeset
|
1354 |
v->u.road.state = RVSB_WORMHOLE; |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1355 |
} |
6317
c73bda71ac16
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents:
6181
diff
changeset
|
1356 |
return VETSB_ENTERED_WORMHOLE; |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1357 |
} else if (DirToDiagDir(v->direction) == ReverseDiagDir(dir)) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1358 |
v->tile = tile; |
6585
7da94b26498a
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6574
diff
changeset
|
1359 |
if (v->type == VEH_TRAIN) { |
6319
27e68b914d3d
(svn r8701) -Codechange: replace magic numbers with enums for u.rail.track.
rubidium
parents:
6317
diff
changeset
|
1360 |
if (v->u.rail.track == TRACK_BIT_WORMHOLE) { |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1361 |
v->u.rail.track = (DiagDirToAxis(dir) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y); |
6317
c73bda71ac16
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents:
6181
diff
changeset
|
1362 |
return VETSB_ENTERED_WORMHOLE; |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1363 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1364 |
} else { |
6326
c904c7ea1c8d
(svn r8715) -Codechange/cleanup: replace magic numbers related to state of road vehicles with enums. Original patch by mart3p.
rubidium
parents:
6319
diff
changeset
|
1365 |
if (v->u.road.state == RVSB_WORMHOLE) { |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1366 |
v->u.road.state = _road_exit_tunnel_state[dir]; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1367 |
v->u.road.frame = 0; |
6317
c73bda71ac16
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents:
6181
diff
changeset
|
1368 |
return VETSB_ENTERED_WORMHOLE; |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1369 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5116
diff
changeset
|
1370 |
} |
6317
c73bda71ac16
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents:
6181
diff
changeset
|
1371 |
return VETSB_CONTINUE; |
0 | 1372 |
} |
1373 |
} |
|
6317
c73bda71ac16
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents:
6181
diff
changeset
|
1374 |
return VETSB_CONTINUE; |
0 | 1375 |
} |
1376 |
||
7990
70039e33e893
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents:
7968
diff
changeset
|
1377 |
static CommandCost TerraformTile_TunnelBridge(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new) |
70039e33e893
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents:
7968
diff
changeset
|
1378 |
{ |
8078
bdf94bf88568
(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
parents:
8044
diff
changeset
|
1379 |
if (_patches.build_on_slopes && AutoslopeEnabled() && IsBridge(tile)) { |
8579
3efbb430092e
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
8577
diff
changeset
|
1380 |
DiagDirection direction = GetTunnelBridgeDirection(tile); |
8078
bdf94bf88568
(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
parents:
8044
diff
changeset
|
1381 |
Axis axis = DiagDirToAxis(direction); |
bdf94bf88568
(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
parents:
8044
diff
changeset
|
1382 |
CommandCost res; |
bdf94bf88568
(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
parents:
8044
diff
changeset
|
1383 |
|
bdf94bf88568
(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
parents:
8044
diff
changeset
|
1384 |
/* Check if new slope is valid for bridges in general (so we can savely call GetBridgeFoundation()) */ |
bdf94bf88568
(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
parents:
8044
diff
changeset
|
1385 |
if ((direction == DIAGDIR_NW) || (direction == DIAGDIR_NE)) { |
bdf94bf88568
(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
parents:
8044
diff
changeset
|
1386 |
res = CheckBridgeSlopeSouth(axis, tileh_new); |
bdf94bf88568
(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
parents:
8044
diff
changeset
|
1387 |
} else { |
bdf94bf88568
(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
parents:
8044
diff
changeset
|
1388 |
res = CheckBridgeSlopeNorth(axis, tileh_new); |
bdf94bf88568
(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
parents:
8044
diff
changeset
|
1389 |
} |
bdf94bf88568
(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
parents:
8044
diff
changeset
|
1390 |
|
bdf94bf88568
(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
parents:
8044
diff
changeset
|
1391 |
if (!CmdFailed(res)) { |
bdf94bf88568
(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
parents:
8044
diff
changeset
|
1392 |
uint z_old; |
bdf94bf88568
(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
parents:
8044
diff
changeset
|
1393 |
Slope tileh_old = GetTileSlope(tile, &z_old); |
bdf94bf88568
(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
parents:
8044
diff
changeset
|
1394 |
|
bdf94bf88568
(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
parents:
8044
diff
changeset
|
1395 |
z_old += ApplyFoundationToSlope(GetBridgeFoundation(tileh_old, axis), &tileh_old); |
bdf94bf88568
(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
parents:
8044
diff
changeset
|
1396 |
z_new += ApplyFoundationToSlope(GetBridgeFoundation(tileh_new, axis), &tileh_new); |
bdf94bf88568
(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
parents:
8044
diff
changeset
|
1397 |
|
bdf94bf88568
(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
parents:
8044
diff
changeset
|
1398 |
/* Surface slope remains unchanged? */ |
8726
5ae45b46506b
(svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium
parents:
8720
diff
changeset
|
1399 |
if ((z_old == z_new) && (tileh_old == tileh_new)) return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform); |
8078
bdf94bf88568
(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
parents:
8044
diff
changeset
|
1400 |
} |
bdf94bf88568
(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
parents:
8044
diff
changeset
|
1401 |
} |
bdf94bf88568
(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
parents:
8044
diff
changeset
|
1402 |
|
7990
70039e33e893
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents:
7968
diff
changeset
|
1403 |
return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
70039e33e893
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents:
7968
diff
changeset
|
1404 |
} |
70039e33e893
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents:
7968
diff
changeset
|
1405 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1406 |
extern const TileTypeProcs _tile_type_tunnelbridge_procs = { |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4304
diff
changeset
|
1407 |
DrawTile_TunnelBridge, /* draw_tile_proc */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4304
diff
changeset
|
1408 |
GetSlopeZ_TunnelBridge, /* get_slope_z_proc */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4304
diff
changeset
|
1409 |
ClearTile_TunnelBridge, /* clear_tile_proc */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4304
diff
changeset
|
1410 |
GetAcceptedCargo_TunnelBridge, /* get_accepted_cargo_proc */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4304
diff
changeset
|
1411 |
GetTileDesc_TunnelBridge, /* get_tile_desc_proc */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4304
diff
changeset
|
1412 |
GetTileTrackStatus_TunnelBridge, /* get_tile_track_status_proc */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4304
diff
changeset
|
1413 |
ClickTile_TunnelBridge, /* click_tile_proc */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4304
diff
changeset
|
1414 |
AnimateTile_TunnelBridge, /* animate_tile_proc */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4304
diff
changeset
|
1415 |
TileLoop_TunnelBridge, /* tile_loop_clear */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4304
diff
changeset
|
1416 |
ChangeTileOwner_TunnelBridge, /* change_tile_owner_clear */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4304
diff
changeset
|
1417 |
NULL, /* get_produced_cargo_proc */ |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4304
diff
changeset
|
1418 |
VehicleEnter_TunnelBridge, /* vehicle_enter_tile_proc */ |
7831
5dded9b03500
(svn r10698) -Codechange [FS#1082]: simplify the code related to foundations. Primarily removal of (duplicated|magic) code and introduction of few helper functions to ease foundation determination. Patch by frosch.
rubidium
parents:
7829
diff
changeset
|
1419 |
GetFoundation_TunnelBridge, /* get_foundation_proc */ |
7990
70039e33e893
(svn r11005) -Codechange: move the tiletype specific terraforming checks to the functions for those tile types.
rubidium
parents:
7968
diff
changeset
|
1420 |
TerraformTile_TunnelBridge, /* terraform_tile_proc */ |
0 | 1421 |
}; |