author | celestar |
Tue, 19 Jun 2007 07:21:01 +0000 | |
branch | gamebalance |
changeset 9913 | e79cd19772dd |
parent 9912 | 1ac8aac92385 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
3 |
/** @file rail_cmd.cpp */ |
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1818
diff
changeset
|
6 |
#include "openttd.h" |
3189
1af302c5abd0
(svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
3185
diff
changeset
|
7 |
#include "bridge_map.h" |
6486
4f8af35b11eb
(svn r8908) -Codechange: declaration of DrawBridgeMiddle does not belong in a map accessors header.
rubidium
parents:
6460
diff
changeset
|
8 |
#include "bridge.h" |
6460 | 9 |
#include "cmd_helper.h" |
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
10 |
#include "debug.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2148
diff
changeset
|
11 |
#include "functions.h" |
3101
e2fdb8802c2f
(svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
3099
diff
changeset
|
12 |
#include "rail_map.h" |
3144
426b825578f9
(svn r3763) Adapt to the new 'map accessors go in foo_map.h'-scheme
tron
parents:
3142
diff
changeset
|
13 |
#include "road_map.h" |
1363
01d3de5d8039
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1330
diff
changeset
|
14 |
#include "table/sprites.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
497
diff
changeset
|
15 |
#include "table/strings.h" |
679
e959706a3e4d
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
555
diff
changeset
|
16 |
#include "map.h" |
9906
6f41b8713b65
(svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents:
9903
diff
changeset
|
17 |
#include "landscape.h" |
1209
a1ac96655b79
(svn r1713) Split off several functions which query/set information about a single tile from map.h and put them into a seperate file tile.h
tron
parents:
1123
diff
changeset
|
18 |
#include "tile.h" |
3319
7d04847e4689
(svn r4085) Add GetTown{Index,ByTile}() to get the town index resp. the town from a tile
tron
parents:
3286
diff
changeset
|
19 |
#include "town_map.h" |
3154 | 20 |
#include "tunnel_map.h" |
0 | 21 |
#include "vehicle.h" |
22 |
#include "viewport.h" |
|
23 |
#include "command.h" |
|
24 |
#include "pathfind.h" |
|
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
25 |
#include "engine.h" |
0 | 26 |
#include "town.h" |
337
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
283
diff
changeset
|
27 |
#include "sound.h" |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
337
diff
changeset
|
28 |
#include "station.h" |
405
6830ae7a0d5d
(svn r602) -newgrf: Move DrawTileSeqStruct & co and struct SpriteGroup to sprite.h (pasky)
darkvater
parents:
403
diff
changeset
|
29 |
#include "sprite.h" |
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1247
diff
changeset
|
30 |
#include "depot.h" |
1542
2ca6d1624e6d
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1536
diff
changeset
|
31 |
#include "waypoint.h" |
4440
76189b34da8a
(svn r6212) Remove dependency on window.h from station.h
tron
parents:
4434
diff
changeset
|
32 |
#include "window.h" |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
33 |
#include "rail.h" |
2236 | 34 |
#include "railtypes.h" // include table for railtypes |
3638
6e0b43d905d4
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3636
diff
changeset
|
35 |
#include "newgrf.h" |
3900
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
36 |
#include "yapf/yapf.h" |
3757
a0bba34a94ba
(svn r4748) - Newstations: use custom sprite layout callback for waypoints as well as stations. Supports merging of adjacent waypoints if the GRF supports it (newstatsw.grf)
peter1138
parents:
3751
diff
changeset
|
37 |
#include "newgrf_callbacks.h" |
a0bba34a94ba
(svn r4748) - Newstations: use custom sprite layout callback for waypoints as well as stations. Supports merging of adjacent waypoints if the GRF supports it (newstatsw.grf)
peter1138
parents:
3751
diff
changeset
|
38 |
#include "newgrf_station.h" |
4556
693f37c36c85
(svn r6395) -Fix: when converting a depot from/to elrail, update the power of trains that are in it
glx
parents:
4549
diff
changeset
|
39 |
#include "train.h" |
0 | 40 |
|
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2254
diff
changeset
|
41 |
const byte _track_sloped_sprites[14] = { |
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2254
diff
changeset
|
42 |
14, 15, 22, 13, |
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2254
diff
changeset
|
43 |
0, 21, 17, 12, |
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2254
diff
changeset
|
44 |
23, 0, 18, 20, |
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2254
diff
changeset
|
45 |
19, 16 |
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2254
diff
changeset
|
46 |
}; |
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2254
diff
changeset
|
47 |
|
0 | 48 |
|
49 |
/* 4 |
|
50 |
* --------- |
|
51 |
* |\ /| |
|
52 |
* | \ 1/ | |
|
53 |
* | \ / | |
|
54 |
* | \ / | |
|
55 |
* 16| \ |32 |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
56 |
* | / \2 | |
0 | 57 |
* | / \ | |
58 |
* | / \ | |
|
59 |
* |/ \| |
|
60 |
* --------- |
|
61 |
* 8 |
|
62 |
*/ |
|
63 |
||
64 |
||
65 |
||
22 | 66 |
/* MAP2 byte: abcd???? => Signal On? Same coding as map3lo |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
67 |
* MAP3LO byte: abcd???? => Signal Exists? |
4434
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4388
diff
changeset
|
68 |
* a and b are for diagonals, upper and left, |
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4388
diff
changeset
|
69 |
* one for each direction. (ie a == NE->SW, b == |
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4388
diff
changeset
|
70 |
* SW->NE, or v.v., I don't know. b and c are |
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4388
diff
changeset
|
71 |
* similar for lower and right. |
0 | 72 |
* MAP2 byte: ????abcd => Type of ground. |
73 |
* MAP3LO byte: ????abcd => Type of rail. |
|
74 |
* MAP5: 00abcdef => rail |
|
75 |
* 01abcdef => rail w/ signals |
|
76 |
* 10uuuuuu => unused |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
77 |
* 11uuuudd => rail depot |
0 | 78 |
*/ |
79 |
||
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
80 |
static bool CheckTrackCombination(TileIndex tile, TrackBits to_build, uint flags) |
0 | 81 |
{ |
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
82 |
TrackBits current; // The current track layout |
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
83 |
TrackBits future; // The track layout we want to build |
0 | 84 |
_error_message = STR_1001_IMPOSSIBLE_TRACK_COMBINATION; |
85 |
||
4182
20d711816338
(svn r5624) Use {IsPlainRailTile,IsRailDepot,IsRailWaypoint,HasSignals}() instead of GetRailTile{T,Subt}ype() - this is more concise and a bit more flexible if/when the rail tile encoding changes
tron
parents:
4180
diff
changeset
|
86 |
if (!IsPlainRailTile(tile)) return false; |
0 | 87 |
|
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
88 |
/* So, we have a tile with tracks on it (and possibly signals). Let's see |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
89 |
* what tracks first */ |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
90 |
current = GetTrackBits(tile); |
1946
68e7ee03016a
(svn r2452) Fix defect in r2448 which caused building tracks unexpectedly fail or succeed
tron
parents:
1942
diff
changeset
|
91 |
future = current | to_build; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
92 |
|
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
93 |
/* Are we really building something new? */ |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
94 |
if (current == future) { |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
95 |
/* Nothing new is being built */ |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
96 |
_error_message = STR_1007_ALREADY_BUILT; |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
97 |
return false; |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
98 |
} |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
99 |
|
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
100 |
/* Let's see if we may build this */ |
4182
20d711816338
(svn r5624) Use {IsPlainRailTile,IsRailDepot,IsRailWaypoint,HasSignals}() instead of GetRailTile{T,Subt}ype() - this is more concise and a bit more flexible if/when the rail tile encoding changes
tron
parents:
4180
diff
changeset
|
101 |
if (flags & DC_NO_RAIL_OVERLAP || HasSignals(tile)) { |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
102 |
/* If we are not allowed to overlap (flag is on for ai players or we have |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
103 |
* signals on the tile), check that */ |
3258
94a915e7485f
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
104 |
return future == TRACK_BIT_HORZ || future == TRACK_BIT_VERT; |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
105 |
} else { |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
106 |
/* Normally, we may overlap and any combination is valid */ |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
107 |
return true; |
0 | 108 |
} |
109 |
} |
|
110 |
||
111 |
||
4067
ab047dec0733
(svn r5363) Revert 5312, 5288, 5248, 3992, 3249, 3228
tron
parents:
4052
diff
changeset
|
112 |
static const TrackBits _valid_tileh_slopes[][15] = { |
0 | 113 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
114 |
/* set of normal ones */ |
0 | 115 |
{ |
3258
94a915e7485f
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
116 |
TRACK_BIT_ALL, |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
117 |
TRACK_BIT_RIGHT, |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
118 |
TRACK_BIT_UPPER, |
3102
fde95020fc8e
(svn r3697) Rename DIAG1/DIAG2 to X resp. Y as this conveys a bit better in which direction a pieces of rail goes
tron
parents:
3101
diff
changeset
|
119 |
TRACK_BIT_X, |
0 | 120 |
|
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
121 |
TRACK_BIT_LEFT, |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
122 |
TRACK_BIT_NONE, |
3102
fde95020fc8e
(svn r3697) Rename DIAG1/DIAG2 to X resp. Y as this conveys a bit better in which direction a pieces of rail goes
tron
parents:
3101
diff
changeset
|
123 |
TRACK_BIT_Y, |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
124 |
TRACK_BIT_LOWER, |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
125 |
|
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
126 |
TRACK_BIT_LOWER, |
3102
fde95020fc8e
(svn r3697) Rename DIAG1/DIAG2 to X resp. Y as this conveys a bit better in which direction a pieces of rail goes
tron
parents:
3101
diff
changeset
|
127 |
TRACK_BIT_Y, |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
128 |
TRACK_BIT_NONE, |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
129 |
TRACK_BIT_LEFT, |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
130 |
|
3102
fde95020fc8e
(svn r3697) Rename DIAG1/DIAG2 to X resp. Y as this conveys a bit better in which direction a pieces of rail goes
tron
parents:
3101
diff
changeset
|
131 |
TRACK_BIT_X, |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
132 |
TRACK_BIT_UPPER, |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
133 |
TRACK_BIT_RIGHT, |
0 | 134 |
}, |
135 |
||
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
136 |
/* allowed rail for an evenly raised platform */ |
0 | 137 |
{ |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
138 |
TRACK_BIT_NONE, |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
139 |
TRACK_BIT_LEFT, |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
140 |
TRACK_BIT_LOWER, |
3102
fde95020fc8e
(svn r3697) Rename DIAG1/DIAG2 to X resp. Y as this conveys a bit better in which direction a pieces of rail goes
tron
parents:
3101
diff
changeset
|
141 |
TRACK_BIT_Y | TRACK_BIT_LOWER | TRACK_BIT_LEFT, |
0 | 142 |
|
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
143 |
TRACK_BIT_RIGHT, |
3258
94a915e7485f
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
144 |
TRACK_BIT_ALL, |
3102
fde95020fc8e
(svn r3697) Rename DIAG1/DIAG2 to X resp. Y as this conveys a bit better in which direction a pieces of rail goes
tron
parents:
3101
diff
changeset
|
145 |
TRACK_BIT_X | TRACK_BIT_LOWER | TRACK_BIT_RIGHT, |
3258
94a915e7485f
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
146 |
TRACK_BIT_ALL, |
0 | 147 |
|
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
148 |
TRACK_BIT_UPPER, |
3102
fde95020fc8e
(svn r3697) Rename DIAG1/DIAG2 to X resp. Y as this conveys a bit better in which direction a pieces of rail goes
tron
parents:
3101
diff
changeset
|
149 |
TRACK_BIT_X | TRACK_BIT_UPPER | TRACK_BIT_LEFT, |
3258
94a915e7485f
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
150 |
TRACK_BIT_ALL, |
94a915e7485f
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
151 |
TRACK_BIT_ALL, |
0 | 152 |
|
3102
fde95020fc8e
(svn r3697) Rename DIAG1/DIAG2 to X resp. Y as this conveys a bit better in which direction a pieces of rail goes
tron
parents:
3101
diff
changeset
|
153 |
TRACK_BIT_Y | TRACK_BIT_UPPER | TRACK_BIT_RIGHT, |
3258
94a915e7485f
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
154 |
TRACK_BIT_ALL, |
94a915e7485f
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
155 |
TRACK_BIT_ALL |
3276
fa7cc2225ca4
(svn r3988) Remove the info about valid rails on shore tiles. It's the same as for any other sloped tile
tron
parents:
3274
diff
changeset
|
156 |
} |
0 | 157 |
}; |
158 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
159 |
uint GetRailFoundation(Slope tileh, TrackBits bits) |
0 | 160 |
{ |
3878
91a8b87f641e
(svn r4927) Replace 3 big ifs (which regard foundations) by a bit less confusing code
tron
parents:
3869
diff
changeset
|
161 |
uint i; |
0 | 162 |
|
4246
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
163 |
if (!IsSteepSlope(tileh)) { |
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
164 |
if ((~_valid_tileh_slopes[0][tileh] & bits) == 0) return 0; |
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
165 |
if ((~_valid_tileh_slopes[1][tileh] & bits) == 0) return tileh; |
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
166 |
} |
3878
91a8b87f641e
(svn r4927) Replace 3 big ifs (which regard foundations) by a bit less confusing code
tron
parents:
3869
diff
changeset
|
167 |
|
91a8b87f641e
(svn r4927) Replace 3 big ifs (which regard foundations) by a bit less confusing code
tron
parents:
3869
diff
changeset
|
168 |
switch (bits) { |
4253
6fadea8a8043
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
169 |
default: NOT_REACHED(); |
3878
91a8b87f641e
(svn r4927) Replace 3 big ifs (which regard foundations) by a bit less confusing code
tron
parents:
3869
diff
changeset
|
170 |
case TRACK_BIT_X: i = 0; break; |
91a8b87f641e
(svn r4927) Replace 3 big ifs (which regard foundations) by a bit less confusing code
tron
parents:
3869
diff
changeset
|
171 |
case TRACK_BIT_Y: i = 1; break; |
4253
6fadea8a8043
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
172 |
case TRACK_BIT_LEFT: return 15 + 8 + (tileh == SLOPE_STEEP_W ? 4 : 0); |
6fadea8a8043
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
173 |
case TRACK_BIT_LOWER: return 15 + 8 + (tileh == SLOPE_STEEP_S ? 5 : 1); |
6fadea8a8043
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
174 |
case TRACK_BIT_RIGHT: return 15 + 8 + (tileh == SLOPE_STEEP_E ? 6 : 2); |
6fadea8a8043
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
175 |
case TRACK_BIT_UPPER: return 15 + 8 + (tileh == SLOPE_STEEP_N ? 7 : 3); |
2951 | 176 |
} |
3878
91a8b87f641e
(svn r4927) Replace 3 big ifs (which regard foundations) by a bit less confusing code
tron
parents:
3869
diff
changeset
|
177 |
switch (tileh) { |
4246
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
178 |
case SLOPE_W: |
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
179 |
case SLOPE_STEEP_W: i += 0; break; |
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
180 |
case SLOPE_S: |
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
181 |
case SLOPE_STEEP_S: i += 2; break; |
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
182 |
case SLOPE_E: |
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
183 |
case SLOPE_STEEP_E: i += 4; break; |
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
184 |
case SLOPE_N: |
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
185 |
case SLOPE_STEEP_N: i += 6; break; |
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
186 |
default: return 0; |
3878
91a8b87f641e
(svn r4927) Replace 3 big ifs (which regard foundations) by a bit less confusing code
tron
parents:
3869
diff
changeset
|
187 |
} |
91a8b87f641e
(svn r4927) Replace 3 big ifs (which regard foundations) by a bit less confusing code
tron
parents:
3869
diff
changeset
|
188 |
return i + 15; |
0 | 189 |
} |
190 |
||
2639 | 191 |
|
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
192 |
static CommandCost CheckRailSlope(Slope tileh, TrackBits rail_bits, TrackBits existing, TileIndex tile) |
0 | 193 |
{ |
4246
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
194 |
if (IsSteepSlope(tileh)) { |
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
195 |
if (_patches.build_on_slopes && existing == 0) { |
4253
6fadea8a8043
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
196 |
TrackBits valid = TRACK_BIT_CROSS | (HASBIT(1 << SLOPE_STEEP_W | 1 << SLOPE_STEEP_E, tileh) ? TRACK_BIT_VERT : TRACK_BIT_HORZ); |
9903
dc85aaa556ae
(svn r9534) [gamebalance] -Codechange: Made the prices a member of the Economy and removed all global variables concerning prices (INCOMPLETE).
celestar
parents:
9895
diff
changeset
|
197 |
if (valid & rail_bits) return _eco->GetPrice(CEconomy::TERRAFORM); |
4246
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
198 |
} |
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
199 |
} else { |
0 | 200 |
rail_bits |= existing; |
201 |
||
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
202 |
/* don't allow building on the lower side of a coast */ |
1627
d88508d9ced0
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
203 |
if (IsTileType(tile, MP_WATER) && |
3276
fa7cc2225ca4
(svn r3988) Remove the info about valid rails on shore tiles. It's the same as for any other sloped tile
tron
parents:
3274
diff
changeset
|
204 |
~_valid_tileh_slopes[1][tileh] & rail_bits) { |
0 | 205 |
return_cmd_error(STR_3807_CAN_T_BUILD_ON_WATER); |
206 |
} |
|
207 |
||
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
208 |
/* no special foundation */ |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
209 |
if ((~_valid_tileh_slopes[0][tileh] & rail_bits) == 0) { |
0 | 210 |
return 0; |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
211 |
} else if (!_patches.build_on_slopes || _is_old_ai_player) { |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
212 |
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
213 |
} |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
214 |
|
1627
d88508d9ced0
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
215 |
if ((~_valid_tileh_slopes[1][tileh] & rail_bits) == 0 || ( // whole tile is leveled up |
3102
fde95020fc8e
(svn r3697) Rename DIAG1/DIAG2 to X resp. Y as this conveys a bit better in which direction a pieces of rail goes
tron
parents:
3101
diff
changeset
|
216 |
(rail_bits == TRACK_BIT_X || rail_bits == TRACK_BIT_Y) && |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
217 |
(tileh == SLOPE_W || tileh == SLOPE_S || tileh == SLOPE_E || tileh == SLOPE_N) |
1627
d88508d9ced0
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
218 |
)) { // partly up |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
219 |
return (existing != 0) ? 0 : _eco->GetPrice(CEconomy::TERRAFORM); |
0 | 220 |
} |
221 |
} |
|
222 |
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
|
223 |
} |
|
224 |
||
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:
1719
diff
changeset
|
225 |
/* Validate functions for rail building */ |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
226 |
static inline bool ValParamTrackOrientation(Track track) {return IsValidTrack(track);} |
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:
1719
diff
changeset
|
227 |
|
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:
1719
diff
changeset
|
228 |
/** Build a single piece of rail |
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:
3486
diff
changeset
|
229 |
* @param tile tile to build on |
9909
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
230 |
* @param flags operation to perform |
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:
1719
diff
changeset
|
231 |
* @param p1 railtype of being built piece (normal, mono, maglev) |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
232 |
* @param p2 rail track to build |
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:
1719
diff
changeset
|
233 |
*/ |
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
234 |
CommandCost CmdBuildSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 235 |
{ |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
236 |
Slope tileh; |
5058
81748e4f3e60
(svn r7111) After checking p1 in CmdBuildSingleRail() assign it to a variable railtype instead of using p1 in the function. Also assign p2 to track only after it has been checked for validity
tron
parents:
5055
diff
changeset
|
237 |
RailType railtype; |
81748e4f3e60
(svn r7111) After checking p1 in CmdBuildSingleRail() assign it to a variable railtype instead of using p1 in the function. Also assign p2 to track only after it has been checked for validity
tron
parents:
5055
diff
changeset
|
238 |
Track track; |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
239 |
TrackBits trackbit; |
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
240 |
CommandCost cost = 0; |
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
241 |
CommandCost ret; |
1627
d88508d9ced0
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
242 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
243 |
if (!ValParamRailtype(p1) || !ValParamTrackOrientation((Track)p2)) return CMD_ERROR; |
5058
81748e4f3e60
(svn r7111) After checking p1 in CmdBuildSingleRail() assign it to a variable railtype instead of using p1 in the function. Also assign p2 to track only after it has been checked for validity
tron
parents:
5055
diff
changeset
|
244 |
railtype = (RailType)p1; |
81748e4f3e60
(svn r7111) After checking p1 in CmdBuildSingleRail() assign it to a variable railtype instead of using p1 in the function. Also assign p2 to track only after it has been checked for validity
tron
parents:
5055
diff
changeset
|
245 |
track = (Track)p2; |
1627
d88508d9ced0
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
246 |
|
d88508d9ced0
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
247 |
tileh = GetTileSlope(tile, NULL); |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
248 |
trackbit = TrackToTrackBits(track); |
0 | 249 |
|
250 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
|
251 |
||
1627
d88508d9ced0
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
252 |
switch (GetTileType(tile)) { |
d88508d9ced0
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
253 |
case MP_RAILWAY: |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
254 |
if (!CheckTrackCombination(tile, trackbit, flags) || |
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
255 |
!EnsureNoVehicleOnGround(tile)) { |
1627
d88508d9ced0
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
256 |
return CMD_ERROR; |
d88508d9ced0
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
257 |
} |
4180
72f8362401b6
(svn r5618) Remove a redundant check, CheckTrackCombination() a few lines above performs the same test
tron
parents:
4158
diff
changeset
|
258 |
if (!IsTileOwner(tile, _current_player) || |
5582
0b1e6b9a1bdb
(svn r7583) -Fix (r7573): Merging of bridge branch broke (partially reverted?) automatic railtype conversion when building track on existing rail.
peter1138
parents:
5573
diff
changeset
|
259 |
!IsCompatibleRail(GetRailType(tile), railtype)) { |
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
260 |
/* Get detailed error message */ |
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:
3486
diff
changeset
|
261 |
return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
1627
d88508d9ced0
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
262 |
} |
d88508d9ced0
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
263 |
|
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
264 |
ret = CheckRailSlope(tileh, trackbit, GetTrackBits(tile), tile); |
1691
fcd9fefaed02
(svn r2195) Add CmdFailed() as the One True Way(tm) to check if a command failed.
tron
parents:
1669
diff
changeset
|
265 |
if (CmdFailed(ret)) return ret; |
0 | 266 |
cost += ret; |
267 |
||
5059
dbded6ba1f91
(svn r7112) -Codechange (r7106): Improve the test for determining if the rail type should be converted
peter1138
parents:
5058
diff
changeset
|
268 |
/* If the rail types don't match, try to convert only if engines of |
dbded6ba1f91
(svn r7112) -Codechange (r7106): Improve the test for determining if the rail type should be converted
peter1138
parents:
5058
diff
changeset
|
269 |
* the present rail type are powered on the new rail type. */ |
dbded6ba1f91
(svn r7112) -Codechange (r7106): Improve the test for determining if the rail type should be converted
peter1138
parents:
5058
diff
changeset
|
270 |
if (GetRailType(tile) != railtype && HasPowerOnRail(GetRailType(tile), railtype)) { |
5058
81748e4f3e60
(svn r7111) After checking p1 in CmdBuildSingleRail() assign it to a variable railtype instead of using p1 in the function. Also assign p2 to track only after it has been checked for validity
tron
parents:
5055
diff
changeset
|
271 |
ret = DoCommand(tile, tile, railtype, flags, CMD_CONVERT_RAIL); |
5054
cf05383e4df5
(svn r7106) -Feature: Allow over-building of compatible railtypes, i.e. normal and
peter1138
parents:
5015
diff
changeset
|
272 |
if (CmdFailed(ret)) return ret; |
cf05383e4df5
(svn r7106) -Feature: Allow over-building of compatible railtypes, i.e. normal and
peter1138
parents:
5015
diff
changeset
|
273 |
cost += ret; |
cf05383e4df5
(svn r7106) -Feature: Allow over-building of compatible railtypes, i.e. normal and
peter1138
parents:
5015
diff
changeset
|
274 |
} |
cf05383e4df5
(svn r7106) -Feature: Allow over-building of compatible railtypes, i.e. normal and
peter1138
parents:
5015
diff
changeset
|
275 |
|
1719
b428568cec03
(svn r2223) When adding tracks to a railway tile reset the ground to bare land, fix for a glitch in r2131
tron
parents:
1691
diff
changeset
|
276 |
if (flags & DC_EXEC) { |
3523
168ee460418b
(svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents:
3522
diff
changeset
|
277 |
SetRailGroundType(tile, RAIL_GROUND_BARREN); |
5662
2dd848654f54
(svn r7609) -Codechange: remove some direct map accesses to m5 and some unneeded signal removal code in ClearTileTrack as it is done in CmdRemoveSingleRail too, which is called for every removed trackbit.
rubidium
parents:
5582
diff
changeset
|
278 |
SetTrackBits(tile, GetTrackBits(tile) | trackbit); |
1719
b428568cec03
(svn r2223) When adding tracks to a railway tile reset the ground to bare land, fix for a glitch in r2131
tron
parents:
1691
diff
changeset
|
279 |
} |
9903
dc85aaa556ae
(svn r9534) [gamebalance] -Codechange: Made the prices a member of the Economy and removed all global variables concerning prices (INCOMPLETE).
celestar
parents:
9895
diff
changeset
|
280 |
cost += _eco->GetPrice(CEconomy::PRICE_RAIL_BUILD, tile); |
1627
d88508d9ced0
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
281 |
break; |
0 | 282 |
|
1627
d88508d9ced0
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
283 |
case MP_STREET: |
3142
00b67636048f
(svn r3760) Replace some magic numbers for checking for a suitable slope for a level crossing by some less magic numbers. Quite similar to r3699, though this time for placing the rails
tron
parents:
3103
diff
changeset
|
284 |
#define M(x) (1 << (x)) |
00b67636048f
(svn r3760) Replace some magic numbers for checking for a suitable slope for a level crossing by some less magic numbers. Quite similar to r3699, though this time for placing the rails
tron
parents:
3103
diff
changeset
|
285 |
/* Level crossings may only be built on these slopes */ |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
286 |
if (!HASBIT(M(SLOPE_SEN) | M(SLOPE_ENW) | M(SLOPE_NWS) | M(SLOPE_NS) | M(SLOPE_WSE) | M(SLOPE_EW) | M(SLOPE_FLAT), tileh)) { |
1627
d88508d9ced0
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
287 |
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
3142
00b67636048f
(svn r3760) Replace some magic numbers for checking for a suitable slope for a level crossing by some less magic numbers. Quite similar to r3699, though this time for placing the rails
tron
parents:
3103
diff
changeset
|
288 |
} |
00b67636048f
(svn r3760) Replace some magic numbers for checking for a suitable slope for a level crossing by some less magic numbers. Quite similar to r3699, though this time for placing the rails
tron
parents:
3103
diff
changeset
|
289 |
#undef M |
00b67636048f
(svn r3760) Replace some magic numbers for checking for a suitable slope for a level crossing by some less magic numbers. Quite similar to r3699, though this time for placing the rails
tron
parents:
3103
diff
changeset
|
290 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
291 |
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; |
0 | 292 |
|
4140
c294db895325
(svn r5500) Undo r4597, because it breaks the intended change of r5315 to prohibit building rails on a road tile while road works are in progress
tron
parents:
4139
diff
changeset
|
293 |
if (GetRoadTileType(tile) == ROAD_TILE_NORMAL) { |
c294db895325
(svn r5500) Undo r4597, because it breaks the intended change of r5315 to prohibit building rails on a road tile while road works are in progress
tron
parents:
4139
diff
changeset
|
294 |
if (HasRoadWorks(tile)) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS); |
c294db895325
(svn r5500) Undo r4597, because it breaks the intended change of r5315 to prohibit building rails on a road tile while road works are in progress
tron
parents:
4139
diff
changeset
|
295 |
|
9911
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9909
diff
changeset
|
296 |
RoadTypes roadtypes = GetRoadTypes(tile); |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9909
diff
changeset
|
297 |
RoadBits road = GetRoadBits(tile, ROADTYPE_ROAD); |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9909
diff
changeset
|
298 |
RoadBits tram = GetRoadBits(tile, ROADTYPE_TRAM); |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9909
diff
changeset
|
299 |
switch (roadtypes) { |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9909
diff
changeset
|
300 |
default: break; |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
301 |
case ROADTYPES_TRAM: |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
302 |
/* Tram crossings must always have road. */ |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
303 |
SetRoadOwner(tile, ROADTYPE_ROAD, _current_player); |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
304 |
roadtypes |= ROADTYPES_ROAD; |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
305 |
break; |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
306 |
|
9911
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9909
diff
changeset
|
307 |
case ROADTYPES_ROADTRAM: if (road == tram) break; |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9909
diff
changeset
|
308 |
/* FALL THROUGH */ |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9909
diff
changeset
|
309 |
case ROADTYPES_ROADHWAY: // Road and highway are incompatible in this case |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9909
diff
changeset
|
310 |
case ROADTYPES_TRAMHWAY: // Tram and highway are incompatible in this case |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9909
diff
changeset
|
311 |
case ROADTYPES_ALL: // Also incompatible |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9909
diff
changeset
|
312 |
return CMD_ERROR; |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9909
diff
changeset
|
313 |
} |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9909
diff
changeset
|
314 |
|
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9909
diff
changeset
|
315 |
road |= tram | GetRoadBits(tile, ROADTYPE_HWAY); |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9909
diff
changeset
|
316 |
|
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9909
diff
changeset
|
317 |
if ((track == TRACK_X && road == ROAD_Y) || |
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9909
diff
changeset
|
318 |
(track == TRACK_Y && road == ROAD_X)) { |
4140
c294db895325
(svn r5500) Undo r4597, because it breaks the intended change of r5315 to prohibit building rails on a road tile while road works are in progress
tron
parents:
4139
diff
changeset
|
319 |
if (flags & DC_EXEC) { |
9911
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9909
diff
changeset
|
320 |
MakeRoadCrossing(tile, GetRoadOwner(tile, ROADTYPE_ROAD), GetRoadOwner(tile, ROADTYPE_TRAM), GetRoadOwner(tile, ROADTYPE_HWAY), _current_player, (track == TRACK_X ? AXIS_Y : AXIS_X), railtype, roadtypes, GetTownIndex(tile)); |
4140
c294db895325
(svn r5500) Undo r4597, because it breaks the intended change of r5315 to prohibit building rails on a road tile while road works are in progress
tron
parents:
4139
diff
changeset
|
321 |
} |
c294db895325
(svn r5500) Undo r4597, because it breaks the intended change of r5315 to prohibit building rails on a road tile while road works are in progress
tron
parents:
4139
diff
changeset
|
322 |
break; |
4139
e4acf9f12cb9
(svn r5497) -Fix: somehow in r5315 slipped some wrong logic, allowed you to build rail on all road pieces without really building it ;)
truelight
parents:
4081
diff
changeset
|
323 |
} |
1627
d88508d9ced0
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
324 |
} |
d88508d9ced0
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
325 |
|
3267
591027d10884
(svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents:
3265
diff
changeset
|
326 |
if (IsLevelCrossing(tile) && GetCrossingRailBits(tile) == trackbit) { |
1627
d88508d9ced0
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
327 |
return_cmd_error(STR_1007_ALREADY_BUILT); |
3267
591027d10884
(svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents:
3265
diff
changeset
|
328 |
} |
1627
d88508d9ced0
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
329 |
/* FALLTHROUGH */ |
d88508d9ced0
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
330 |
|
d88508d9ced0
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
331 |
default: |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
332 |
ret = CheckRailSlope(tileh, trackbit, TRACK_BIT_NONE, tile); |
1691
fcd9fefaed02
(svn r2195) Add CmdFailed() as the One True Way(tm) to check if a command failed.
tron
parents:
1669
diff
changeset
|
333 |
if (CmdFailed(ret)) return ret; |
1627
d88508d9ced0
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
334 |
cost += ret; |
d88508d9ced0
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
335 |
|
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:
3486
diff
changeset
|
336 |
ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
1691
fcd9fefaed02
(svn r2195) Add CmdFailed() as the One True Way(tm) to check if a command failed.
tron
parents:
1669
diff
changeset
|
337 |
if (CmdFailed(ret)) return ret; |
1627
d88508d9ced0
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
338 |
cost += ret; |
d88508d9ced0
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
339 |
|
9903
dc85aaa556ae
(svn r9534) [gamebalance] -Codechange: Made the prices a member of the Economy and removed all global variables concerning prices (INCOMPLETE).
celestar
parents:
9895
diff
changeset
|
340 |
cost += _eco->GetPrice(CEconomy::PRICE_RAIL_BUILD, tile); |
5058
81748e4f3e60
(svn r7111) After checking p1 in CmdBuildSingleRail() assign it to a variable railtype instead of using p1 in the function. Also assign p2 to track only after it has been checked for validity
tron
parents:
5055
diff
changeset
|
341 |
if (flags & DC_EXEC) MakeRailNormal(tile, _current_player, trackbit, railtype); |
1627
d88508d9ced0
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
342 |
break; |
0 | 343 |
} |
344 |
||
345 |
if (flags & DC_EXEC) { |
|
346 |
MarkTileDirtyByTile(tile); |
|
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
347 |
SetSignalsOnBothDir(tile, track); |
3900
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
348 |
YapfNotifyTrackLayoutChange(tile, track); |
0 | 349 |
} |
350 |
||
9903
dc85aaa556ae
(svn r9534) [gamebalance] -Codechange: Made the prices a member of the Economy and removed all global variables concerning prices (INCOMPLETE).
celestar
parents:
9895
diff
changeset
|
351 |
return cost; |
0 | 352 |
} |
353 |
||
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:
1719
diff
changeset
|
354 |
/** Remove a single piece of track |
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:
3486
diff
changeset
|
355 |
* @param tile tile to remove track from |
9909
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
356 |
* @param flags operation to perform |
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:
1719
diff
changeset
|
357 |
* @param p1 unused |
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:
1719
diff
changeset
|
358 |
* @param p2 rail orientation |
0 | 359 |
*/ |
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
360 |
CommandCost CmdRemoveSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 361 |
{ |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
362 |
Track track = (Track)p2; |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
363 |
TrackBits trackbit; |
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
364 |
CommandCost cost = 0; |
3284
fafe2ef7b809
(svn r3998) - Fix: When removing rail track from a while where only X and Y (/ and \) pieces exist, explicitly update signals in both directions.
peter1138
parents:
3279
diff
changeset
|
365 |
bool crossing = false; |
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:
1719
diff
changeset
|
366 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
367 |
if (!ValParamTrackOrientation((Track)p2)) return CMD_ERROR; |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
368 |
trackbit = TrackToTrackBits(track); |
0 | 369 |
|
370 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
|
371 |
||
3273
7303df652359
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
372 |
switch (GetTileType(tile)) { |
3071
a6acfe74e0a7
(svn r3660) Convert further road bits and type references to the functions/enums
tron
parents:
3069
diff
changeset
|
373 |
case MP_STREET: { |
3273
7303df652359
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
374 |
if (!IsLevelCrossing(tile) || |
7303df652359
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
375 |
GetCrossingRailBits(tile) != trackbit || |
7303df652359
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
376 |
(_current_player != OWNER_WATER && !CheckTileOwnership(tile)) || |
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
377 |
!EnsureNoVehicleOnGround(tile)) { |
3273
7303df652359
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
378 |
return CMD_ERROR; |
7303df652359
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
379 |
} |
0 | 380 |
|
9903
dc85aaa556ae
(svn r9534) [gamebalance] -Codechange: Made the prices a member of the Economy and removed all global variables concerning prices (INCOMPLETE).
celestar
parents:
9895
diff
changeset
|
381 |
cost += _eco->GetPrice(CEconomy::PRICE_RAIL_REMOVE, tile, true); |
3273
7303df652359
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
382 |
if (flags & DC_EXEC) { |
9911
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9909
diff
changeset
|
383 |
MakeRoadNormal(tile, GetCrossingRoadBits(tile), GetRoadTypes(tile), GetTownIndex(tile), GetRoadOwner(tile, ROADTYPE_ROAD), GetRoadOwner(tile, ROADTYPE_TRAM), GetRoadOwner(tile, ROADTYPE_HWAY)); |
3273
7303df652359
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
384 |
} |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
385 |
break; |
3071
a6acfe74e0a7
(svn r3660) Convert further road bits and type references to the functions/enums
tron
parents:
3069
diff
changeset
|
386 |
} |
2548
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2544
diff
changeset
|
387 |
|
3273
7303df652359
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
388 |
case MP_RAILWAY: { |
7303df652359
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
389 |
TrackBits present; |
7303df652359
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
390 |
|
7303df652359
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
391 |
if (!IsPlainRailTile(tile) || |
7303df652359
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
392 |
(_current_player != OWNER_WATER && !CheckTileOwnership(tile)) || |
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
393 |
!EnsureNoVehicleOnGround(tile)) { |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
394 |
return CMD_ERROR; |
3273
7303df652359
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
395 |
} |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
396 |
|
3273
7303df652359
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
397 |
present = GetTrackBits(tile); |
7303df652359
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
398 |
if ((present & trackbit) == 0) return CMD_ERROR; |
3284
fafe2ef7b809
(svn r3998) - Fix: When removing rail track from a while where only X and Y (/ and \) pieces exist, explicitly update signals in both directions.
peter1138
parents:
3279
diff
changeset
|
399 |
if (present == (TRACK_BIT_X | TRACK_BIT_Y)) crossing = true; |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
400 |
|
1963
8a398139fb87
(svn r2469) - Add: When removing tracks with the 'remove' tool, have it automatically remove signals on the tracks.
hackykid
parents:
1954
diff
changeset
|
401 |
/* Charge extra to remove signals on the track, if they are there */ |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
402 |
if (HasSignalOnTrack(tile, track)) |
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:
3486
diff
changeset
|
403 |
cost += DoCommand(tile, track, 0, flags, CMD_REMOVE_SIGNALS); |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
404 |
|
9903
dc85aaa556ae
(svn r9534) [gamebalance] -Codechange: Made the prices a member of the Economy and removed all global variables concerning prices (INCOMPLETE).
celestar
parents:
9895
diff
changeset
|
405 |
present ^= trackbit; |
dc85aaa556ae
(svn r9534) [gamebalance] -Codechange: Made the prices a member of the Economy and removed all global variables concerning prices (INCOMPLETE).
celestar
parents:
9895
diff
changeset
|
406 |
cost += _eco->GetPrice(CEconomy::PRICE_RAIL_REMOVE, tile, (present == 0)); |
3273
7303df652359
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
407 |
if (flags & DC_EXEC) { |
7303df652359
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
408 |
if (present == 0) { |
7303df652359
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
409 |
DoClearSquare(tile); |
7303df652359
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
410 |
} else { |
7303df652359
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
411 |
SetTrackBits(tile, present); |
7303df652359
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
412 |
} |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
413 |
} |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
414 |
break; |
3273
7303df652359
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
415 |
} |
2548
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2544
diff
changeset
|
416 |
|
3273
7303df652359
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
417 |
default: return CMD_ERROR; |
0 | 418 |
} |
419 |
||
3273
7303df652359
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
420 |
if (flags & DC_EXEC) { |
7303df652359
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
421 |
MarkTileDirtyByTile(tile); |
3284
fafe2ef7b809
(svn r3998) - Fix: When removing rail track from a while where only X and Y (/ and \) pieces exist, explicitly update signals in both directions.
peter1138
parents:
3279
diff
changeset
|
422 |
if (crossing) { |
fafe2ef7b809
(svn r3998) - Fix: When removing rail track from a while where only X and Y (/ and \) pieces exist, explicitly update signals in both directions.
peter1138
parents:
3279
diff
changeset
|
423 |
/* crossing is set when only TRACK_BIT_X and TRACK_BIT_Y are set. As we |
fafe2ef7b809
(svn r3998) - Fix: When removing rail track from a while where only X and Y (/ and \) pieces exist, explicitly update signals in both directions.
peter1138
parents:
3279
diff
changeset
|
424 |
* are removing one of these pieces, we'll need to update signals for |
fafe2ef7b809
(svn r3998) - Fix: When removing rail track from a while where only X and Y (/ and \) pieces exist, explicitly update signals in both directions.
peter1138
parents:
3279
diff
changeset
|
425 |
* both directions explicitly, as after the track is removed it won't |
fafe2ef7b809
(svn r3998) - Fix: When removing rail track from a while where only X and Y (/ and \) pieces exist, explicitly update signals in both directions.
peter1138
parents:
3279
diff
changeset
|
426 |
* 'connect' with the other piece. */ |
fafe2ef7b809
(svn r3998) - Fix: When removing rail track from a while where only X and Y (/ and \) pieces exist, explicitly update signals in both directions.
peter1138
parents:
3279
diff
changeset
|
427 |
SetSignalsOnBothDir(tile, TRACK_X); |
fafe2ef7b809
(svn r3998) - Fix: When removing rail track from a while where only X and Y (/ and \) pieces exist, explicitly update signals in both directions.
peter1138
parents:
3279
diff
changeset
|
428 |
SetSignalsOnBothDir(tile, TRACK_Y); |
3900
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
429 |
YapfNotifyTrackLayoutChange(tile, TRACK_X); |
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
430 |
YapfNotifyTrackLayoutChange(tile, TRACK_Y); |
3284
fafe2ef7b809
(svn r3998) - Fix: When removing rail track from a while where only X and Y (/ and \) pieces exist, explicitly update signals in both directions.
peter1138
parents:
3279
diff
changeset
|
431 |
} else { |
fafe2ef7b809
(svn r3998) - Fix: When removing rail track from a while where only X and Y (/ and \) pieces exist, explicitly update signals in both directions.
peter1138
parents:
3279
diff
changeset
|
432 |
SetSignalsOnBothDir(tile, track); |
3900
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
433 |
YapfNotifyTrackLayoutChange(tile, track); |
3284
fafe2ef7b809
(svn r3998) - Fix: When removing rail track from a while where only X and Y (/ and \) pieces exist, explicitly update signals in both directions.
peter1138
parents:
3279
diff
changeset
|
434 |
} |
3273
7303df652359
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
435 |
} |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
436 |
|
1963
8a398139fb87
(svn r2469) - Add: When removing tracks with the 'remove' tool, have it automatically remove signals on the tracks.
hackykid
parents:
1954
diff
changeset
|
437 |
return cost; |
0 | 438 |
} |
439 |
||
440 |
||
3493
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
441 |
static const TileIndexDiffC _trackdelta[] = { |
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
442 |
{ -1, 0 }, { 0, 1 }, { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, 1 }, |
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
443 |
{ 0, 0 }, |
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
444 |
{ 0, 0 }, |
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
445 |
{ 1, 0 }, { 0, -1 }, { 0, -1 }, { 1, 0 }, { 0, -1 }, { -1, 0 }, |
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
446 |
{ 0, 0 }, |
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
447 |
{ 0, 0 } |
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
448 |
}; |
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
449 |
|
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
450 |
|
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
451 |
static CommandCost ValidateAutoDrag(Trackdir *trackdir, TileIndex start, TileIndex end) |
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
452 |
{ |
3493
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
453 |
int x = TileX(start); |
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
454 |
int y = TileY(start); |
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
455 |
int ex = TileX(end); |
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
456 |
int ey = TileY(end); |
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
457 |
int dx, dy, trdx, trdy; |
0 | 458 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
459 |
if (!ValParamTrackOrientation(TrackdirToTrack(*trackdir))) return CMD_ERROR; |
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
460 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
461 |
/* calculate delta x,y from start to end tile */ |
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
462 |
dx = ex - x; |
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
463 |
dy = ey - y; |
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
464 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
465 |
/* calculate delta x,y for the first direction */ |
3493
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
466 |
trdx = _trackdelta[*trackdir].x; |
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
467 |
trdy = _trackdelta[*trackdir].y; |
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
468 |
|
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
469 |
if (!IsDiagonalTrackdir(*trackdir)) { |
3493
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
470 |
trdx += _trackdelta[*trackdir ^ 1].x; |
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
471 |
trdy += _trackdelta[*trackdir ^ 1].y; |
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
472 |
} |
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
473 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
474 |
/* validate the direction */ |
2951 | 475 |
while ( |
476 |
(trdx <= 0 && dx > 0) || |
|
477 |
(trdx >= 0 && dx < 0) || |
|
478 |
(trdy <= 0 && dy > 0) || |
|
479 |
(trdy >= 0 && dy < 0) |
|
480 |
) { |
|
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
481 |
if (!HASBIT(*trackdir, 3)) { // first direction is invalid, try the other |
6453
e65715f6e063
(svn r8864) -Codechange: make ClrBitT(), SetBitT() and ToggleBitT more like CLRBIT() and so on (modify value of the first parameter instead or returning the result)
KUDr
parents:
6432
diff
changeset
|
482 |
SetBitT(*trackdir, 3); // reverse the direction |
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
483 |
trdx = -trdx; |
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
484 |
trdy = -trdy; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
485 |
} else { // other direction is invalid too, invalid drag |
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
486 |
return CMD_ERROR; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
487 |
} |
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
488 |
} |
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
489 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
490 |
/* (for diagonal tracks, this is already made sure of by above test), but: |
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
491 |
* for non-diagonal tracks, check if the start and end tile are on 1 line */ |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
492 |
if (!IsDiagonalTrackdir(*trackdir)) { |
3493
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
493 |
trdx = _trackdelta[*trackdir].x; |
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
494 |
trdy = _trackdelta[*trackdir].y; |
2951 | 495 |
if (abs(dx) != abs(dy) && abs(dx) + abs(trdy) != abs(dy) + abs(trdx)) |
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
496 |
return CMD_ERROR; |
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
497 |
} |
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
498 |
|
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
499 |
return 0; |
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
500 |
} |
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
501 |
|
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:
1719
diff
changeset
|
502 |
/** Build a stretch of railroad tracks. |
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:
3486
diff
changeset
|
503 |
* @param tile start tile of drag |
9909
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
504 |
* @param flags operation to perform |
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:
1719
diff
changeset
|
505 |
* @param p1 end tile of drag |
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:
1719
diff
changeset
|
506 |
* @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:
1719
diff
changeset
|
507 |
* - p2 = (bit 0-3) - railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev) |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
508 |
* - p2 = (bit 4-6) - track-orientation, valid values: 0-5 (Track enum) |
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:
1719
diff
changeset
|
509 |
* - p2 = (bit 7) - 0 = build, 1 = remove tracks |
0 | 510 |
*/ |
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
511 |
static CommandCost CmdRailTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
512 |
{ |
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
513 |
CommandCost ret, total_cost = 0; |
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:
2111
diff
changeset
|
514 |
Track track = (Track)GB(p2, 4, 3); |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
515 |
Trackdir trackdir; |
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
516 |
byte mode = HASBIT(p2, 7); |
2604
901508f52c3d
(svn r3141) Replace incorrect railtype bitmask in CmdRailTrackHelper with appropriate GB()
peter1138
parents:
2549
diff
changeset
|
517 |
RailType railtype = (RailType)GB(p2, 0, 4); |
3493
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
518 |
TileIndex end_tile; |
0 | 519 |
|
2604
901508f52c3d
(svn r3141) Replace incorrect railtype bitmask in CmdRailTrackHelper with appropriate GB()
peter1138
parents:
2549
diff
changeset
|
520 |
if (!ValParamRailtype(railtype) || !ValParamTrackOrientation(track)) return CMD_ERROR; |
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:
2916
diff
changeset
|
521 |
if (p1 >= MapSize()) return CMD_ERROR; |
3493
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
522 |
end_tile = p1; |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
523 |
trackdir = TrackToTrackdir(track); |
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:
1719
diff
changeset
|
524 |
|
889
7f8630bfea41
(svn r1375) -Fix: [1050990] Buying trains sometimes accounted for incorrectly. Was the result of the cost getting reset in a recursive call of docommand. That is fixed. In addition all cost-commands are typed explicitely. Please do not forget to do so or your costs will be credited to construction if you are unlucky.
darkvater
parents:
826
diff
changeset
|
525 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
7f8630bfea41
(svn r1375) -Fix: [1050990] Buying trains sometimes accounted for incorrectly. Was the result of the cost getting reset in a recursive call of docommand. That is fixed. In addition all cost-commands are typed explicitely. Please do not forget to do so or your costs will be credited to construction if you are unlucky.
darkvater
parents:
826
diff
changeset
|
526 |
|
3493
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
527 |
if (CmdFailed(ValidateAutoDrag(&trackdir, tile, end_tile))) return CMD_ERROR; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
528 |
|
3493
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
529 |
if (flags & DC_EXEC) SndPlayTileFx(SND_20_SPLAT_2, tile); |
0 | 530 |
|
2952 | 531 |
for (;;) { |
3493
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
532 |
ret = DoCommand(tile, railtype, TrackdirToTrack(trackdir), flags, (mode == 0) ? CMD_BUILD_SINGLE_RAIL : CMD_REMOVE_SINGLE_RAIL); |
0 | 533 |
|
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:
1719
diff
changeset
|
534 |
if (CmdFailed(ret)) { |
3671
6d3a34989d05
(svn r4586) - Codechange: Recursive commands that rely on _error_message to handle success/failure can fail if a recursive call fails but doesn't set the error message, thus resulting in an old, possibly erroneous being used (see FS#130 prior to r4585). Now properly reset the global variable _error_message in these cases.
Darkvater
parents:
3657
diff
changeset
|
535 |
if ((_error_message != STR_1007_ALREADY_BUILT) && (mode == 0)) break; |
6d3a34989d05
(svn r4586) - Codechange: Recursive commands that rely on _error_message to handle success/failure can fail if a recursive call fails but doesn't set the error message, thus resulting in an old, possibly erroneous being used (see FS#130 prior to r4585). Now properly reset the global variable _error_message in these cases.
Darkvater
parents:
3657
diff
changeset
|
536 |
_error_message = INVALID_STRING_ID; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
537 |
} else { |
0 | 538 |
total_cost += ret; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
539 |
} |
0 | 540 |
|
3493
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
541 |
if (tile == end_tile) break; |
0 | 542 |
|
3493
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
543 |
tile += ToTileIndexDiff(_trackdelta[trackdir]); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
544 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
545 |
/* toggle railbit for the non-diagonal tracks */ |
6453
e65715f6e063
(svn r8864) -Codechange: make ClrBitT(), SetBitT() and ToggleBitT more like CLRBIT() and so on (modify value of the first parameter instead or returning the result)
KUDr
parents:
6432
diff
changeset
|
546 |
if (!IsDiagonalTrackdir(trackdir)) ToggleBitT(trackdir, 0); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
547 |
} |
0 | 548 |
|
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:
1719
diff
changeset
|
549 |
return (total_cost == 0) ? CMD_ERROR : total_cost; |
0 | 550 |
} |
551 |
||
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
552 |
/** Build rail on a stretch of track. |
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
553 |
* Stub for the unified rail builder/remover |
9909
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
554 |
* @param tile start tile of drag |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
555 |
* @param flags operation to perform |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
556 |
* @param p1 end tile of drag |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
557 |
* @param p2 various bitstuffed elements |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
558 |
* - p2 = (bit 0-3) - railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev) |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
559 |
* - p2 = (bit 4-6) - track-orientation, valid values: 0-5 (Track enum) |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
560 |
* - p2 = (bit 7) - 0 = build, 1 = remove tracks |
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
561 |
* @see CmdRailTrackHelper |
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
562 |
*/ |
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
563 |
CommandCost CmdBuildRailroadTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
564 |
{ |
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:
3486
diff
changeset
|
565 |
return CmdRailTrackHelper(tile, flags, p1, CLRBIT(p2, 7)); |
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
566 |
} |
0 | 567 |
|
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
568 |
/** Build rail on a stretch of track. |
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
569 |
* Stub for the unified rail builder/remover |
9909
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
570 |
* @param tile start tile of drag |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
571 |
* @param flags operation to perform |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
572 |
* @param p1 end tile of drag |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
573 |
* @param p2 various bitstuffed elements |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
574 |
* - p2 = (bit 0-3) - railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev) |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
575 |
* - p2 = (bit 4-6) - track-orientation, valid values: 0-5 (Track enum) |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
576 |
* - p2 = (bit 7) - 0 = build, 1 = remove tracks |
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
577 |
* @see CmdRailTrackHelper |
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
578 |
*/ |
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
579 |
CommandCost CmdRemoveRailroadTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 580 |
{ |
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:
3486
diff
changeset
|
581 |
return CmdRailTrackHelper(tile, flags, p1, SETBIT(p2, 7)); |
0 | 582 |
} |
583 |
||
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:
1719
diff
changeset
|
584 |
/** Build a train depot |
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:
3486
diff
changeset
|
585 |
* @param tile position of the train depot |
9909
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
586 |
* @param flags operation to perform |
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:
1719
diff
changeset
|
587 |
* @param p1 rail type |
6460 | 588 |
* @param p2 bit 0..1 entrance direction (DiagDirection) |
2085
ae9e92ffe168
(svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents:
2049
diff
changeset
|
589 |
* |
ae9e92ffe168
(svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents:
2049
diff
changeset
|
590 |
* @todo When checking for the tile slope, |
ae9e92ffe168
(svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents:
2049
diff
changeset
|
591 |
* distingush between "Flat land required" and "land sloped in wrong direction" |
0 | 592 |
*/ |
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
593 |
CommandCost CmdBuildTrainDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 594 |
{ |
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:
1719
diff
changeset
|
595 |
Depot *d; |
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
596 |
CommandCost cost, ret; |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
597 |
Slope tileh; |
0 | 598 |
|
599 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
|
600 |
||
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:
1719
diff
changeset
|
601 |
/* check railtype and valid direction for depot (0 through 3), 4 in total */ |
6460 | 602 |
if (!ValParamRailtype(p1)) return CMD_ERROR; |
0 | 603 |
|
604 |
tileh = GetTileSlope(tile, NULL); |
|
2085
ae9e92ffe168
(svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents:
2049
diff
changeset
|
605 |
|
6460 | 606 |
DiagDirection dir = Extract<DiagDirection, 0>(p2); |
607 |
||
2085
ae9e92ffe168
(svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents:
2049
diff
changeset
|
608 |
/* Prohibit construction if |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4483
diff
changeset
|
609 |
* The tile is non-flat AND |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4483
diff
changeset
|
610 |
* 1) The AI is "old-school" |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4483
diff
changeset
|
611 |
* 2) build-on-slopes is disabled |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4483
diff
changeset
|
612 |
* 3) the tile is steep i.e. spans two height levels |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4483
diff
changeset
|
613 |
* 4) the exit points in the wrong direction |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4483
diff
changeset
|
614 |
*/ |
2085
ae9e92ffe168
(svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents:
2049
diff
changeset
|
615 |
|
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
616 |
if (tileh != SLOPE_FLAT && ( |
2548
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2544
diff
changeset
|
617 |
_is_old_ai_player || |
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2544
diff
changeset
|
618 |
!_patches.build_on_slopes || |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
619 |
IsSteepSlope(tileh) || |
6460 | 620 |
!CanBuildDepotByTileh(dir, tileh) |
2548
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2544
diff
changeset
|
621 |
)) { |
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2544
diff
changeset
|
622 |
return_cmd_error(STR_0007_FLAT_LAND_REQUIRED); |
0 | 623 |
} |
624 |
||
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:
3486
diff
changeset
|
625 |
ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
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:
1719
diff
changeset
|
626 |
if (CmdFailed(ret)) return CMD_ERROR; |
0 | 627 |
cost = ret; |
628 |
||
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
629 |
if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) 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:
5568
diff
changeset
|
630 |
|
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:
1719
diff
changeset
|
631 |
d = AllocateDepot(); |
2639 | 632 |
if (d == NULL) return CMD_ERROR; |
0 | 633 |
|
9903
dc85aaa556ae
(svn r9534) [gamebalance] -Codechange: Made the prices a member of the Economy and removed all global variables concerning prices (INCOMPLETE).
celestar
parents:
9895
diff
changeset
|
634 |
cost += _eco->GetPrice(CEconomy::BUILD_TRAIN_DEPOT, tile); |
dc85aaa556ae
(svn r9534) [gamebalance] -Codechange: Made the prices a member of the Economy and removed all global variables concerning prices (INCOMPLETE).
celestar
parents:
9895
diff
changeset
|
635 |
|
0 | 636 |
if (flags & DC_EXEC) { |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
637 |
MakeRailDepot(tile, _current_player, dir, (RailType)p1); |
3101
e2fdb8802c2f
(svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
3099
diff
changeset
|
638 |
MarkTileDirtyByTile(tile); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
639 |
|
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:
1719
diff
changeset
|
640 |
d->xy = tile; |
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:
1719
diff
changeset
|
641 |
d->town_index = ClosestTownFromTile(tile, (uint)-1)->index; |
0 | 642 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
643 |
UpdateSignalsOnSegment(tile, dir); |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
644 |
YapfNotifyTrackLayoutChange(tile, TrackdirToTrack(DiagdirToDiagTrackdir(dir))); |
0 | 645 |
} |
646 |
||
9903
dc85aaa556ae
(svn r9534) [gamebalance] -Codechange: Made the prices a member of the Economy and removed all global variables concerning prices (INCOMPLETE).
celestar
parents:
9895
diff
changeset
|
647 |
return cost; |
0 | 648 |
} |
649 |
||
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:
1719
diff
changeset
|
650 |
/** Build signals, alternate between double/single, signal/semaphore, |
5982
54218ea5af1e
(svn r8274) -Codechange (r8151): Move the automatic semaphore/signal checks inside the CMD_ functions where they are supposed to be. Achieve this by adding a seperate bit to p1/p2 to hold the CTRL-modifier. While here, use proper types, and 'unify' the parameter bit-meanings. 0 - ctrl-pressed, 1 - signal/semaphore, 2-4 - trackbits, 5 - remove (internal), 24-31 - drag density.
Darkvater
parents:
5919
diff
changeset
|
651 |
* pre/exit/combo-signals, and what-else not. If the rail piece does not |
54218ea5af1e
(svn r8274) -Codechange (r8151): Move the automatic semaphore/signal checks inside the CMD_ functions where they are supposed to be. Achieve this by adding a seperate bit to p1/p2 to hold the CTRL-modifier. While here, use proper types, and 'unify' the parameter bit-meanings. 0 - ctrl-pressed, 1 - signal/semaphore, 2-4 - trackbits, 5 - remove (internal), 24-31 - drag density.
Darkvater
parents:
5919
diff
changeset
|
652 |
* have any signals, bit 4 (cycle signal-type) is ignored |
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:
3486
diff
changeset
|
653 |
* @param tile tile where to build the signals |
9909
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
654 |
* @param flags operation to perform |
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:
1719
diff
changeset
|
655 |
* @param p1 various bitstuffed elements |
5986
1b9ab9629d36
(svn r8279) -Regression (r8274): Removing signals could fail under certain circumstances (not the proper bits of p1/p2 were set to trackbits). Moved trackbits back to bits 0..2, ctrl to 3, semaphore to 4. Also lower the decision of the ctrl-override of signal/semaphore from the GUI into the cmd function since we are passing the ctrl-bit anyways. Bug(s) found by Frostregen; thanks
Darkvater
parents:
5982
diff
changeset
|
656 |
* - p1 = (bit 0-2) - track-orientation, valid values: 0-5 (Track enum) |
1b9ab9629d36
(svn r8279) -Regression (r8274): Removing signals could fail under certain circumstances (not the proper bits of p1/p2 were set to trackbits). Moved trackbits back to bits 0..2, ctrl to 3, semaphore to 4. Also lower the decision of the ctrl-override of signal/semaphore from the GUI into the cmd function since we are passing the ctrl-bit anyways. Bug(s) found by Frostregen; thanks
Darkvater
parents:
5982
diff
changeset
|
657 |
* - p1 = (bit 3) - 1 = override signal/semaphore, or pre/exit/combo signal (CTRL-toggle) |
1b9ab9629d36
(svn r8279) -Regression (r8274): Removing signals could fail under certain circumstances (not the proper bits of p1/p2 were set to trackbits). Moved trackbits back to bits 0..2, ctrl to 3, semaphore to 4. Also lower the decision of the ctrl-override of signal/semaphore from the GUI into the cmd function since we are passing the ctrl-bit anyways. Bug(s) found by Frostregen; thanks
Darkvater
parents:
5982
diff
changeset
|
658 |
* - p1 = (bit 4) - 0 = signals, 1 = semaphores |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
659 |
* @param p2 used for CmdBuildManySignals() to copy direction of first signal |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
660 |
* TODO: p2 should be replaced by two bits for "along" and "against" the track. |
58
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
39
diff
changeset
|
661 |
*/ |
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
662 |
CommandCost CmdBuildSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 663 |
{ |
5986
1b9ab9629d36
(svn r8279) -Regression (r8274): Removing signals could fail under certain circumstances (not the proper bits of p1/p2 were set to trackbits). Moved trackbits back to bits 0..2, ctrl to 3, semaphore to 4. Also lower the decision of the ctrl-override of signal/semaphore from the GUI into the cmd function since we are passing the ctrl-bit anyways. Bug(s) found by Frostregen; thanks
Darkvater
parents:
5982
diff
changeset
|
664 |
Track track = (Track)GB(p1, 0, 3); |
1b9ab9629d36
(svn r8279) -Regression (r8274): Removing signals could fail under certain circumstances (not the proper bits of p1/p2 were set to trackbits). Moved trackbits back to bits 0..2, ctrl to 3, semaphore to 4. Also lower the decision of the ctrl-override of signal/semaphore from the GUI into the cmd function since we are passing the ctrl-bit anyways. Bug(s) found by Frostregen; thanks
Darkvater
parents:
5982
diff
changeset
|
665 |
bool pre_signal = HASBIT(p1, 3); |
1b9ab9629d36
(svn r8279) -Regression (r8274): Removing signals could fail under certain circumstances (not the proper bits of p1/p2 were set to trackbits). Moved trackbits back to bits 0..2, ctrl to 3, semaphore to 4. Also lower the decision of the ctrl-override of signal/semaphore from the GUI into the cmd function since we are passing the ctrl-bit anyways. Bug(s) found by Frostregen; thanks
Darkvater
parents:
5982
diff
changeset
|
666 |
SignalVariant sigvar = (pre_signal ^ HASBIT(p1, 4)) ? SIG_SEMAPHORE : SIG_ELECTRIC; |
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
667 |
CommandCost cost; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
668 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
669 |
if (!ValParamTrackOrientation(track) || !IsTileType(tile, MP_RAILWAY) || !EnsureNoVehicleOnGround(tile)) |
0 | 670 |
return CMD_ERROR; |
671 |
||
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:
1719
diff
changeset
|
672 |
/* Protect against invalid signal copying */ |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
673 |
if (p2 != 0 && (p2 & SignalOnTrack(track)) == 0) return CMD_ERROR; |
0 | 674 |
|
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
675 |
/* You can only build signals on plain rail tiles, and the selected track must exist */ |
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
676 |
if (!IsPlainRailTile(tile) || !HasTrack(tile, track)) return CMD_ERROR; |
1084 | 677 |
|
678 |
if (!CheckTileOwnership(tile)) return CMD_ERROR; |
|
679 |
||
58
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
39
diff
changeset
|
680 |
_error_message = STR_1005_NO_SUITABLE_RAILROAD_TRACK; |
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
39
diff
changeset
|
681 |
|
0 | 682 |
{ |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
683 |
/* See if this is a valid track combination for signals, (ie, no overlap) */ |
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
684 |
TrackBits trackbits = GetTrackBits(tile); |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
685 |
if (KILL_FIRST_BIT(trackbits) != 0 && /* More than one track present */ |
3258
94a915e7485f
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
686 |
trackbits != TRACK_BIT_HORZ && |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
687 |
trackbits != TRACK_BIT_VERT) { |
0 | 688 |
return CMD_ERROR; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
689 |
} |
0 | 690 |
} |
691 |
||
1084 | 692 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
0 | 693 |
|
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
694 |
if (!HasSignalOnTrack(tile, track)) { |
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
695 |
/* build new signals */ |
9903
dc85aaa556ae
(svn r9534) [gamebalance] -Codechange: Made the prices a member of the Economy and removed all global variables concerning prices (INCOMPLETE).
celestar
parents:
9895
diff
changeset
|
696 |
cost = _eco->GetPrice(CEconomy::BUILD_SIGNALS); |
1066
aad3c6ad147f
(svn r1567) -Fix: [110452] On horizontal/vertical tracks you are also charged for building/removing signals on the parallel track on the same tile. Signal updating is also correct. (Hackykid)
darkvater
parents:
1059
diff
changeset
|
697 |
} else { |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
698 |
if (p2 != 0 && sigvar != GetSignalVariant(tile, track)) { |
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
699 |
/* convert signals <-> semaphores */ |
9903
dc85aaa556ae
(svn r9534) [gamebalance] -Codechange: Made the prices a member of the Economy and removed all global variables concerning prices (INCOMPLETE).
celestar
parents:
9895
diff
changeset
|
700 |
cost = _eco->GetPrice(CEconomy::BUILD_SIGNALS) + _eco->GetPrice(CEconomy::REMOVE_SIGNALS); |
1084 | 701 |
} else { |
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
702 |
/* it is free to change orientation/pre-exit-combo signals */ |
1084 | 703 |
cost = 0; |
704 |
} |
|
0 | 705 |
} |
706 |
||
707 |
if (flags & DC_EXEC) { |
|
4182
20d711816338
(svn r5624) Use {IsPlainRailTile,IsRailDepot,IsRailWaypoint,HasSignals}() instead of GetRailTile{T,Subt}ype() - this is more concise and a bit more flexible if/when the rail tile encoding changes
tron
parents:
4180
diff
changeset
|
708 |
if (!HasSignals(tile)) { |
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
709 |
/* there are no signals at all on this tile yet */ |
6498
aff910a05c6e
(svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents:
6486
diff
changeset
|
710 |
SetHasSignals(tile, true); |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
711 |
SetSignalStates(tile, 0xF); // all signals are on |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
712 |
SetPresentSignals(tile, 0); // no signals built by default |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
713 |
SetSignalType(tile, track, SIGTYPE_NORMAL); |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
714 |
SetSignalVariant(tile, track, sigvar); |
0 | 715 |
} |
716 |
||
1084 | 717 |
if (p2 == 0) { |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
718 |
if (!HasSignalOnTrack(tile, track)) { |
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
719 |
/* build new signals */ |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
720 |
SetPresentSignals(tile, GetPresentSignals(tile) | SignalOnTrack(track)); |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
721 |
SetSignalType(tile, track, SIGTYPE_NORMAL); |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
722 |
SetSignalVariant(tile, track, sigvar); |
1084 | 723 |
} else { |
724 |
if (pre_signal) { |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
725 |
/* cycle between normal -> pre -> exit -> combo -> ... */ |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
726 |
SignalType type = GetSignalType(tile, track); |
3238
a100405fe221
(svn r3912) Move the signal type enum and GetSignalType() to rail_map.h; also add SetSignalType() and use the functions
tron
parents:
3237
diff
changeset
|
727 |
|
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
728 |
SetSignalType(tile, track, type == SIGTYPE_COMBO ? SIGTYPE_NORMAL : (SignalType)(type + 1)); |
1084 | 729 |
} else { |
3522
25ce619b9a19
(svn r4378) -Add and make use of an accessor function two-way => one-way => one-way => two-way signal cycling
celestar
parents:
3521
diff
changeset
|
730 |
CycleSignalSide(tile, track); |
1084 | 731 |
} |
732 |
} |
|
58
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
39
diff
changeset
|
733 |
} else { |
1084 | 734 |
/* If CmdBuildManySignals is called with copying signals, just copy the |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
735 |
* direction of the first signal given as parameter by CmdBuildManySignals */ |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
736 |
SetPresentSignals(tile, (GetPresentSignals(tile) & ~SignalOnTrack(track)) | (p2 & SignalOnTrack(track))); |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
737 |
SetSignalVariant(tile, track, sigvar); |
0 | 738 |
} |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
739 |
|
0 | 740 |
MarkTileDirtyByTile(tile); |
741 |
SetSignalsOnBothDir(tile, track); |
|
3900
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
742 |
YapfNotifyTrackLayoutChange(tile, track); |
0 | 743 |
} |
744 |
||
745 |
return cost; |
|
746 |
} |
|
747 |
||
4434
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4388
diff
changeset
|
748 |
/** Build many signals by dragging; AutoSignals |
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:
3486
diff
changeset
|
749 |
* @param tile start tile of drag |
9909
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
750 |
* @param flags operation to perform |
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
751 |
* @param p1 end tile of drag |
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
752 |
* @param p2 various bitstuffed elements |
5986
1b9ab9629d36
(svn r8279) -Regression (r8274): Removing signals could fail under certain circumstances (not the proper bits of p1/p2 were set to trackbits). Moved trackbits back to bits 0..2, ctrl to 3, semaphore to 4. Also lower the decision of the ctrl-override of signal/semaphore from the GUI into the cmd function since we are passing the ctrl-bit anyways. Bug(s) found by Frostregen; thanks
Darkvater
parents:
5982
diff
changeset
|
753 |
* - p2 = (bit 0- 2) - track-orientation, valid values: 0-5 (Track enum) |
1b9ab9629d36
(svn r8279) -Regression (r8274): Removing signals could fail under certain circumstances (not the proper bits of p1/p2 were set to trackbits). Moved trackbits back to bits 0..2, ctrl to 3, semaphore to 4. Also lower the decision of the ctrl-override of signal/semaphore from the GUI into the cmd function since we are passing the ctrl-bit anyways. Bug(s) found by Frostregen; thanks
Darkvater
parents:
5982
diff
changeset
|
754 |
* - p2 = (bit 3) - 1 = override signal/semaphore, or pre/exit/combo signal (CTRL-toggle) |
1b9ab9629d36
(svn r8279) -Regression (r8274): Removing signals could fail under certain circumstances (not the proper bits of p1/p2 were set to trackbits). Moved trackbits back to bits 0..2, ctrl to 3, semaphore to 4. Also lower the decision of the ctrl-override of signal/semaphore from the GUI into the cmd function since we are passing the ctrl-bit anyways. Bug(s) found by Frostregen; thanks
Darkvater
parents:
5982
diff
changeset
|
755 |
* - p2 = (bit 4) - 0 = signals, 1 = semaphores |
5982
54218ea5af1e
(svn r8274) -Codechange (r8151): Move the automatic semaphore/signal checks inside the CMD_ functions where they are supposed to be. Achieve this by adding a seperate bit to p1/p2 to hold the CTRL-modifier. While here, use proper types, and 'unify' the parameter bit-meanings. 0 - ctrl-pressed, 1 - signal/semaphore, 2-4 - trackbits, 5 - remove (internal), 24-31 - drag density.
Darkvater
parents:
5919
diff
changeset
|
756 |
* - p2 = (bit 5) - 0 = build, 1 = remove signals |
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
757 |
* - p2 = (bit 24-31) - user defined signals_density |
58
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
39
diff
changeset
|
758 |
*/ |
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
759 |
static CommandCost CmdSignalTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
58
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
39
diff
changeset
|
760 |
{ |
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
761 |
CommandCost ret, total_cost; |
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
762 |
int signal_ctr; |
1954
58fee2f9eb81
(svn r2460) - Fix: Prevent assertion failure when trying to drag signals starting from a non-rail tile.
hackykid
parents:
1946
diff
changeset
|
763 |
byte signals; |
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
764 |
bool error = true; |
3493
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
765 |
TileIndex end_tile; |
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
766 |
|
5986
1b9ab9629d36
(svn r8279) -Regression (r8274): Removing signals could fail under certain circumstances (not the proper bits of p1/p2 were set to trackbits). Moved trackbits back to bits 0..2, ctrl to 3, semaphore to 4. Also lower the decision of the ctrl-override of signal/semaphore from the GUI into the cmd function since we are passing the ctrl-bit anyways. Bug(s) found by Frostregen; thanks
Darkvater
parents:
5982
diff
changeset
|
767 |
Track track = (Track)GB(p2, 0, 3); |
1b9ab9629d36
(svn r8279) -Regression (r8274): Removing signals could fail under certain circumstances (not the proper bits of p1/p2 were set to trackbits). Moved trackbits back to bits 0..2, ctrl to 3, semaphore to 4. Also lower the decision of the ctrl-override of signal/semaphore from the GUI into the cmd function since we are passing the ctrl-bit anyways. Bug(s) found by Frostregen; thanks
Darkvater
parents:
5982
diff
changeset
|
768 |
bool mode = HASBIT(p2, 3); |
1b9ab9629d36
(svn r8279) -Regression (r8274): Removing signals could fail under certain circumstances (not the proper bits of p1/p2 were set to trackbits). Moved trackbits back to bits 0..2, ctrl to 3, semaphore to 4. Also lower the decision of the ctrl-override of signal/semaphore from the GUI into the cmd function since we are passing the ctrl-bit anyways. Bug(s) found by Frostregen; thanks
Darkvater
parents:
5982
diff
changeset
|
769 |
bool semaphores = HASBIT(p2, 4); |
5982
54218ea5af1e
(svn r8274) -Codechange (r8151): Move the automatic semaphore/signal checks inside the CMD_ functions where they are supposed to be. Achieve this by adding a seperate bit to p1/p2 to hold the CTRL-modifier. While here, use proper types, and 'unify' the parameter bit-meanings. 0 - ctrl-pressed, 1 - signal/semaphore, 2-4 - trackbits, 5 - remove (internal), 24-31 - drag density.
Darkvater
parents:
5919
diff
changeset
|
770 |
bool remove = HASBIT(p2, 5); |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
771 |
Trackdir trackdir = TrackToTrackdir(track); |
5982
54218ea5af1e
(svn r8274) -Codechange (r8151): Move the automatic semaphore/signal checks inside the CMD_ functions where they are supposed to be. Achieve this by adding a seperate bit to p1/p2 to hold the CTRL-modifier. While here, use proper types, and 'unify' the parameter bit-meanings. 0 - ctrl-pressed, 1 - signal/semaphore, 2-4 - trackbits, 5 - remove (internal), 24-31 - drag density.
Darkvater
parents:
5919
diff
changeset
|
772 |
byte signal_density = GB(p2, 24, 8); |
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
773 |
|
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:
2916
diff
changeset
|
774 |
if (p1 >= MapSize()) return CMD_ERROR; |
3493
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
775 |
end_tile = p1; |
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
776 |
if (signal_density == 0 || signal_density > 20) return CMD_ERROR; |
58
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
39
diff
changeset
|
777 |
|
2639 | 778 |
if (!IsTileType(tile, MP_RAILWAY)) return CMD_ERROR; |
1954
58fee2f9eb81
(svn r2460) - Fix: Prevent assertion failure when trying to drag signals starting from a non-rail tile.
hackykid
parents:
1946
diff
changeset
|
779 |
|
889
7f8630bfea41
(svn r1375) -Fix: [1050990] Buying trains sometimes accounted for incorrectly. Was the result of the cost getting reset in a recursive call of docommand. That is fixed. In addition all cost-commands are typed explicitely. Please do not forget to do so or your costs will be credited to construction if you are unlucky.
darkvater
parents:
826
diff
changeset
|
780 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
7f8630bfea41
(svn r1375) -Fix: [1050990] Buying trains sometimes accounted for incorrectly. Was the result of the cost getting reset in a recursive call of docommand. That is fixed. In addition all cost-commands are typed explicitely. Please do not forget to do so or your costs will be credited to construction if you are unlucky.
darkvater
parents:
826
diff
changeset
|
781 |
|
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
782 |
/* for vertical/horizontal tracks, double the given signals density |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4483
diff
changeset
|
783 |
* since the original amount will be too dense (shorter tracks) */ |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
784 |
if (!IsDiagonalTrack(track)) signal_density *= 2; |
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
785 |
|
3493
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
786 |
if (CmdFailed(ValidateAutoDrag(&trackdir, tile, end_tile))) return CMD_ERROR; |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
787 |
|
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
788 |
track = TrackdirToTrack(trackdir); /* trackdir might have changed, keep track in sync */ |
58
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
39
diff
changeset
|
789 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
790 |
/* copy the signal-style of the first rail-piece if existing */ |
4182
20d711816338
(svn r5624) Use {IsPlainRailTile,IsRailDepot,IsRailWaypoint,HasSignals}() instead of GetRailTile{T,Subt}ype() - this is more concise and a bit more flexible if/when the rail tile encoding changes
tron
parents:
4180
diff
changeset
|
791 |
if (HasSignals(tile)) { |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
792 |
signals = GetPresentSignals(tile) & SignalOnTrack(track); |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
793 |
if (signals == 0) signals = SignalOnTrack(track); /* Can this actually occur? */ |
58
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
39
diff
changeset
|
794 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
795 |
/* copy signal/semaphores style (independent of CTRL) */ |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
796 |
semaphores = GetSignalVariant(tile, track) != SIG_ELECTRIC; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
797 |
} else { // no signals exist, drag a two-way signal stretch |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
798 |
signals = SignalOnTrack(track); |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
799 |
} |
58
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
39
diff
changeset
|
800 |
|
1954
58fee2f9eb81
(svn r2460) - Fix: Prevent assertion failure when trying to drag signals starting from a non-rail tile.
hackykid
parents:
1946
diff
changeset
|
801 |
/* signal_ctr - amount of tiles already processed |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
802 |
* signals_density - patch setting to put signal on every Nth tile (double space on |, -- tracks) |
58
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
39
diff
changeset
|
803 |
********** |
1954
58fee2f9eb81
(svn r2460) - Fix: Prevent assertion failure when trying to drag signals starting from a non-rail tile.
hackykid
parents:
1946
diff
changeset
|
804 |
* trackdir - trackdir to build with autorail |
58fee2f9eb81
(svn r2460) - Fix: Prevent assertion failure when trying to drag signals starting from a non-rail tile.
hackykid
parents:
1946
diff
changeset
|
805 |
* semaphores - semaphores or signals |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
806 |
* signals - is there a signal/semaphore on the first tile, copy its style (two-way/single-way) |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4483
diff
changeset
|
807 |
* and convert all others to semaphore/signal |
5982
54218ea5af1e
(svn r8274) -Codechange (r8151): Move the automatic semaphore/signal checks inside the CMD_ functions where they are supposed to be. Achieve this by adding a seperate bit to p1/p2 to hold the CTRL-modifier. While here, use proper types, and 'unify' the parameter bit-meanings. 0 - ctrl-pressed, 1 - signal/semaphore, 2-4 - trackbits, 5 - remove (internal), 24-31 - drag density.
Darkvater
parents:
5919
diff
changeset
|
808 |
* remove - 1 remove signals, 0 build signals */ |
58
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
39
diff
changeset
|
809 |
signal_ctr = total_cost = 0; |
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
810 |
for (;;) { |
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
811 |
/* only build/remove signals with the specified density */ |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
812 |
if (signal_ctr % signal_density == 0) { |
5986
1b9ab9629d36
(svn r8279) -Regression (r8274): Removing signals could fail under certain circumstances (not the proper bits of p1/p2 were set to trackbits). Moved trackbits back to bits 0..2, ctrl to 3, semaphore to 4. Also lower the decision of the ctrl-override of signal/semaphore from the GUI into the cmd function since we are passing the ctrl-bit anyways. Bug(s) found by Frostregen; thanks
Darkvater
parents:
5982
diff
changeset
|
813 |
uint32 p1 = GB(TrackdirToTrack(trackdir), 0, 3); |
1b9ab9629d36
(svn r8279) -Regression (r8274): Removing signals could fail under certain circumstances (not the proper bits of p1/p2 were set to trackbits). Moved trackbits back to bits 0..2, ctrl to 3, semaphore to 4. Also lower the decision of the ctrl-override of signal/semaphore from the GUI into the cmd function since we are passing the ctrl-bit anyways. Bug(s) found by Frostregen; thanks
Darkvater
parents:
5982
diff
changeset
|
814 |
SB(p1, 3, 1, mode); |
1b9ab9629d36
(svn r8279) -Regression (r8274): Removing signals could fail under certain circumstances (not the proper bits of p1/p2 were set to trackbits). Moved trackbits back to bits 0..2, ctrl to 3, semaphore to 4. Also lower the decision of the ctrl-override of signal/semaphore from the GUI into the cmd function since we are passing the ctrl-bit anyways. Bug(s) found by Frostregen; thanks
Darkvater
parents:
5982
diff
changeset
|
815 |
SB(p1, 4, 1, semaphores); |
5982
54218ea5af1e
(svn r8274) -Codechange (r8151): Move the automatic semaphore/signal checks inside the CMD_ functions where they are supposed to be. Achieve this by adding a seperate bit to p1/p2 to hold the CTRL-modifier. While here, use proper types, and 'unify' the parameter bit-meanings. 0 - ctrl-pressed, 1 - signal/semaphore, 2-4 - trackbits, 5 - remove (internal), 24-31 - drag density.
Darkvater
parents:
5919
diff
changeset
|
816 |
ret = DoCommand(tile, p1, signals, flags, remove ? CMD_REMOVE_SIGNALS : CMD_BUILD_SIGNALS); |
58
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
39
diff
changeset
|
817 |
|
5069
8097cd4cd07a
(svn r7127) -Codechange [FS#149]: Improve the usability of the signal-dragger, do not bail out
Darkvater
parents:
5059
diff
changeset
|
818 |
/* Be user-friendly and try placing signals as much as possible */ |
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
819 |
if (CmdSucceeded(ret)) { |
58
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
39
diff
changeset
|
820 |
error = false; |
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
39
diff
changeset
|
821 |
total_cost += ret; |
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
39
diff
changeset
|
822 |
} |
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
39
diff
changeset
|
823 |
} |
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
39
diff
changeset
|
824 |
|
3493
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
825 |
if (tile == end_tile) break; |
58
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
39
diff
changeset
|
826 |
|
3493
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
827 |
tile += ToTileIndexDiff(_trackdelta[trackdir]); |
58
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
39
diff
changeset
|
828 |
signal_ctr++; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
829 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
830 |
/* toggle railbit for the non-diagonal tracks (|, -- tracks) */ |
6453
e65715f6e063
(svn r8864) -Codechange: make ClrBitT(), SetBitT() and ToggleBitT more like CLRBIT() and so on (modify value of the first parameter instead or returning the result)
KUDr
parents:
6432
diff
changeset
|
831 |
if (!IsDiagonalTrackdir(trackdir)) ToggleBitT(trackdir, 0); |
58
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
39
diff
changeset
|
832 |
} |
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
39
diff
changeset
|
833 |
|
2951 | 834 |
return error ? CMD_ERROR : total_cost; |
58
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
39
diff
changeset
|
835 |
} |
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
39
diff
changeset
|
836 |
|
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
837 |
/** Build signals on a stretch of track. |
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
838 |
* Stub for the unified signal builder/remover |
9909
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
839 |
* @param tile start tile of drag |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
840 |
* @param flags operation to perform |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
841 |
* @param p1 end tile of drag |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
842 |
* @param p2 various bitstuffed elements |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
843 |
* - p2 = (bit 0- 2) - track-orientation, valid values: 0-5 (Track enum) |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
844 |
* - p2 = (bit 3) - 1 = override signal/semaphore, or pre/exit/combo signal (CTRL-toggle) |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
845 |
* - p2 = (bit 4) - 0 = signals, 1 = semaphores |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
846 |
* - p2 = (bit 5) - 0 = build, 1 = remove signals |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
847 |
* - p2 = (bit 24-31) - user defined signals_density |
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
848 |
* @see CmdSignalTrackHelper |
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
849 |
*/ |
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
850 |
CommandCost CmdBuildSignalTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
851 |
{ |
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:
3486
diff
changeset
|
852 |
return CmdSignalTrackHelper(tile, flags, p1, p2); |
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
853 |
} |
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
854 |
|
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:
1719
diff
changeset
|
855 |
/** Remove signals |
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:
3486
diff
changeset
|
856 |
* @param tile coordinates where signal is being deleted from |
9909
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
857 |
* @param flags operation to perform |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
858 |
* @param p1 various bitstuffed elements, only track information is used |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
859 |
* - (bit 0- 2) - track-orientation, valid values: 0-5 (Track enum) |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
860 |
* - (bit 3) - override signal/semaphore, or pre/exit/combo signal (CTRL-toggle) |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
861 |
* - (bit 4) - 0 = signals, 1 = semaphores |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
862 |
* @param p2 unused |
0 | 863 |
*/ |
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
864 |
CommandCost CmdRemoveSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 865 |
{ |
5986
1b9ab9629d36
(svn r8279) -Regression (r8274): Removing signals could fail under certain circumstances (not the proper bits of p1/p2 were set to trackbits). Moved trackbits back to bits 0..2, ctrl to 3, semaphore to 4. Also lower the decision of the ctrl-override of signal/semaphore from the GUI into the cmd function since we are passing the ctrl-bit anyways. Bug(s) found by Frostregen; thanks
Darkvater
parents:
5982
diff
changeset
|
866 |
Track track = (Track)GB(p1, 0, 3); |
1518
ade7a74ac31a
(svn r2022) Revise CmdRemoveSingleSignal: Check parameters for validity and simplify the function
tron
parents:
1477
diff
changeset
|
867 |
|
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
868 |
if (!ValParamTrackOrientation(track) || |
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
869 |
!IsTileType(tile, MP_RAILWAY) || |
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
870 |
!EnsureNoVehicleOnGround(tile) || |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
871 |
!HasSignalOnTrack(tile, track)) { |
1518
ade7a74ac31a
(svn r2022) Revise CmdRemoveSingleSignal: Check parameters for validity and simplify the function
tron
parents:
1477
diff
changeset
|
872 |
return CMD_ERROR; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
873 |
} |
1518
ade7a74ac31a
(svn r2022) Revise CmdRemoveSingleSignal: Check parameters for validity and simplify the function
tron
parents:
1477
diff
changeset
|
874 |
|
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:
1719
diff
changeset
|
875 |
/* Only water can remove signals from anyone */ |
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:
1719
diff
changeset
|
876 |
if (_current_player != OWNER_WATER && !CheckTileOwnership(tile)) return CMD_ERROR; |
0 | 877 |
|
878 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
|
879 |
||
880 |
/* Do it? */ |
|
881 |
if (flags & DC_EXEC) { |
|
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
882 |
SetPresentSignals(tile, GetPresentSignals(tile) & ~SignalOnTrack(track)); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
883 |
|
1066
aad3c6ad147f
(svn r1567) -Fix: [110452] On horizontal/vertical tracks you are also charged for building/removing signals on the parallel track on the same tile. Signal updating is also correct. (Hackykid)
darkvater
parents:
1059
diff
changeset
|
884 |
/* removed last signal from tile? */ |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
885 |
if (GetPresentSignals(tile) == 0) { |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
886 |
SetSignalStates(tile, 0); |
6498
aff910a05c6e
(svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents:
6486
diff
changeset
|
887 |
SetHasSignals(tile, false); |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
888 |
SetSignalVariant(tile, INVALID_TRACK, SIG_ELECTRIC); // remove any possible semaphores |
1066
aad3c6ad147f
(svn r1567) -Fix: [110452] On horizontal/vertical tracks you are also charged for building/removing signals on the parallel track on the same tile. Signal updating is also correct. (Hackykid)
darkvater
parents:
1059
diff
changeset
|
889 |
} |
1109
1bab892228cd
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1095
diff
changeset
|
890 |
|
1066
aad3c6ad147f
(svn r1567) -Fix: [110452] On horizontal/vertical tracks you are also charged for building/removing signals on the parallel track on the same tile. Signal updating is also correct. (Hackykid)
darkvater
parents:
1059
diff
changeset
|
891 |
SetSignalsOnBothDir(tile, track); |
3900
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
892 |
YapfNotifyTrackLayoutChange(tile, track); |
0 | 893 |
|
894 |
MarkTileDirtyByTile(tile); |
|
895 |
} |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
896 |
|
9903
dc85aaa556ae
(svn r9534) [gamebalance] -Codechange: Made the prices a member of the Economy and removed all global variables concerning prices (INCOMPLETE).
celestar
parents:
9895
diff
changeset
|
897 |
return _eco->GetPrice(CEconomy::REMOVE_SIGNALS); |
0 | 898 |
} |
899 |
||
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
900 |
/** Remove signals on a stretch of track. |
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
901 |
* Stub for the unified signal builder/remover |
9909
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
902 |
* @param tile start tile of drag |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
903 |
* @param flags operation to perform |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
904 |
* @param p1 end tile of drag |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
905 |
* @param p2 various bitstuffed elements |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
906 |
* - p2 = (bit 0- 2) - track-orientation, valid values: 0-5 (Track enum) |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
907 |
* - p2 = (bit 3) - 1 = override signal/semaphore, or pre/exit/combo signal (CTRL-toggle) |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
908 |
* - p2 = (bit 4) - 0 = signals, 1 = semaphores |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
909 |
* - p2 = (bit 5) - 0 = build, 1 = remove signals |
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
910 |
* - p2 = (bit 24-31) - user defined signals_density |
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
911 |
* @see CmdSignalTrackHelper |
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1782
diff
changeset
|
912 |
*/ |
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
913 |
CommandCost CmdRemoveSignalTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
914 |
{ |
5982
54218ea5af1e
(svn r8274) -Codechange (r8151): Move the automatic semaphore/signal checks inside the CMD_ functions where they are supposed to be. Achieve this by adding a seperate bit to p1/p2 to hold the CTRL-modifier. While here, use proper types, and 'unify' the parameter bit-meanings. 0 - ctrl-pressed, 1 - signal/semaphore, 2-4 - trackbits, 5 - remove (internal), 24-31 - drag density.
Darkvater
parents:
5919
diff
changeset
|
915 |
return CmdSignalTrackHelper(tile, flags, p1, SETBIT(p2, 5)); // bit 5 is remove bit |
1227
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
916 |
} |
3552f20fcfcb
(svn r1731) - Fix: [ 1106930 ] BugFix: placing signals with 2x1 drags workaround is completely rewritten. Also features checks for hacked/modified clients. Thanks a lot Hackykid!
darkvater
parents:
1209
diff
changeset
|
917 |
|
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
918 |
typedef CommandCost DoConvertRailProc(TileIndex tile, RailType totype, bool exec); |
0 | 919 |
|
9907
3b068c3a1c74
(svn r9675) [gamebalance] -Sync: r9420:9520 from trunk
celestar
parents:
9906
diff
changeset
|
920 |
/** |
3b068c3a1c74
(svn r9675) [gamebalance] -Sync: r9420:9520 from trunk
celestar
parents:
9906
diff
changeset
|
921 |
* Switches the rail type. |
3b068c3a1c74
(svn r9675) [gamebalance] -Sync: r9420:9520 from trunk
celestar
parents:
9906
diff
changeset
|
922 |
* Railtypes are stored on a per-tile basis, not on a per-track basis, so |
3b068c3a1c74
(svn r9675) [gamebalance] -Sync: r9420:9520 from trunk
celestar
parents:
9906
diff
changeset
|
923 |
* all the tracks in the given tile will be converted. |
3b068c3a1c74
(svn r9675) [gamebalance] -Sync: r9420:9520 from trunk
celestar
parents:
9906
diff
changeset
|
924 |
* @param tile The tile on which the railtype is to be convert. |
3b068c3a1c74
(svn r9675) [gamebalance] -Sync: r9420:9520 from trunk
celestar
parents:
9906
diff
changeset
|
925 |
* @param totype The railtype we want to convert to |
3b068c3a1c74
(svn r9675) [gamebalance] -Sync: r9420:9520 from trunk
celestar
parents:
9906
diff
changeset
|
926 |
* @param exec Switches between test and execute mode |
3b068c3a1c74
(svn r9675) [gamebalance] -Sync: r9420:9520 from trunk
celestar
parents:
9906
diff
changeset
|
927 |
* @return The cost and state of the operation |
3b068c3a1c74
(svn r9675) [gamebalance] -Sync: r9420:9520 from trunk
celestar
parents:
9906
diff
changeset
|
928 |
* @retval CMD_ERROR An error occured during the operation. |
3b068c3a1c74
(svn r9675) [gamebalance] -Sync: r9420:9520 from trunk
celestar
parents:
9906
diff
changeset
|
929 |
*/ |
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
930 |
static CommandCost DoConvertRail(TileIndex tile, RailType totype, bool exec) |
0 | 931 |
{ |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3333
diff
changeset
|
932 |
if (!CheckTileOwnership(tile)) return CMD_ERROR; |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3333
diff
changeset
|
933 |
|
9907
3b068c3a1c74
(svn r9675) [gamebalance] -Sync: r9420:9520 from trunk
celestar
parents:
9906
diff
changeset
|
934 |
if (GetRailType(tile) == totype) return CMD_ERROR; |
0 | 935 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
936 |
if (!EnsureNoVehicleOnGround(tile) && (!IsCompatibleRail(GetRailType(tile), totype) || IsPlainRailTile(tile))) return CMD_ERROR; |
0 | 937 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
938 |
/* 'hidden' elrails can't be downgraded to normal rail when elrails are disabled */ |
5116
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5069
diff
changeset
|
939 |
if (_patches.disable_elrails && totype == RAILTYPE_RAIL && GetRailType(tile) == RAILTYPE_ELECTRIC) return CMD_ERROR; |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5069
diff
changeset
|
940 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
941 |
/* change type. */ |
0 | 942 |
if (exec) { |
3242
1cefa03f0d5e
(svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents:
3238
diff
changeset
|
943 |
SetRailType(tile, totype); |
0 | 944 |
MarkTileDirtyByTile(tile); |
3869
446041505522
(svn r4906) - Fix: Refresh build vehicle window (if opened) when converting rail depot
glx
parents:
3794
diff
changeset
|
945 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
946 |
/* notify YAPF about the track layout change */ |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
947 |
TrackBits tracks = GetTrackBits(tile); |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
948 |
while (tracks != TRACK_BIT_NONE) { |
5849
58039c9dc565
(svn r8052) - Codechange: RemoveFirstTrack() and RemoveFirstTrackdir() now accept pointer to TrackBits/TrackdirBits instead of reference.
KUDr
parents:
5838
diff
changeset
|
949 |
YapfNotifyTrackLayoutChange(tile, RemoveFirstTrack(&tracks)); |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
950 |
} |
3900
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
951 |
|
3869
446041505522
(svn r4906) - Fix: Refresh build vehicle window (if opened) when converting rail depot
glx
parents:
3794
diff
changeset
|
952 |
if (IsTileDepotType(tile, TRANSPORT_RAIL)) { |
4556
693f37c36c85
(svn r6395) -Fix: when converting a depot from/to elrail, update the power of trains that are in it
glx
parents:
4549
diff
changeset
|
953 |
Vehicle *v; |
693f37c36c85
(svn r6395) -Fix: when converting a depot from/to elrail, update the power of trains that are in it
glx
parents:
4549
diff
changeset
|
954 |
|
693f37c36c85
(svn r6395) -Fix: when converting a depot from/to elrail, update the power of trains that are in it
glx
parents:
4549
diff
changeset
|
955 |
/* Update build vehicle window related to this depot */ |
4792
c5d474cb8623
(svn r6714) -Codechange: replaced a direct manipulation of windows with InvalidateWindowData() in rail_cmd.c
bjarni
parents:
4790
diff
changeset
|
956 |
InvalidateWindowData(WC_BUILD_VEHICLE, tile); |
4556
693f37c36c85
(svn r6395) -Fix: when converting a depot from/to elrail, update the power of trains that are in it
glx
parents:
4549
diff
changeset
|
957 |
|
693f37c36c85
(svn r6395) -Fix: when converting a depot from/to elrail, update the power of trains that are in it
glx
parents:
4549
diff
changeset
|
958 |
/* update power of trains in this depot */ |
693f37c36c85
(svn r6395) -Fix: when converting a depot from/to elrail, update the power of trains that are in it
glx
parents:
4549
diff
changeset
|
959 |
FOR_ALL_VEHICLES(v) { |
9895
7bd07f43b0e3
(svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents:
6513
diff
changeset
|
960 |
if (v->type == VEH_TRAIN && IsFrontEngine(v) && v->tile == tile && v->u.rail.track == 0x80) { |
4556
693f37c36c85
(svn r6395) -Fix: when converting a depot from/to elrail, update the power of trains that are in it
glx
parents:
4549
diff
changeset
|
961 |
TrainPowerChanged(v); |
693f37c36c85
(svn r6395) -Fix: when converting a depot from/to elrail, update the power of trains that are in it
glx
parents:
4549
diff
changeset
|
962 |
} |
693f37c36c85
(svn r6395) -Fix: when converting a depot from/to elrail, update the power of trains that are in it
glx
parents:
4549
diff
changeset
|
963 |
} |
3869
446041505522
(svn r4906) - Fix: Refresh build vehicle window (if opened) when converting rail depot
glx
parents:
3794
diff
changeset
|
964 |
} |
0 | 965 |
} |
966 |
||
9903
dc85aaa556ae
(svn r9534) [gamebalance] -Codechange: Made the prices a member of the Economy and removed all global variables concerning prices (INCOMPLETE).
celestar
parents:
9895
diff
changeset
|
967 |
return _eco->GetPrice(CEconomy::PRICE_RAIL_BUILD) / 2; |
0 | 968 |
} |
969 |
||
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
970 |
extern CommandCost DoConvertStationRail(TileIndex tile, RailType totype, bool exec); |
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
971 |
extern CommandCost DoConvertStreetRail(TileIndex tile, RailType totype, bool exec); |
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
972 |
extern CommandCost DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec); |
0 | 973 |
|
1782
0ac16ff36293
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1781
diff
changeset
|
974 |
/** Convert one rail type to the other. You can convert normal rail to |
0ac16ff36293
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1781
diff
changeset
|
975 |
* monorail/maglev easily or vice-versa. |
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:
3486
diff
changeset
|
976 |
* @param tile end tile of rail conversion drag |
9909
dce9a6923bb7
(svn r10133) [gamebalance] -Sync: r9620:9670 from trunk
celestar
parents:
9908
diff
changeset
|
977 |
* @param flags operation to perform |
1782
0ac16ff36293
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1781
diff
changeset
|
978 |
* @param p1 start tile of drag |
0ac16ff36293
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1781
diff
changeset
|
979 |
* @param p2 new railtype to convert to |
0ac16ff36293
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1781
diff
changeset
|
980 |
*/ |
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
981 |
CommandCost CmdConvertRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 982 |
{ |
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
983 |
CommandCost ret, cost; |
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
984 |
int32 money; |
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:
3486
diff
changeset
|
985 |
int ex; |
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3486
diff
changeset
|
986 |
int ey; |
1782
0ac16ff36293
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1781
diff
changeset
|
987 |
int sx, sy, x, y; |
0 | 988 |
|
889
7f8630bfea41
(svn r1375) -Fix: [1050990] Buying trains sometimes accounted for incorrectly. Was the result of the cost getting reset in a recursive call of docommand. That is fixed. In addition all cost-commands are typed explicitely. Please do not forget to do so or your costs will be credited to construction if you are unlucky.
darkvater
parents:
826
diff
changeset
|
989 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
7f8630bfea41
(svn r1375) -Fix: [1050990] Buying trains sometimes accounted for incorrectly. Was the result of the cost getting reset in a recursive call of docommand. That is fixed. In addition all cost-commands are typed explicitely. Please do not forget to do so or your costs will be credited to construction if you are unlucky.
darkvater
parents:
826
diff
changeset
|
990 |
|
1782
0ac16ff36293
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1781
diff
changeset
|
991 |
if (!ValParamRailtype(p2)) return CMD_ERROR; |
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:
2916
diff
changeset
|
992 |
if (p1 >= MapSize()) return CMD_ERROR; |
1782
0ac16ff36293
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1781
diff
changeset
|
993 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
994 |
/* make sure sx,sy are smaller than ex,ey */ |
3493
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
995 |
ex = TileX(tile); |
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
996 |
ey = TileY(tile); |
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
997 |
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
|
998 |
sy = TileY(p1); |
6432 | 999 |
if (ex < sx) Swap(ex, sx); |
1000 |
if (ey < sy) Swap(ey, sy); |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1001 |
|
0 | 1002 |
money = GetAvailableMoneyForCommand(); |
1003 |
cost = 0; |
|
3881 | 1004 |
ret = 0; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1005 |
|
3493
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
1006 |
for (x = sx; x <= ex; ++x) { |
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
1007 |
for (y = sy; y <= ey; ++y) { |
4d5830846ec2
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
1008 |
TileIndex tile = TileXY(x, y); |
2549 | 1009 |
DoConvertRailProc* proc; |
1782
0ac16ff36293
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1781
diff
changeset
|
1010 |
|
2549 | 1011 |
switch (GetTileType(tile)) { |
1012 |
case MP_RAILWAY: proc = DoConvertRail; break; |
|
1013 |
case MP_STATION: proc = DoConvertStationRail; break; |
|
1014 |
case MP_STREET: proc = DoConvertStreetRail; break; |
|
1015 |
case MP_TUNNELBRIDGE: proc = DoConvertTunnelBridgeRail; break; |
|
1016 |
default: continue; |
|
1017 |
} |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1018 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1019 |
ret = proc(tile, (RailType)p2, false); |
1782
0ac16ff36293
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1781
diff
changeset
|
1020 |
if (CmdFailed(ret)) continue; |
0 | 1021 |
cost += ret; |
1022 |
||
1023 |
if (flags & DC_EXEC) { |
|
2549 | 1024 |
money -= ret; |
1025 |
if (money < 0) { |
|
1026 |
_additional_cash_required = ret; |
|
1027 |
return cost - ret; |
|
1028 |
} |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1029 |
proc(tile, (RailType)p2, true); |
0 | 1030 |
} |
1031 |
} |
|
1032 |
} |
|
1782
0ac16ff36293
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1781
diff
changeset
|
1033 |
|
3881 | 1034 |
return (cost == 0) ? ret : cost; |
0 | 1035 |
} |
1036 |
||
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
1037 |
static CommandCost RemoveTrainDepot(TileIndex tile, uint32 flags) |
0 | 1038 |
{ |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
84
diff
changeset
|
1039 |
if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) |
0 | 1040 |
return CMD_ERROR; |
1041 |
||
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1042 |
if (!EnsureNoVehicleOnGround(tile)) |
0 | 1043 |
return CMD_ERROR; |
1044 |
||
1045 |
if (flags & DC_EXEC) { |
|
3191
d273bda0f5d4
(svn r3851) Rail depots only have an entrance at one side, therefore use UpdateSignalsOnSegment() instead of SetSignalsOnBothDir()
tron
parents:
3189
diff
changeset
|
1046 |
DiagDirection dir = GetRailDepotDirection(tile); |
0 | 1047 |
|
4388
e5a166837162
(svn r6141) -Codechange: introduced DepotID and used it as much as possible
truelight
parents:
4344
diff
changeset
|
1048 |
DeleteDepot(GetDepotByTile(tile)); |
3191
d273bda0f5d4
(svn r3851) Rail depots only have an entrance at one side, therefore use UpdateSignalsOnSegment() instead of SetSignalsOnBothDir()
tron
parents:
3189
diff
changeset
|
1049 |
UpdateSignalsOnSegment(tile, dir); |
3900
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
1050 |
YapfNotifyTrackLayoutChange(tile, TrackdirToTrack(DiagdirToDiagTrackdir(dir))); |
0 | 1051 |
} |
1052 |
||
9903
dc85aaa556ae
(svn r9534) [gamebalance] -Codechange: Made the prices a member of the Economy and removed all global variables concerning prices (INCOMPLETE).
celestar
parents:
9895
diff
changeset
|
1053 |
return _eco->GetPrice(CEconomy::REMOVE_TRAIN_DEPOT, tile, true); |
0 | 1054 |
} |
1055 |
||
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
1056 |
static CommandCost ClearTile_Track(TileIndex tile, byte flags) |
1534
2f7388d38291
(svn r2038) -Fix: A player only received the money for one rail when clearing a tile with 2 rails and signals
tron
parents:
1518
diff
changeset
|
1057 |
{ |
9913
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
1058 |
CommandCost cost; |
e79cd19772dd
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents:
9912
diff
changeset
|
1059 |
CommandCost ret; |
0 | 1060 |
|
1061 |
if (flags & DC_AUTO) { |
|
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
|
1062 |
if (!IsTileOwner(tile, _current_player)) |
0 | 1063 |
return_cmd_error(STR_1024_AREA_IS_OWNED_BY_ANOTHER); |
1064 |
||
4182
20d711816338
(svn r5624) Use {IsPlainRailTile,IsRailDepot,IsRailWaypoint,HasSignals}() instead of GetRailTile{T,Subt}ype() - this is more concise and a bit more flexible if/when the rail tile encoding changes
tron
parents:
4180
diff
changeset
|
1065 |
if (IsPlainRailTile(tile)) { |
20d711816338
(svn r5624) Use {IsPlainRailTile,IsRailDepot,IsRailWaypoint,HasSignals}() instead of GetRailTile{T,Subt}ype() - this is more concise and a bit more flexible if/when the rail tile encoding changes
tron
parents:
4180
diff
changeset
|
1066 |
return_cmd_error(STR_1008_MUST_REMOVE_RAILROAD_TRACK); |
20d711816338
(svn r5624) Use {IsPlainRailTile,IsRailDepot,IsRailWaypoint,HasSignals}() instead of GetRailTile{T,Subt}ype() - this is more concise and a bit more flexible if/when the rail tile encoding changes
tron
parents:
4180
diff
changeset
|
1067 |
} else { |
20d711816338
(svn r5624) Use {IsPlainRailTile,IsRailDepot,IsRailWaypoint,HasSignals}() instead of GetRailTile{T,Subt}ype() - this is more concise and a bit more flexible if/when the rail tile encoding changes
tron
parents:
4180
diff
changeset
|
1068 |
return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED); |
20d711816338
(svn r5624) Use {IsPlainRailTile,IsRailDepot,IsRailWaypoint,HasSignals}() instead of GetRailTile{T,Subt}ype() - this is more concise and a bit more flexible if/when the rail tile encoding changes
tron
parents:
4180
diff
changeset
|
1069 |
} |
0 | 1070 |
} |
1071 |
||
1072 |
cost = 0; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1073 |
|
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
1074 |
switch (GetRailTileType(tile)) { |
3792
2eb8388731bf
(svn r4788) - Codechange: RAILTYPE_{NORMAL,ELECTRIC,...} and RAIL_TYPE_{NORMAL,SIGNAL,...} have nearly the same name, rename RAIL_TYPE_* to RAIL_TILE_* of extra clarity
rubidium
parents:
3778
diff
changeset
|
1075 |
case RAIL_TILE_SIGNALS: |
2eb8388731bf
(svn r4788) - Codechange: RAILTYPE_{NORMAL,ELECTRIC,...} and RAIL_TYPE_{NORMAL,SIGNAL,...} have nearly the same name, rename RAIL_TYPE_* to RAIL_TILE_* of extra clarity
rubidium
parents:
3778
diff
changeset
|
1076 |
case RAIL_TILE_NORMAL: { |
5665
9498578ecbf2
(svn r7617) -Fix (7609): GetTrackBits only works (as intended) for plain rail tiles, so get the trackbits if it is certain it is a plain rail tile. Noticed by Tron.
rubidium
parents:
5662
diff
changeset
|
1077 |
TrackBits tracks = GetTrackBits(tile); |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1078 |
while (tracks != TRACK_BIT_NONE) { |
5849
58039c9dc565
(svn r8052) - Codechange: RemoveFirstTrack() and RemoveFirstTrackdir() now accept pointer to TrackBits/TrackdirBits instead of reference.
KUDr
parents:
5838
diff
changeset
|
1079 |
Track track = RemoveFirstTrack(&tracks); |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1080 |
ret = DoCommand(tile, 0, track, flags, CMD_REMOVE_SINGLE_RAIL); |
5662
2dd848654f54
(svn r7609) -Codechange: remove some direct map accesses to m5 and some unneeded signal removal code in ClearTileTrack as it is done in CmdRemoveSingleRail too, which is called for every removed trackbit.
rubidium
parents:
5582
diff
changeset
|
1081 |
if (CmdFailed(ret)) return CMD_ERROR; |
2dd848654f54
(svn r7609) -Codechange: remove some direct map accesses to m5 and some unneeded signal removal code in ClearTileTrack as it is done in CmdRemoveSingleRail too, which is called for every removed trackbit.
rubidium
parents:
5582
diff
changeset
|
1082 |
cost += ret; |
1534
2f7388d38291
(svn r2038) -Fix: A player only received the money for one rail when clearing a tile with 2 rails and signals
tron
parents:
1518
diff
changeset
|
1083 |
} |
2f7388d38291
(svn r2038) -Fix: A player only received the money for one rail when clearing a tile with 2 rails and signals
tron
parents:
1518
diff
changeset
|
1084 |
return cost; |
2f7388d38291
(svn r2038) -Fix: A player only received the money for one rail when clearing a tile with 2 rails and signals
tron
parents:
1518
diff
changeset
|
1085 |
} |
2f7388d38291
(svn r2038) -Fix: A player only received the money for one rail when clearing a tile with 2 rails and signals
tron
parents:
1518
diff
changeset
|
1086 |
|
6498
aff910a05c6e
(svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents:
6486
diff
changeset
|
1087 |
case RAIL_TILE_DEPOT: |
aff910a05c6e
(svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents:
6486
diff
changeset
|
1088 |
return RemoveTrainDepot(tile, flags); |
aff910a05c6e
(svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents:
6486
diff
changeset
|
1089 |
|
aff910a05c6e
(svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents:
6486
diff
changeset
|
1090 |
case RAIL_TILE_WAYPOINT: |
aff910a05c6e
(svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents:
6486
diff
changeset
|
1091 |
return RemoveTrainWaypoint(tile, flags, false); |
1534
2f7388d38291
(svn r2038) -Fix: A player only received the money for one rail when clearing a tile with 2 rails and signals
tron
parents:
1518
diff
changeset
|
1092 |
|
2f7388d38291
(svn r2038) -Fix: A player only received the money for one rail when clearing a tile with 2 rails and signals
tron
parents:
1518
diff
changeset
|
1093 |
default: |
2f7388d38291
(svn r2038) -Fix: A player only received the money for one rail when clearing a tile with 2 rails and signals
tron
parents:
1518
diff
changeset
|
1094 |
return CMD_ERROR; |
2f7388d38291
(svn r2038) -Fix: A player only received the money for one rail when clearing a tile with 2 rails and signals
tron
parents:
1518
diff
changeset
|
1095 |
} |
0 | 1096 |
} |
1097 |
||
1098 |
#include "table/track_land.h" |
|
1099 |
||
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1100 |
static void DrawSingleSignal(TileIndex tile, Track track, byte condition, uint image, uint pos) |
0 | 1101 |
{ |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1102 |
bool side = (_opt.road_side != 0) && _patches.signal_side; |
3502
d41ccd2fb5c5
(svn r4353) Codechange: Move global _signal_position into the only function that uses it and convert the bit-hacking into a struct
celestar
parents:
3493
diff
changeset
|
1103 |
static const Point SignalPositions[2][12] = { |
d41ccd2fb5c5
(svn r4353) Codechange: Move global _signal_position into the only function that uses it and convert the bit-hacking into a struct
celestar
parents:
3493
diff
changeset
|
1104 |
{ /* Signals on the left side */ |
d41ccd2fb5c5
(svn r4353) Codechange: Move global _signal_position into the only function that uses it and convert the bit-hacking into a struct
celestar
parents:
3493
diff
changeset
|
1105 |
/* LEFT LEFT RIGHT RIGHT UPPER UPPER */ |
d41ccd2fb5c5
(svn r4353) Codechange: Move global _signal_position into the only function that uses it and convert the bit-hacking into a struct
celestar
parents:
3493
diff
changeset
|
1106 |
{ 8, 5}, {14, 1}, { 1, 14}, { 9, 11}, { 1, 0}, { 3, 10}, |
d41ccd2fb5c5
(svn r4353) Codechange: Move global _signal_position into the only function that uses it and convert the bit-hacking into a struct
celestar
parents:
3493
diff
changeset
|
1107 |
/* LOWER LOWER X X Y Y */ |
d41ccd2fb5c5
(svn r4353) Codechange: Move global _signal_position into the only function that uses it and convert the bit-hacking into a struct
celestar
parents:
3493
diff
changeset
|
1108 |
{11, 4}, {14, 14}, {11, 3}, { 4, 13}, { 3, 4}, {11, 13} |
d41ccd2fb5c5
(svn r4353) Codechange: Move global _signal_position into the only function that uses it and convert the bit-hacking into a struct
celestar
parents:
3493
diff
changeset
|
1109 |
}, { /* Signals on the right side */ |
d41ccd2fb5c5
(svn r4353) Codechange: Move global _signal_position into the only function that uses it and convert the bit-hacking into a struct
celestar
parents:
3493
diff
changeset
|
1110 |
/* LEFT LEFT RIGHT RIGHT UPPER UPPER */ |
d41ccd2fb5c5
(svn r4353) Codechange: Move global _signal_position into the only function that uses it and convert the bit-hacking into a struct
celestar
parents:
3493
diff
changeset
|
1111 |
{14, 1}, {12, 10}, { 4, 6}, { 1, 14}, {10, 4}, { 0, 1}, |
d41ccd2fb5c5
(svn r4353) Codechange: Move global _signal_position into the only function that uses it and convert the bit-hacking into a struct
celestar
parents:
3493
diff
changeset
|
1112 |
/* LOWER LOWER X X Y Y */ |
d41ccd2fb5c5
(svn r4353) Codechange: Move global _signal_position into the only function that uses it and convert the bit-hacking into a struct
celestar
parents:
3493
diff
changeset
|
1113 |
{14, 14}, { 5, 12}, {11, 13}, { 4, 3}, {13, 4}, { 3, 11} |
d41ccd2fb5c5
(svn r4353) Codechange: Move global _signal_position into the only function that uses it and convert the bit-hacking into a struct
celestar
parents:
3493
diff
changeset
|
1114 |
} |
d41ccd2fb5c5
(svn r4353) Codechange: Move global _signal_position into the only function that uses it and convert the bit-hacking into a struct
celestar
parents:
3493
diff
changeset
|
1115 |
}; |
0 | 1116 |
|
3506
9a9489c7896f
(svn r4357) -Codechange: Moved global _signal_base_sprites into the only function where it is used and use a better array arrangement for it
celestar
parents:
3503
diff
changeset
|
1117 |
static const SpriteID SignalBase[2][2][4] = { |
9a9489c7896f
(svn r4357) -Codechange: Moved global _signal_base_sprites into the only function where it is used and use a better array arrangement for it
celestar
parents:
3503
diff
changeset
|
1118 |
{ /* Signals on left side */ |
9a9489c7896f
(svn r4357) -Codechange: Moved global _signal_base_sprites into the only function where it is used and use a better array arrangement for it
celestar
parents:
3503
diff
changeset
|
1119 |
{ 0x4FB, 0x1323, 0x1333, 0x1343}, /* light signals */ |
9a9489c7896f
(svn r4357) -Codechange: Moved global _signal_base_sprites into the only function where it is used and use a better array arrangement for it
celestar
parents:
3503
diff
changeset
|
1120 |
{ 0x1353, 0x1363, 0x1373, 0x1383} /* semaphores */ |
9a9489c7896f
(svn r4357) -Codechange: Moved global _signal_base_sprites into the only function where it is used and use a better array arrangement for it
celestar
parents:
3503
diff
changeset
|
1121 |
}, { /* Signals on right side */ |
9a9489c7896f
(svn r4357) -Codechange: Moved global _signal_base_sprites into the only function where it is used and use a better array arrangement for it
celestar
parents:
3503
diff
changeset
|
1122 |
{ 0x4FB, 0x1323, 0x1333, 0x1343}, /* light signals */ |
9a9489c7896f
(svn r4357) -Codechange: Moved global _signal_base_sprites into the only function where it is used and use a better array arrangement for it
celestar
parents:
3503
diff
changeset
|
1123 |
{ 0x1446, 0x1456, 0x1466, 0x1476} /* semaphores */ |
9a9489c7896f
(svn r4357) -Codechange: Moved global _signal_base_sprites into the only function where it is used and use a better array arrangement for it
celestar
parents:
3503
diff
changeset
|
1124 |
/* | | | | */ |
9a9489c7896f
(svn r4357) -Codechange: Moved global _signal_base_sprites into the only function where it is used and use a better array arrangement for it
celestar
parents:
3503
diff
changeset
|
1125 |
/* normal, entry, exit, combo */ |
9a9489c7896f
(svn r4357) -Codechange: Moved global _signal_base_sprites into the only function where it is used and use a better array arrangement for it
celestar
parents:
3503
diff
changeset
|
1126 |
} |
9a9489c7896f
(svn r4357) -Codechange: Moved global _signal_base_sprites into the only function where it is used and use a better array arrangement for it
celestar
parents:
3503
diff
changeset
|
1127 |
}; |
9a9489c7896f
(svn r4357) -Codechange: Moved global _signal_base_sprites into the only function where it is used and use a better array arrangement for it
celestar
parents:
3503
diff
changeset
|
1128 |
|
3575
867df1ec208a
(svn r4461) -Codechange: Add and make use of map accessor functions for signal drawing. Includes some basic cleanup of the drawing functions
celestar
parents:
3562
diff
changeset
|
1129 |
uint x = TileX(tile) * TILE_SIZE + SignalPositions[side][pos].x; |
867df1ec208a
(svn r4461) -Codechange: Add and make use of map accessor functions for signal drawing. Includes some basic cleanup of the drawing functions
celestar
parents:
3562
diff
changeset
|
1130 |
uint y = TileY(tile) * TILE_SIZE + SignalPositions[side][pos].y; |
867df1ec208a
(svn r4461) -Codechange: Add and make use of map accessor functions for signal drawing. Includes some basic cleanup of the drawing functions
celestar
parents:
3562
diff
changeset
|
1131 |
|
3638
6e0b43d905d4
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3636
diff
changeset
|
1132 |
SpriteID sprite; |
6e0b43d905d4
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3636
diff
changeset
|
1133 |
|
6e0b43d905d4
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3636
diff
changeset
|
1134 |
/* _signal_base is set by our NewGRF Action 5 loader. If it is 0 then we |
6e0b43d905d4
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3636
diff
changeset
|
1135 |
* just draw the standard signals, else we get the offset from _signal_base |
6e0b43d905d4
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3636
diff
changeset
|
1136 |
* and draw that sprite. All the signal sprites are loaded sequentially. */ |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1137 |
if (_signal_base == 0 || (GetSignalType(tile, track) == SIGTYPE_NORMAL && GetSignalVariant(tile, track) == SIG_ELECTRIC)) { |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1138 |
sprite = SignalBase[side][GetSignalVariant(tile, track)][GetSignalType(tile, track)] + image + condition; |
3638
6e0b43d905d4
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3636
diff
changeset
|
1139 |
} else { |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1140 |
sprite = _signal_base + (GetSignalType(tile, track) - 1) * 16 + GetSignalVariant(tile, track) * 64 + image + condition; |
3638
6e0b43d905d4
(svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents:
3636
diff
changeset
|
1141 |
} |
3575
867df1ec208a
(svn r4461) -Codechange: Add and make use of map accessor functions for signal drawing. Includes some basic cleanup of the drawing functions
celestar
parents:
3562
diff
changeset
|
1142 |
|
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1143 |
AddSortableSpriteToDraw(sprite, PAL_NONE, x, y, 1, 1, 10, GetSlopeZ(x,y)); |
0 | 1144 |
} |
1145 |
||
1146 |
static uint32 _drawtile_track_palette; |
|
1147 |
||
1148 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
1149 |
static void DrawTrackFence_NW(const TileInfo *ti) |
0 | 1150 |
{ |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1151 |
SpriteID image = 0x515; |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
1152 |
if (ti->tileh != SLOPE_FLAT) image = (ti->tileh & SLOPE_S) ? 0x519 : 0x51B; |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1153 |
AddSortableSpriteToDraw(image, _drawtile_track_palette, |
2951 | 1154 |
ti->x, ti->y + 1, 16, 1, 4, ti->z); |
0 | 1155 |
} |
1156 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
1157 |
static void DrawTrackFence_SE(const TileInfo *ti) |
0 | 1158 |
{ |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1159 |
SpriteID image = 0x515; |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
1160 |
if (ti->tileh != SLOPE_FLAT) image = (ti->tileh & SLOPE_S) ? 0x519 : 0x51B; |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1161 |
AddSortableSpriteToDraw(image, _drawtile_track_palette, |
3645
86af43f87885
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3638
diff
changeset
|
1162 |
ti->x, ti->y + TILE_SIZE - 1, 16, 1, 4, ti->z); |
0 | 1163 |
} |
1164 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
1165 |
static void DrawTrackFence_NW_SE(const TileInfo *ti) |
0 | 1166 |
{ |
1167 |
DrawTrackFence_NW(ti); |
|
1168 |
DrawTrackFence_SE(ti); |
|
1169 |
} |
|
1170 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
1171 |
static void DrawTrackFence_NE(const TileInfo *ti) |
0 | 1172 |
{ |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1173 |
SpriteID image = 0x516; |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
1174 |
if (ti->tileh != SLOPE_FLAT) image = (ti->tileh & SLOPE_S) ? 0x51A : 0x51C; |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1175 |
AddSortableSpriteToDraw(image, _drawtile_track_palette, |
2951 | 1176 |
ti->x + 1, ti->y, 1, 16, 4, ti->z); |
0 | 1177 |
} |
1178 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
1179 |
static void DrawTrackFence_SW(const TileInfo *ti) |
0 | 1180 |
{ |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1181 |
SpriteID image = 0x516; |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
1182 |
if (ti->tileh != SLOPE_FLAT) image = (ti->tileh & SLOPE_S) ? 0x51A : 0x51C; |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1183 |
AddSortableSpriteToDraw(image, _drawtile_track_palette, |
3645
86af43f87885
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3638
diff
changeset
|
1184 |
ti->x + TILE_SIZE - 1, ti->y, 1, 16, 4, ti->z); |
0 | 1185 |
} |
1186 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
1187 |
static void DrawTrackFence_NE_SW(const TileInfo *ti) |
0 | 1188 |
{ |
1189 |
DrawTrackFence_NE(ti); |
|
1190 |
DrawTrackFence_SW(ti); |
|
1191 |
} |
|
1192 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
1193 |
static void DrawTrackFence_NS_1(const TileInfo *ti) |
0 | 1194 |
{ |
1195 |
int z = ti->z; |
|
3645
86af43f87885
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3638
diff
changeset
|
1196 |
if (ti->tileh & SLOPE_W) z += TILE_HEIGHT; |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1197 |
AddSortableSpriteToDraw(0x517, _drawtile_track_palette, |
3645
86af43f87885
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3638
diff
changeset
|
1198 |
ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z); |
0 | 1199 |
} |
1200 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
1201 |
static void DrawTrackFence_NS_2(const TileInfo *ti) |
0 | 1202 |
{ |
1203 |
int z = ti->z; |
|
3645
86af43f87885
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3638
diff
changeset
|
1204 |
if (ti->tileh & SLOPE_E) z += TILE_HEIGHT; |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1205 |
AddSortableSpriteToDraw(0x517, _drawtile_track_palette, |
3645
86af43f87885
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3638
diff
changeset
|
1206 |
ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z); |
0 | 1207 |
} |
1208 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
1209 |
static void DrawTrackFence_WE_1(const TileInfo *ti) |
0 | 1210 |
{ |
1211 |
int z = ti->z; |
|
3645
86af43f87885
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3638
diff
changeset
|
1212 |
if (ti->tileh & SLOPE_N) z += TILE_HEIGHT; |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1213 |
AddSortableSpriteToDraw(0x518, _drawtile_track_palette, |
3645
86af43f87885
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3638
diff
changeset
|
1214 |
ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z); |
0 | 1215 |
} |
1216 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
1217 |
static void DrawTrackFence_WE_2(const TileInfo *ti) |
0 | 1218 |
{ |
1219 |
int z = ti->z; |
|
3645
86af43f87885
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3638
diff
changeset
|
1220 |
if (ti->tileh & SLOPE_S) z += TILE_HEIGHT; |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1221 |
AddSortableSpriteToDraw(0x518, _drawtile_track_palette, |
3645
86af43f87885
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3638
diff
changeset
|
1222 |
ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z); |
0 | 1223 |
} |
1224 |
||
4040
3c5fc0aea78d
(svn r5308) Replace an array of function pointers with a switch: It's shorter, more comprehensible, less dependent on magic numbers
tron
parents:
4000
diff
changeset
|
1225 |
|
3c5fc0aea78d
(svn r5308) Replace an array of function pointers with a switch: It's shorter, more comprehensible, less dependent on magic numbers
tron
parents:
4000
diff
changeset
|
1226 |
static void DrawTrackDetails(const TileInfo* ti) |
0 | 1227 |
{ |
4040
3c5fc0aea78d
(svn r5308) Replace an array of function pointers with a switch: It's shorter, more comprehensible, less dependent on magic numbers
tron
parents:
4000
diff
changeset
|
1228 |
switch (GetRailGroundType(ti->tile)) { |
3c5fc0aea78d
(svn r5308) Replace an array of function pointers with a switch: It's shorter, more comprehensible, less dependent on magic numbers
tron
parents:
4000
diff
changeset
|
1229 |
case RAIL_GROUND_FENCE_NW: DrawTrackFence_NW(ti); break; |
3c5fc0aea78d
(svn r5308) Replace an array of function pointers with a switch: It's shorter, more comprehensible, less dependent on magic numbers
tron
parents:
4000
diff
changeset
|
1230 |
case RAIL_GROUND_FENCE_SE: DrawTrackFence_SE(ti); break; |
3c5fc0aea78d
(svn r5308) Replace an array of function pointers with a switch: It's shorter, more comprehensible, less dependent on magic numbers
tron
parents:
4000
diff
changeset
|
1231 |
case RAIL_GROUND_FENCE_SENW: DrawTrackFence_NW_SE(ti); break; |
3c5fc0aea78d
(svn r5308) Replace an array of function pointers with a switch: It's shorter, more comprehensible, less dependent on magic numbers
tron
parents:
4000
diff
changeset
|
1232 |
case RAIL_GROUND_FENCE_NE: DrawTrackFence_NE(ti); break; |
3c5fc0aea78d
(svn r5308) Replace an array of function pointers with a switch: It's shorter, more comprehensible, less dependent on magic numbers
tron
parents:
4000
diff
changeset
|
1233 |
case RAIL_GROUND_FENCE_SW: DrawTrackFence_SW(ti); break; |
3c5fc0aea78d
(svn r5308) Replace an array of function pointers with a switch: It's shorter, more comprehensible, less dependent on magic numbers
tron
parents:
4000
diff
changeset
|
1234 |
case RAIL_GROUND_FENCE_NESW: DrawTrackFence_NE_SW(ti); break; |
3c5fc0aea78d
(svn r5308) Replace an array of function pointers with a switch: It's shorter, more comprehensible, less dependent on magic numbers
tron
parents:
4000
diff
changeset
|
1235 |
case RAIL_GROUND_FENCE_VERT1: DrawTrackFence_NS_1(ti); break; |
3c5fc0aea78d
(svn r5308) Replace an array of function pointers with a switch: It's shorter, more comprehensible, less dependent on magic numbers
tron
parents:
4000
diff
changeset
|
1236 |
case RAIL_GROUND_FENCE_VERT2: DrawTrackFence_NS_2(ti); break; |
3c5fc0aea78d
(svn r5308) Replace an array of function pointers with a switch: It's shorter, more comprehensible, less dependent on magic numbers
tron
parents:
4000
diff
changeset
|
1237 |
case RAIL_GROUND_FENCE_HORIZ1: DrawTrackFence_WE_1(ti); break; |
3c5fc0aea78d
(svn r5308) Replace an array of function pointers with a switch: It's shorter, more comprehensible, less dependent on magic numbers
tron
parents:
4000
diff
changeset
|
1238 |
case RAIL_GROUND_FENCE_HORIZ2: DrawTrackFence_WE_2(ti); break; |
3c5fc0aea78d
(svn r5308) Replace an array of function pointers with a switch: It's shorter, more comprehensible, less dependent on magic numbers
tron
parents:
4000
diff
changeset
|
1239 |
default: break; |
3c5fc0aea78d
(svn r5308) Replace an array of function pointers with a switch: It's shorter, more comprehensible, less dependent on magic numbers
tron
parents:
4000
diff
changeset
|
1240 |
} |
0 | 1241 |
} |
1242 |
||
1243 |
||
2472
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1244 |
/** |
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1245 |
* Draw ground sprite and track bits |
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1246 |
* @param ti TileInfo |
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1247 |
* @param track TrackBits to draw |
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1248 |
*/ |
4081 | 1249 |
static void DrawTrackBits(TileInfo* ti, TrackBits track) |
2472
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1250 |
{ |
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1251 |
const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile)); |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1252 |
SpriteID image; |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1253 |
SpriteID pal = PAL_NONE; |
2472
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1254 |
bool junction = false; |
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1255 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1256 |
/* Select the sprite to use. */ |
3102
fde95020fc8e
(svn r3697) Rename DIAG1/DIAG2 to X resp. Y as this conveys a bit better in which direction a pieces of rail goes
tron
parents:
3101
diff
changeset
|
1257 |
(image = rti->base_sprites.track_y, track == TRACK_BIT_Y) || |
fde95020fc8e
(svn r3697) Rename DIAG1/DIAG2 to X resp. Y as this conveys a bit better in which direction a pieces of rail goes
tron
parents:
3101
diff
changeset
|
1258 |
(image++, track == TRACK_BIT_X) || |
2472
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1259 |
(image++, track == TRACK_BIT_UPPER) || |
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1260 |
(image++, track == TRACK_BIT_LOWER) || |
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1261 |
(image++, track == TRACK_BIT_RIGHT) || |
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1262 |
(image++, track == TRACK_BIT_LEFT) || |
3258
94a915e7485f
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
1263 |
(image++, track == TRACK_BIT_CROSS) || |
2472
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1264 |
|
3258
94a915e7485f
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
1265 |
(image = rti->base_sprites.track_ns, track == TRACK_BIT_HORZ) || |
94a915e7485f
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
1266 |
(image++, track == TRACK_BIT_VERT) || |
2472
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1267 |
|
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1268 |
(junction = true, false) || |
3258
94a915e7485f
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
1269 |
(image = rti->base_sprites.ground, (track & TRACK_BIT_3WAY_NE) == 0) || |
94a915e7485f
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
1270 |
(image++, (track & TRACK_BIT_3WAY_SW) == 0) || |
94a915e7485f
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
1271 |
(image++, (track & TRACK_BIT_3WAY_NW) == 0) || |
94a915e7485f
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
1272 |
(image++, (track & TRACK_BIT_3WAY_SE) == 0) || |
2472
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1273 |
(image++, true); |
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1274 |
|
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
1275 |
if (ti->tileh != SLOPE_FLAT) { |
4081 | 1276 |
uint foundation = GetRailFoundation(ti->tileh, track); |
2472
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1277 |
|
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
1278 |
if (foundation != 0) DrawFoundation(ti, foundation); |
2472
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1279 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1280 |
/* DrawFoundation() modifies it. |
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1281 |
* Default sloped sprites.. */ |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
1282 |
if (ti->tileh != SLOPE_FLAT) |
2472
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1283 |
image = _track_sloped_sprites[ti->tileh - 1] + rti->base_sprites.track_y; |
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1284 |
} |
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1285 |
|
4466
480223faf4c4
(svn r6251) Replace 2 bool variables by a simple switch
tron
parents:
4440
diff
changeset
|
1286 |
switch (GetRailGroundType(ti->tile)) { |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1287 |
case RAIL_GROUND_BARREN: pal = PALETTE_TO_BARE_LAND; break; |
4466
480223faf4c4
(svn r6251) Replace 2 bool variables by a simple switch
tron
parents:
4440
diff
changeset
|
1288 |
case RAIL_GROUND_ICE_DESERT: image += rti->snow_offset; break; |
480223faf4c4
(svn r6251) Replace 2 bool variables by a simple switch
tron
parents:
4440
diff
changeset
|
1289 |
default: break; |
2472
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1290 |
} |
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1291 |
|
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1292 |
DrawGroundSprite(image, pal); |
2472
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1293 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1294 |
/* Draw track pieces individually for junction tiles */ |
2472
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1295 |
if (junction) { |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1296 |
if (track & TRACK_BIT_X) DrawGroundSprite(rti->base_sprites.single_y, PAL_NONE); |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1297 |
if (track & TRACK_BIT_Y) DrawGroundSprite(rti->base_sprites.single_x, PAL_NONE); |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1298 |
if (track & TRACK_BIT_UPPER) DrawGroundSprite(rti->base_sprites.single_n, PAL_NONE); |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1299 |
if (track & TRACK_BIT_LOWER) DrawGroundSprite(rti->base_sprites.single_s, PAL_NONE); |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1300 |
if (track & TRACK_BIT_LEFT) DrawGroundSprite(rti->base_sprites.single_w, PAL_NONE); |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1301 |
if (track & TRACK_BIT_RIGHT) DrawGroundSprite(rti->base_sprites.single_e, PAL_NONE); |
2472
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1302 |
} |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3333
diff
changeset
|
1303 |
|
3361
47e190d820e0
(svn r4156) CodeChange : Little cleanup after Celestar's elrail merge
belugas
parents:
3355
diff
changeset
|
1304 |
if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenary(ti); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3333
diff
changeset
|
1305 |
|
2472
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1306 |
} |
60c843b7ea28
(svn r2998) -Codechange: Split rail drawing code off from DrawTile_Rail into a separate function to be used elsewhere. (Deja vu?)
peter1138
parents:
2436
diff
changeset
|
1307 |
|
3519
22391e5d1bbf
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1308 |
static void DrawSignals(TileIndex tile, TrackBits rails) |
22391e5d1bbf
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1309 |
{ |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1310 |
#define MAYBE_DRAW_SIGNAL(x,y,z,t) if (IsSignalPresent(tile, x)) DrawSingleSignal(tile, t, GetSingleSignalState(tile, x), y - 0x4FB, z) |
3519
22391e5d1bbf
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1311 |
|
22391e5d1bbf
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1312 |
if (!(rails & TRACK_BIT_Y)) { |
22391e5d1bbf
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1313 |
if (!(rails & TRACK_BIT_X)) { |
22391e5d1bbf
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1314 |
if (rails & TRACK_BIT_LEFT) { |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1315 |
MAYBE_DRAW_SIGNAL(2, 0x509, 0, TRACK_LEFT); |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1316 |
MAYBE_DRAW_SIGNAL(3, 0x507, 1, TRACK_LEFT); |
3519
22391e5d1bbf
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1317 |
} |
22391e5d1bbf
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1318 |
if (rails & TRACK_BIT_RIGHT) { |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1319 |
MAYBE_DRAW_SIGNAL(0, 0x509, 2, TRACK_RIGHT); |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1320 |
MAYBE_DRAW_SIGNAL(1, 0x507, 3, TRACK_RIGHT); |
3519
22391e5d1bbf
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1321 |
} |
22391e5d1bbf
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1322 |
if (rails & TRACK_BIT_UPPER) { |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1323 |
MAYBE_DRAW_SIGNAL(3, 0x505, 4, TRACK_UPPER); |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1324 |
MAYBE_DRAW_SIGNAL(2, 0x503, 5, TRACK_UPPER); |
3519
22391e5d1bbf
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1325 |
} |
22391e5d1bbf
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1326 |
if (rails & TRACK_BIT_LOWER) { |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1327 |
MAYBE_DRAW_SIGNAL(1, 0x505, 6, TRACK_LOWER); |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1328 |
MAYBE_DRAW_SIGNAL(0, 0x503, 7, TRACK_LOWER); |
3519
22391e5d1bbf
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1329 |
} |
22391e5d1bbf
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1330 |
} else { |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1331 |
MAYBE_DRAW_SIGNAL(3, 0x4FB, 8, TRACK_X); |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1332 |
MAYBE_DRAW_SIGNAL(2, 0x4FD, 9, TRACK_X); |
3519
22391e5d1bbf
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1333 |
} |
22391e5d1bbf
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1334 |
} else { |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1335 |
MAYBE_DRAW_SIGNAL(3, 0x4FF, 10, TRACK_Y); |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1336 |
MAYBE_DRAW_SIGNAL(2, 0x501, 11, TRACK_Y); |
3519
22391e5d1bbf
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1337 |
} |
22391e5d1bbf
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1338 |
} |
22391e5d1bbf
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1339 |
|
0 | 1340 |
static void DrawTile_Track(TileInfo *ti) |
1341 |
{ |
|
2233
146e2e405ec1
(svn r2753) -Codechange: Introduced a new struct "RailtypeInfo" to store rail type specific information. Begun populating it with a bunch of sprites, more to come later. This should result in cleaner, more compact code which allows easy introduction of new railtypes.
celestar
parents:
2187
diff
changeset
|
1342 |
const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile)); |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1343 |
SpriteID image; |
0 | 1344 |
|
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1345 |
_drawtile_track_palette = PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)); |
0 | 1346 |
|
4182
20d711816338
(svn r5624) Use {IsPlainRailTile,IsRailDepot,IsRailWaypoint,HasSignals}() instead of GetRailTile{T,Subt}ype() - this is more concise and a bit more flexible if/when the rail tile encoding changes
tron
parents:
4180
diff
changeset
|
1347 |
if (IsPlainRailTile(ti->tile)) { |
3267
591027d10884
(svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents:
3265
diff
changeset
|
1348 |
TrackBits rails = GetTrackBits(ti->tile); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1349 |
|
4081 | 1350 |
DrawTrackBits(ti, rails); |
2008
c9d6585c96c8
(svn r2516) - Feature: [pbs] Implement path-based-signalling. This allows multiple trains within the same signal block, provided their paths dont intersect. For this the block must have all exit and entry signals be pbs signals. Place these by ctrl-clicking 4 times on a normal signal.
hackykid
parents:
2007
diff
changeset
|
1351 |
|
9911
0b8b245a2391
(svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents:
9909
diff
changeset
|
1352 |
if (HASBIT(_display_opt, DO_FULL_DETAIL)) DrawTrackDetails(ti); |
0 | 1353 |
|
4182
20d711816338
(svn r5624) Use {IsPlainRailTile,IsRailDepot,IsRailWaypoint,HasSignals}() instead of GetRailTile{T,Subt}ype() - this is more concise and a bit more flexible if/when the rail tile encoding changes
tron
parents:
4180
diff
changeset
|
1354 |
if (HasSignals(ti->tile)) DrawSignals(ti->tile, rails); |
0 | 1355 |
} else { |
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1356 |
/* draw depot/waypoint */ |
4225
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1357 |
const DrawTileSprites* dts; |
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1358 |
const DrawTileSeqStruct* dtss; |
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1359 |
uint32 relocation; |
0 | 1360 |
|
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
1361 |
if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh); |
0 | 1362 |
|
6498
aff910a05c6e
(svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents:
6486
diff
changeset
|
1363 |
if (IsRailDepot(ti->tile)) { |
4225
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1364 |
dts = &_depot_gfx_table[GetRailDepotDirection(ti->tile)]; |
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1365 |
|
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1366 |
relocation = rti->total_offset; |
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1367 |
|
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1368 |
image = dts->ground_sprite; |
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1369 |
if (image != SPR_FLAT_GRASS_TILE) image += rti->total_offset; |
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1370 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1371 |
/* adjust ground tile for desert |
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1372 |
* don't adjust for snow, because snow in depots looks weird */ |
9906
6f41b8713b65
(svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents:
9903
diff
changeset
|
1373 |
if (IsSnowRailGround(ti->tile) && _opt.landscape == LT_TROPIC) { |
4225
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1374 |
if (image != SPR_FLAT_GRASS_TILE) { |
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1375 |
image += rti->snow_offset; // tile with tracks |
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1376 |
} else { |
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1377 |
image = SPR_FLAT_SNOWY_TILE; // flat ground |
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1378 |
} |
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1379 |
} |
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1380 |
} else { |
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1381 |
/* look for customization */ |
2670
34970983ef08
(svn r3212) - Waypoints/Depots: Store waypoint index in m2 for waypoints. This moves the ground type bits from m2 to m4 for waypoints and depots (leaving room for depot index in m2 in future), and moves the custom graphics ID to the waypoint struct.
peter1138
parents:
2668
diff
changeset
|
1382 |
byte stat_id = GetWaypointByTile(ti->tile)->stat_id; |
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3671
diff
changeset
|
1383 |
const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, stat_id); |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
337
diff
changeset
|
1384 |
|
3676
48444d881fbe
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3671
diff
changeset
|
1385 |
if (statspec != NULL) { |
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1386 |
/* emulate station tile - open with building */ |
4225
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1387 |
const Station* st = ComposeWaypointStation(ti->tile); |
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1388 |
uint gfx = 2; |
3757
a0bba34a94ba
(svn r4748) - Newstations: use custom sprite layout callback for waypoints as well as stations. Supports merging of adjacent waypoints if the GRF supports it (newstatsw.grf)
peter1138
parents:
3751
diff
changeset
|
1389 |
|
a0bba34a94ba
(svn r4748) - Newstations: use custom sprite layout callback for waypoints as well as stations. Supports merging of adjacent waypoints if the GRF supports it (newstatsw.grf)
peter1138
parents:
3751
diff
changeset
|
1390 |
if (HASBIT(statspec->callbackmask, CBM_CUSTOM_LAYOUT)) { |
a0bba34a94ba
(svn r4748) - Newstations: use custom sprite layout callback for waypoints as well as stations. Supports merging of adjacent waypoints if the GRF supports it (newstatsw.grf)
peter1138
parents:
3751
diff
changeset
|
1391 |
uint16 callback = GetStationCallback(CBID_STATION_SPRITE_LAYOUT, 0, 0, statspec, st, ti->tile); |
4225
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1392 |
if (callback != CALLBACK_FAILED) gfx = callback; |
3757
a0bba34a94ba
(svn r4748) - Newstations: use custom sprite layout callback for waypoints as well as stations. Supports merging of adjacent waypoints if the GRF supports it (newstatsw.grf)
peter1138
parents:
3751
diff
changeset
|
1393 |
} |
a0bba34a94ba
(svn r4748) - Newstations: use custom sprite layout callback for waypoints as well as stations. Supports merging of adjacent waypoints if the GRF supports it (newstatsw.grf)
peter1138
parents:
3751
diff
changeset
|
1394 |
|
3763
460bbb4a8154
(svn r4754) - Newstations: expose default station display data via a function so we can use it (rarely) in other places.
peter1138
parents:
3757
diff
changeset
|
1395 |
if (statspec->renderdata == NULL) { |
4225
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1396 |
dts = GetStationTileLayout(gfx); |
3763
460bbb4a8154
(svn r4754) - Newstations: expose default station display data via a function so we can use it (rarely) in other places.
peter1138
parents:
3757
diff
changeset
|
1397 |
} else { |
4225
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1398 |
dts = &statspec->renderdata[(gfx < statspec->tiles ? gfx : 0) + GetWaypointAxis(ti->tile)]; |
3763
460bbb4a8154
(svn r4754) - Newstations: expose default station display data via a function so we can use it (rarely) in other places.
peter1138
parents:
3757
diff
changeset
|
1399 |
} |
447
aaf1f59a8957
(svn r657) Do not touch 0x8000 bit in sprite index for custom waypoints. (pasky)
celestar
parents:
438
diff
changeset
|
1400 |
|
4225
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1401 |
if (dts != NULL && dts->seq != NULL) { |
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1402 |
relocation = GetCustomStationRelocation(statspec, st, ti->tile); |
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1403 |
|
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1404 |
image = dts->ground_sprite; |
5989
88540735bad4
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5986
diff
changeset
|
1405 |
if (HASBIT(image, SPRITE_MODIFIER_USE_OFFSET)) { |
3775
f3f1ba3111fa
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3763
diff
changeset
|
1406 |
image += GetCustomStationGroundRelocation(statspec, st, ti->tile); |
f3f1ba3111fa
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3763
diff
changeset
|
1407 |
image += rti->custom_ground_offset; |
f3f1ba3111fa
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3763
diff
changeset
|
1408 |
} else { |
f3f1ba3111fa
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3763
diff
changeset
|
1409 |
image += rti->total_offset; |
f3f1ba3111fa
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3763
diff
changeset
|
1410 |
} |
4225
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1411 |
} else { |
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1412 |
goto default_waypoint; |
389
2d394eeba5e5
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
337
diff
changeset
|
1413 |
} |
2549 | 1414 |
} else { |
4225
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1415 |
default_waypoint: |
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1416 |
/* There is no custom layout, fall back to the default graphics */ |
4225
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1417 |
dts = &_waypoint_gfx_table[GetWaypointAxis(ti->tile)]; |
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1418 |
relocation = 0; |
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1419 |
image = dts->ground_sprite + rti->total_offset; |
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1420 |
if (IsSnowRailGround(ti->tile)) image += rti->snow_offset; |
2549 | 1421 |
} |
0 | 1422 |
} |
1423 |
||
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1424 |
DrawGroundSprite(image, PAL_NONE); |
0 | 1425 |
|
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3333
diff
changeset
|
1426 |
if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenary(ti); |
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3333
diff
changeset
|
1427 |
|
4225
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1428 |
foreach_draw_tile_seq(dtss, dts->seq) { |
5989
88540735bad4
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5986
diff
changeset
|
1429 |
SpriteID image = dtss->image; |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1430 |
SpriteID pal; |
4225
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1431 |
|
5989
88540735bad4
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5986
diff
changeset
|
1432 |
/* Unlike stations, our default waypoint has no variation for |
88540735bad4
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5986
diff
changeset
|
1433 |
* different railtype, so don't use the railtype offset if |
88540735bad4
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5986
diff
changeset
|
1434 |
* no relocation is set */ |
88540735bad4
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5986
diff
changeset
|
1435 |
if (HASBIT(image, SPRITE_MODIFIER_USE_OFFSET)) { |
88540735bad4
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5986
diff
changeset
|
1436 |
image += rti->total_offset; |
88540735bad4
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5986
diff
changeset
|
1437 |
} else { |
88540735bad4
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5986
diff
changeset
|
1438 |
image += relocation; |
88540735bad4
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5986
diff
changeset
|
1439 |
} |
88540735bad4
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5986
diff
changeset
|
1440 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1441 |
if (HASBIT(_transparent_opt, TO_BUILDINGS)) { |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1442 |
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT); |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1443 |
pal = PALETTE_TO_TRANSPARENT; |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1444 |
} else if (HASBIT(image, PALETTE_MODIFIER_COLOR)) { |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1445 |
pal = _drawtile_track_palette; |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1446 |
} else { |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1447 |
pal = dtss->pal; |
4225
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1448 |
} |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1449 |
|
5989
88540735bad4
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5986
diff
changeset
|
1450 |
if ((byte)dtss->delta_z != 0x80) { |
88540735bad4
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5986
diff
changeset
|
1451 |
AddSortableSpriteToDraw( |
88540735bad4
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5986
diff
changeset
|
1452 |
image, pal, |
88540735bad4
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5986
diff
changeset
|
1453 |
ti->x + dtss->delta_x, ti->y + dtss->delta_y, |
88540735bad4
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5986
diff
changeset
|
1454 |
dtss->size_x, dtss->size_y, |
88540735bad4
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5986
diff
changeset
|
1455 |
dtss->size_z, ti->z + dtss->delta_z |
88540735bad4
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5986
diff
changeset
|
1456 |
); |
88540735bad4
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5986
diff
changeset
|
1457 |
} else { |
88540735bad4
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5986
diff
changeset
|
1458 |
AddChildSpriteScreen(image, pal, dtss->delta_x, dtss->delta_y); |
88540735bad4
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5986
diff
changeset
|
1459 |
} |
0 | 1460 |
} |
1461 |
} |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1462 |
DrawBridgeMiddle(ti); |
0 | 1463 |
} |
1464 |
||
1465 |
||
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1466 |
static void DrawTileSequence(int x, int y, SpriteID ground, const DrawTileSeqStruct* dtss, uint32 offset) |
4225
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1467 |
{ |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1468 |
SpriteID palette = PLAYER_SPRITE_COLOR(_local_player); |
0 | 1469 |
|
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1470 |
DrawSprite(ground, PAL_NONE, x, y); |
4225
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1471 |
for (; dtss->image != 0; dtss++) { |
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1472 |
Point pt = RemapCoords(dtss->delta_x, dtss->delta_y, dtss->delta_z); |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1473 |
SpriteID image = dtss->image + offset; |
0 | 1474 |
|
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1475 |
DrawSprite(image, HASBIT(image, PALETTE_MODIFIER_COLOR) ? palette : PAL_NONE, x + pt.x, y + pt.y); |
0 | 1476 |
} |
1477 |
} |
|
1478 |
||
4225
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1479 |
void DrawTrainDepotSprite(int x, int y, int dir, RailType railtype) |
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1480 |
{ |
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1481 |
const DrawTileSprites* dts = &_depot_gfx_table[dir]; |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5849
diff
changeset
|
1482 |
SpriteID image = dts->ground_sprite; |
4225
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1483 |
uint32 offset = GetRailTypeInfo(railtype)->total_offset; |
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1484 |
|
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1485 |
if (image != SPR_FLAT_GRASS_TILE) image += offset; |
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1486 |
DrawTileSequence(x + 33, y + 17, image, dts->seq, offset); |
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1487 |
} |
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1488 |
|
2520
75eb66d6e371
(svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents:
2502
diff
changeset
|
1489 |
void DrawDefaultWaypointSprite(int x, int y, RailType railtype) |
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2254
diff
changeset
|
1490 |
{ |
4225
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1491 |
uint32 offset = GetRailTypeInfo(railtype)->total_offset; |
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1492 |
const DrawTileSprites* dts = &_waypoint_gfx_table[AXIS_X]; |
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2254
diff
changeset
|
1493 |
|
4225
a14f76451e03
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1494 |
DrawTileSequence(x, y, dts->ground_sprite + offset, dts->seq, 0); |
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2254
diff
changeset
|
1495 |
} |
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2254
diff
changeset
|
1496 |
|
9895
7bd07f43b0e3
(svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents:
6513
diff
changeset
|
1497 |
struct SetSignalsData { |
0 | 1498 |
int cur; |
1499 |
int cur_stack; |
|
1500 |
bool stop; |
|
1501 |
bool has_presignal; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1502 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1503 |
/* presignal info */ |
0 | 1504 |
int presignal_exits; |
1505 |
int presignal_exits_free; |
|
1506 |
||
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1507 |
/* these are used to keep track of the signals that change. */ |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1508 |
TrackdirByte bit[NUM_SSD_ENTRY]; |
0 | 1509 |
TileIndex tile[NUM_SSD_ENTRY]; |
1510 |
||
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1511 |
/* these are used to keep track of the stack that modifies presignals recursively */ |
0 | 1512 |
TileIndex next_tile[NUM_SSD_STACK]; |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1513 |
DiagDirectionByte next_dir[NUM_SSD_STACK]; |
0 | 1514 |
|
9895
7bd07f43b0e3
(svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents:
6513
diff
changeset
|
1515 |
}; |
0 | 1516 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1517 |
static bool SetSignalsEnumProc(TileIndex tile, void* data, Trackdir trackdir, uint length, byte* state) |
0 | 1518 |
{ |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1519 |
SetSignalsData* ssd = (SetSignalsData*)data; |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1520 |
Track track = TrackdirToTrack(trackdir); |
4479 | 1521 |
|
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
|
1522 |
if (!IsTileType(tile, MP_RAILWAY)) return false; |
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
|
1523 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1524 |
/* the tile has signals? */ |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1525 |
if (HasSignalOnTrack(tile, track)) { |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1526 |
if (HasSignalOnTrackdir(tile, ReverseTrackdir(trackdir))) { |
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1527 |
/* yes, add the signal to the list of signals */ |
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
|
1528 |
if (ssd->cur != NUM_SSD_ENTRY) { |
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
|
1529 |
ssd->tile[ssd->cur] = tile; // remember the tile index |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1530 |
ssd->bit[ssd->cur] = trackdir; // and the controlling bit number |
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
|
1531 |
ssd->cur++; |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
1532 |
} |
0 | 1533 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1534 |
/* remember if this block has a presignal. */ |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1535 |
ssd->has_presignal |= IsPresignalEntry(tile, track); |
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
|
1536 |
} |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
1537 |
|
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1538 |
if (HasSignalOnTrackdir(tile, trackdir) && IsPresignalExit(tile, track)) { |
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1539 |
/* this is an exit signal that points out from the segment */ |
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
|
1540 |
ssd->presignal_exits++; |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1541 |
if (GetSignalStateByTrackdir(tile, trackdir) != SIGNAL_STATE_RED) |
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
|
1542 |
ssd->presignal_exits_free++; |
2549 | 1543 |
} |
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
|
1544 |
|
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
|
1545 |
return true; |
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
|
1546 |
} else if (IsTileDepotType(tile, TRANSPORT_RAIL)) { |
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
|
1547 |
return true; // don't look further if the tile is a depot |
0 | 1548 |
} |
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
|
1549 |
|
0 | 1550 |
return false; |
1551 |
} |
|
1552 |
||
1555
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1553 |
/* Struct to parse data from VehicleFromPos to SignalVehicleCheckProc */ |
9895
7bd07f43b0e3
(svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents:
6513
diff
changeset
|
1554 |
struct SignalVehicleCheckStruct { |
1555
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1555 |
TileIndex tile; |
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1556 |
uint track; |
9895
7bd07f43b0e3
(svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents:
6513
diff
changeset
|
1557 |
}; |
1555
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1558 |
|
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1559 |
static void *SignalVehicleCheckProc(Vehicle *v, void *data) |
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1560 |
{ |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1561 |
const SignalVehicleCheckStruct* dest = (SignalVehicleCheckStruct*)data; |
1555
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1562 |
|
9895
7bd07f43b0e3
(svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents:
6513
diff
changeset
|
1563 |
if (v->type != VEH_TRAIN) return NULL; |
1609
b4d11170cbb5
(svn r2113) -Fix: first check if a vehicle is a train, before accessing u.rail
truelight
parents:
1598
diff
changeset
|
1564 |
|
1555
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1565 |
/* Wrong tile, or no train? Not a match */ |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1566 |
if (v->tile != dest->tile) return NULL; |
1555
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1567 |
|
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1568 |
/* Are we on the same piece of track? */ |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
1569 |
if (dest->track & v->u.rail.track * 0x101) return v; |
1555
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1570 |
|
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1571 |
return NULL; |
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1572 |
} |
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1573 |
|
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1574 |
/* Special check for SetSignalsAfterProc, to see if there is a vehicle on this tile */ |
2752 | 1575 |
static bool SignalVehicleCheck(TileIndex tile, uint track) |
1555
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1576 |
{ |
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1577 |
SignalVehicleCheckStruct dest; |
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1578 |
|
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1579 |
dest.tile = tile; |
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1580 |
dest.track = track; |
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1581 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1582 |
/* Locate vehicles in tunnels or on bridges */ |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1583 |
if (IsTunnelTile(tile) || IsBridgeTile(tile)) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1584 |
TileIndex end; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1585 |
DiagDirection direction; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1586 |
|
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1587 |
if (IsTunnelTile(tile)) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1588 |
end = GetOtherTunnelEnd(tile); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1589 |
direction = GetTunnelDirection(tile); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1590 |
} else { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1591 |
end = GetOtherBridgeEnd(tile); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1592 |
direction = GetBridgeRampDirection(tile); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1593 |
} |
3154 | 1594 |
|
1816
e96c4a8136bf
(svn r2320) - Fix: [ 1185176 ] Train in tunnel is not properly detected by signal code (Hackykid)
matthijs
parents:
1813
diff
changeset
|
1595 |
dest.track = 1 << (direction & 1); // get the trackbit the vehicle would have if it has not entered the tunnel yet (ie is still visible) |
e96c4a8136bf
(svn r2320) - Fix: [ 1185176 ] Train in tunnel is not properly detected by signal code (Hackykid)
matthijs
parents:
1813
diff
changeset
|
1596 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1597 |
/* check for a vehicle with that trackdir on the start tile of the tunnel */ |
1818
88ab405a9dfc
(svn r2322) - CodeChange: doxygen commented the tunnel-crash fix. Also if (bla) {return;} else {return;} is not proper code. It's if (bla) {return;} return; ;)
Darkvater
parents:
1816
diff
changeset
|
1598 |
if (VehicleFromPos(tile, &dest, SignalVehicleCheckProc) != NULL) return true; |
1816
e96c4a8136bf
(svn r2320) - Fix: [ 1185176 ] Train in tunnel is not properly detected by signal code (Hackykid)
matthijs
parents:
1813
diff
changeset
|
1599 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1600 |
/* check for a vehicle with that trackdir on the end tile of the tunnel */ |
3154 | 1601 |
if (VehicleFromPos(end, &dest, SignalVehicleCheckProc) != NULL) return true; |
1816
e96c4a8136bf
(svn r2320) - Fix: [ 1185176 ] Train in tunnel is not properly detected by signal code (Hackykid)
matthijs
parents:
1813
diff
changeset
|
1602 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1603 |
/* now check all tiles from start to end for a warping vehicle |
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1604 |
* NOTE: the hashes for tiles may overlap, so this could maybe be optimised a bit by not checking every tile? */ |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5568
diff
changeset
|
1605 |
dest.track = 0x40; //Vehicle inside a tunnel or on a bridge |
4559
c853d2440065
(svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents:
4556
diff
changeset
|
1606 |
for (; tile != end; tile += TileOffsByDiagDir(direction)) { |
1816
e96c4a8136bf
(svn r2320) - Fix: [ 1185176 ] Train in tunnel is not properly detected by signal code (Hackykid)
matthijs
parents:
1813
diff
changeset
|
1607 |
if (VehicleFromPos(tile, &dest, SignalVehicleCheckProc) != NULL) |
e96c4a8136bf
(svn r2320) - Fix: [ 1185176 ] Train in tunnel is not properly detected by signal code (Hackykid)
matthijs
parents:
1813
diff
changeset
|
1608 |
return true; |
e96c4a8136bf
(svn r2320) - Fix: [ 1185176 ] Train in tunnel is not properly detected by signal code (Hackykid)
matthijs
parents:
1813
diff
changeset
|
1609 |
} |
e96c4a8136bf
(svn r2320) - Fix: [ 1185176 ] Train in tunnel is not properly detected by signal code (Hackykid)
matthijs
parents:
1813
diff
changeset
|
1610 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1611 |
/* no vehicle found */ |
1816
e96c4a8136bf
(svn r2320) - Fix: [ 1185176 ] Train in tunnel is not properly detected by signal code (Hackykid)
matthijs
parents:
1813
diff
changeset
|
1612 |
return false; |
1818
88ab405a9dfc
(svn r2322) - CodeChange: doxygen commented the tunnel-crash fix. Also if (bla) {return;} else {return;} is not proper code. It's if (bla) {return;} return; ;)
Darkvater
parents:
1816
diff
changeset
|
1613 |
} |
88ab405a9dfc
(svn r2322) - CodeChange: doxygen commented the tunnel-crash fix. Also if (bla) {return;} else {return;} is not proper code. It's if (bla) {return;} return; ;)
Darkvater
parents:
1816
diff
changeset
|
1614 |
|
88ab405a9dfc
(svn r2322) - CodeChange: doxygen commented the tunnel-crash fix. Also if (bla) {return;} else {return;} is not proper code. It's if (bla) {return;} return; ;)
Darkvater
parents:
1816
diff
changeset
|
1615 |
return VehicleFromPos(tile, &dest, SignalVehicleCheckProc) != NULL; |
1555
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1616 |
} |
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1617 |
|
0 | 1618 |
static void SetSignalsAfterProc(TrackPathFinder *tpf) |
1619 |
{ |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1620 |
SetSignalsData *ssd = (SetSignalsData*)tpf->userdata; |
2548
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2544
diff
changeset
|
1621 |
const TrackPathFinderLink* link; |
1555
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1622 |
uint offs; |
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1623 |
uint i; |
0 | 1624 |
|
1625 |
ssd->stop = false; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1626 |
|
1555
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1627 |
/* Go through all the PF tiles */ |
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1628 |
for (i = 0; i < lengthof(tpf->hash_head); i++) { |
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1629 |
/* Empty hash item */ |
2639 | 1630 |
if (tpf->hash_head[i] == 0) continue; |
0 | 1631 |
|
1555
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1632 |
/* If 0x8000 is not set, there is only 1 item */ |
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1633 |
if (!(tpf->hash_head[i] & 0x8000)) { |
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1634 |
/* Check if there is a vehicle on this tile */ |
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1635 |
if (SignalVehicleCheck(tpf->hash_tile[i], tpf->hash_head[i])) { |
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1636 |
ssd->stop = true; |
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1637 |
return; |
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1638 |
} |
0 | 1639 |
} else { |
1555
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1640 |
/* There are multiple items, where hash_tile points to the first item in the list */ |
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1641 |
offs = tpf->hash_tile[i]; |
0 | 1642 |
do { |
1555
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1643 |
/* Find the next item */ |
0 | 1644 |
link = PATHFIND_GET_LINK_PTR(tpf, offs); |
1555
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1645 |
/* Check if there is a vehicle on this tile */ |
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1646 |
if (SignalVehicleCheck(link->tile, link->flags)) { |
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1647 |
ssd->stop = true; |
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1648 |
return; |
0 | 1649 |
} |
1555
c7e5bb32f536
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1650 |
/* Goto the next item */ |
2951 | 1651 |
} while ((offs = link->next) != 0xFFFF); |
0 | 1652 |
} |
1653 |
} |
|
1654 |
} |
|
1655 |
||
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1656 |
static const DiagDirection _dir_from_track[14] = { |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1657 |
DIAGDIR_NE, DIAGDIR_SE, DIAGDIR_NE, DIAGDIR_SE, DIAGDIR_SW, DIAGDIR_SE, DIAGDIR_NE, DIAGDIR_NE, |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
1658 |
DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_NW, DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_NE, |
0 | 1659 |
}; |
1660 |
||
1661 |
||
1662 |
static void ChangeSignalStates(SetSignalsData *ssd) |
|
1663 |
{ |
|
1664 |
int i; |
|
1665 |
||
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1666 |
/* thinking about presignals... |
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1667 |
* the presignal is green if, |
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1668 |
* if no train is in the segment AND |
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1669 |
* there is at least one green exit signal OR |
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1670 |
* there are no exit signals in the segment */ |
0 | 1671 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1672 |
/* then mark the signals in the segment accordingly */ |
2549 | 1673 |
for (i = 0; i != ssd->cur; i++) { |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1963
diff
changeset
|
1674 |
TileIndex tile = ssd->tile[i]; |
2821
ba75b5f98725
(svn r3369) - Codechange: Replace tables _signals_table, _signals_table_other and _signals_table_both by the equivalent calls to rail.h functions.
matthijs
parents:
2817
diff
changeset
|
1675 |
byte bit = SignalAgainstTrackdir(ssd->bit[i]); |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1676 |
uint signals = GetSignalStates(tile); |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1677 |
Track track = TrackdirToTrack(ssd->bit[i]); |
0 | 1678 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1679 |
/* presignals don't turn green if there is at least one presignal exit and none are free */ |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1680 |
if (IsPresignalEntry(tile, track)) { |
0 | 1681 |
int ex = ssd->presignal_exits, exfree = ssd->presignal_exits_free; |
1682 |
||
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1683 |
/* subtract for dual combo signals so they don't count themselves */ |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1684 |
if (IsPresignalExit(tile, track) && HasSignalOnTrackdir(tile, ssd->bit[i])) { |
0 | 1685 |
ex--; |
3520
092efede26b3
(svn r4376) -Codechange Renamed GetSignalState to GetSignalStateByTrackdir
celestar
parents:
3519
diff
changeset
|
1686 |
if (GetSignalStateByTrackdir(tile, ssd->bit[i]) != SIGNAL_STATE_RED) exfree--; |
0 | 1687 |
} |
1688 |
||
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1689 |
/* if we have exits and none are free, make red. */ |
0 | 1690 |
if (ex && !exfree) goto make_red; |
1691 |
} |
|
1692 |
||
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1693 |
/* check if the signal is unaffected. */ |
0 | 1694 |
if (ssd->stop) { |
1695 |
make_red: |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1696 |
/* turn red */ |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1697 |
if ((bit & signals) == 0) continue; |
0 | 1698 |
} else { |
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1699 |
/* turn green */ |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1700 |
if ((bit & signals) != 0) continue; |
0 | 1701 |
} |
1702 |
||
1813
a4b17980b9e4
(svn r2317) - Fix: [ 1193048 ] Pre-signal stays red when there is only a single exit signal (dinno)
Darkvater
parents:
1796
diff
changeset
|
1703 |
/* Update signals on the other side of this exit-combo signal; it changed. */ |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1704 |
if (IsPresignalExit(tile, track)) { |
0 | 1705 |
if (ssd->cur_stack != NUM_SSD_STACK) { |
1706 |
ssd->next_tile[ssd->cur_stack] = tile; |
|
1707 |
ssd->next_dir[ssd->cur_stack] = _dir_from_track[ssd->bit[i]]; |
|
1708 |
ssd->cur_stack++; |
|
1709 |
} else { |
|
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5198
diff
changeset
|
1710 |
DEBUG(misc, 0, "NUM_SSD_STACK too small"); /// @todo WTF is this??? |
0 | 1711 |
} |
1712 |
} |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1713 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1714 |
/* it changed, so toggle it */ |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1715 |
SetSignalStates(tile, signals ^ bit); |
0 | 1716 |
MarkTileDirtyByTile(tile); |
1717 |
} |
|
1718 |
} |
|
1719 |
||
1720 |
||
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
|
1721 |
bool UpdateSignalsOnSegment(TileIndex tile, DiagDirection direction) |
0 | 1722 |
{ |
1723 |
SetSignalsData ssd; |
|
1724 |
int result = -1; |
|
1725 |
||
1726 |
ssd.cur_stack = 0; |
|
1727 |
||
2951 | 1728 |
for (;;) { |
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1729 |
/* go through one segment and update all signals pointing into that segment. */ |
2916
8f1aa489701f
(svn r3472) - [PBS] Remove from trunk. Anyone interested can still find it in branch/pbs. This reverts revisions r3158, r3140, r3075, r2977, r2674, r2625, r2621, r2529, r2528, r2525, r2524, r2519, r2517, r2516, r2507, r2499. (in conjunction with Tron)
Darkvater
parents:
2911
diff
changeset
|
1730 |
ssd.cur = ssd.presignal_exits = ssd.presignal_exits_free = 0; |
0 | 1731 |
ssd.has_presignal = false; |
1732 |
||
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1733 |
FollowTrack(tile, 0xC000 | TRANSPORT_RAIL, 0, direction, SetSignalsEnumProc, SetSignalsAfterProc, &ssd); |
0 | 1734 |
ChangeSignalStates(&ssd); |
1735 |
||
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1736 |
/* remember the result only for the first iteration. */ |
3900
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
1737 |
if (result < 0) { |
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1738 |
/* stay in depot while segment is occupied or while all presignal exits are blocked */ |
3900
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
1739 |
result = ssd.stop || (ssd.presignal_exits > 0 && ssd.presignal_exits_free == 0); |
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
1740 |
} |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1741 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1742 |
/* if any exit signals were changed, we need to keep going to modify the stuff behind those. */ |
2639 | 1743 |
if (ssd.cur_stack == 0) break; |
0 | 1744 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1745 |
/* one or more exit signals were changed, so we need to update another segment too. */ |
0 | 1746 |
tile = ssd.next_tile[--ssd.cur_stack]; |
1747 |
direction = ssd.next_dir[ssd.cur_stack]; |
|
1748 |
} |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1749 |
|
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
|
1750 |
return result != 0; |
0 | 1751 |
} |
1752 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1963
diff
changeset
|
1753 |
void SetSignalsOnBothDir(TileIndex tile, byte track) |
0 | 1754 |
{ |
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
|
1755 |
static const DiagDirection _search_dir_1[] = { |
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
|
1756 |
DIAGDIR_NE, DIAGDIR_SE, DIAGDIR_NE, DIAGDIR_SE, DIAGDIR_SW, DIAGDIR_SE |
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
|
1757 |
}; |
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
|
1758 |
static const DiagDirection _search_dir_2[] = { |
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
|
1759 |
DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_NW, DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_NE |
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
|
1760 |
}; |
0 | 1761 |
|
1762 |
UpdateSignalsOnSegment(tile, _search_dir_1[track]); |
|
1763 |
UpdateSignalsOnSegment(tile, _search_dir_2[track]); |
|
1764 |
} |
|
1765 |
||
4231
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4230
diff
changeset
|
1766 |
static uint GetSlopeZ_Track(TileIndex tile, uint x, uint y) |
0 | 1767 |
{ |
4231
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4230
diff
changeset
|
1768 |
uint z; |
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4230
diff
changeset
|
1769 |
Slope tileh = GetTileSlope(tile, &z); |
2951 | 1770 |
|
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
1771 |
if (tileh == SLOPE_FLAT) return z; |
4231
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4230
diff
changeset
|
1772 |
if (IsPlainRailTile(tile)) { |
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4230
diff
changeset
|
1773 |
uint f = GetRailFoundation(tileh, GetTrackBits(tile)); |
3286
3250f1488eb2
(svn r4000) Rewrite GetSlope{Tileh,Z}_{Road,Track} in a less confusing way
tron
parents:
3284
diff
changeset
|
1774 |
|
3250f1488eb2
(svn r4000) Rewrite GetSlope{Tileh,Z}_{Road,Track} in a less confusing way
tron
parents:
3284
diff
changeset
|
1775 |
if (f != 0) { |
4246
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
1776 |
if (IsSteepSlope(tileh)) { |
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
1777 |
z += TILE_HEIGHT; |
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
1778 |
} else if (f < 15) { |
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
1779 |
return z + TILE_HEIGHT; // leveled foundation |
14a8849c32df
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
1780 |
} |
3286
3250f1488eb2
(svn r4000) Rewrite GetSlope{Tileh,Z}_{Road,Track} in a less confusing way
tron
parents:
3284
diff
changeset
|
1781 |
tileh = _inclined_tileh[f - 15]; // inclined foundation |
0 | 1782 |
} |
4231
dea6a63dd058
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4230
diff
changeset
|
1783 |
return z + GetPartialZ(x & 0xF, y & 0xF, tileh); |
4182
20d711816338
(svn r5624) Use {IsPlainRailTile,IsRailDepot,IsRailWaypoint,HasSignals}() instead of GetRailTile{T,Subt}ype() - this is more concise and a bit more flexible if/when the rail tile encoding changes
tron
parents:
4180
diff
changeset
|
1784 |
} else { |
20d711816338
(svn r5624) Use {IsPlainRailTile,IsRailDepot,IsRailWaypoint,HasSignals}() instead of GetRailTile{T,Subt}ype() - this is more concise and a bit more flexible if/when the rail tile encoding changes
tron
parents:
4180
diff
changeset
|
1785 |
return z + TILE_HEIGHT; |
0 | 1786 |
} |
1787 |
} |
|
1788 |
||
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
1789 |
static Slope GetSlopeTileh_Track(TileIndex tile, Slope tileh) |
39 | 1790 |
{ |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
1791 |
if (tileh == SLOPE_FLAT) return SLOPE_FLAT; |
4182
20d711816338
(svn r5624) Use {IsPlainRailTile,IsRailDepot,IsRailWaypoint,HasSignals}() instead of GetRailTile{T,Subt}ype() - this is more concise and a bit more flexible if/when the rail tile encoding changes
tron
parents:
4180
diff
changeset
|
1792 |
if (IsPlainRailTile(tile)) { |
3418
a592d40a4d04
(svn r4242) Pass TileIndex and slope to GetSlopeTileh_*() instead of TileInfo
tron
parents:
3379
diff
changeset
|
1793 |
uint f = GetRailFoundation(tileh, GetTrackBits(tile)); |
3286
3250f1488eb2
(svn r4000) Rewrite GetSlope{Tileh,Z}_{Road,Track} in a less confusing way
tron
parents:
3284
diff
changeset
|
1794 |
|
3418
a592d40a4d04
(svn r4242) Pass TileIndex and slope to GetSlopeTileh_*() instead of TileInfo
tron
parents:
3379
diff
changeset
|
1795 |
if (f == 0) return tileh; |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
1796 |
if (f < 15) return SLOPE_FLAT; // leveled foundation |
3286
3250f1488eb2
(svn r4000) Rewrite GetSlope{Tileh,Z}_{Road,Track} in a less confusing way
tron
parents:
3284
diff
changeset
|
1797 |
return _inclined_tileh[f - 15]; // inclined foundation |
4182
20d711816338
(svn r5624) Use {IsPlainRailTile,IsRailDepot,IsRailWaypoint,HasSignals}() instead of GetRailTile{T,Subt}ype() - this is more concise and a bit more flexible if/when the rail tile encoding changes
tron
parents:
4180
diff
changeset
|
1798 |
} else { |
20d711816338
(svn r5624) Use {IsPlainRailTile,IsRailDepot,IsRailWaypoint,HasSignals}() instead of GetRailTile{T,Subt}ype() - this is more concise and a bit more flexible if/when the rail tile encoding changes
tron
parents:
4180
diff
changeset
|
1799 |
return SLOPE_FLAT; |
39 | 1800 |
} |
1801 |
} |
|
1802 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1963
diff
changeset
|
1803 |
static void GetAcceptedCargo_Track(TileIndex tile, AcceptedCargo ac) |
0 | 1804 |
{ |
1805 |
/* not used */ |
|
1806 |
} |
|
1807 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1963
diff
changeset
|
1808 |
static void AnimateTile_Track(TileIndex tile) |
0 | 1809 |
{ |
1810 |
/* not used */ |
|
1811 |
} |
|
1812 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1963
diff
changeset
|
1813 |
static void TileLoop_Track(TileIndex tile) |
0 | 1814 |
{ |
3523
168ee460418b
(svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents:
3522
diff
changeset
|
1815 |
RailGroundType old_ground = GetRailGroundType(tile); |
4483
939db99bddb9
(svn r6268) Remove now pointless assignment (followup of r6267)
tron
parents:
4482
diff
changeset
|
1816 |
RailGroundType new_ground; |
0 | 1817 |
|
2631
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2626
diff
changeset
|
1818 |
switch (_opt.landscape) { |
9906
6f41b8713b65
(svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents:
9903
diff
changeset
|
1819 |
case LT_ARCTIC: |
6f41b8713b65
(svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents:
9903
diff
changeset
|
1820 |
if (GetTileZ(tile) > GetSnowLine()) { |
3562
c308f20e8388
(svn r4440) - Fix: Yoyo-effect of rail in desert/snow introduced by r4379. When a special groundtype below the track is encountered in the tileloop, always return even if groundtype hasn't changed.
Darkvater
parents:
3549
diff
changeset
|
1821 |
new_ground = RAIL_GROUND_ICE_DESERT; |
4482
4532293483d6
(svn r6267) Simplify the control flow in the rail tile loop by eliminating a bool flag and replacing it by a simple goto
tron
parents:
4479
diff
changeset
|
1822 |
goto set_ground; |
3562
c308f20e8388
(svn r4440) - Fix: Yoyo-effect of rail in desert/snow introduced by r4379. When a special groundtype below the track is encountered in the tileloop, always return even if groundtype hasn't changed.
Darkvater
parents:
3549
diff
changeset
|
1823 |
} |
2631
13daba67f217
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2626
diff
changeset
|
1824 |
break; |
0 | 1825 |
|
9906
6f41b8713b65
(svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents:
9903
diff
changeset
|
1826 |
case LT_TROPIC: |
3562
c308f20e8388
(svn r4440) - Fix: Yoyo-effect of rail in desert/snow introduced by r4379. When a special groundtype below the track is encountered in the tileloop, always return even if groundtype hasn't changed.
Darkvater
parents:
3549
diff
changeset
|
1827 |
if (GetTropicZone(tile) == TROPICZONE_DESERT) { |
c308f20e8388
(svn r4440) - Fix: Yoyo-effect of rail in desert/snow introduced by r4379. When a special groundtype below the track is encountered in the tileloop, always return even if groundtype hasn't changed.
Darkvater
parents:
3549
diff
changeset
|
1828 |
new_ground = RAIL_GROUND_ICE_DESERT; |
4482
4532293483d6
(svn r6267) Simplify the control flow in the rail tile loop by eliminating a bool flag and replacing it by a simple goto
tron
parents:
4479
diff
changeset
|
1829 |
goto set_ground; |
3562
c308f20e8388
(svn r4440) - Fix: Yoyo-effect of rail in desert/snow introduced by r4379. When a special groundtype below the track is encountered in the tileloop, always return even if groundtype hasn't changed.
Darkvater
parents:
3549
diff
changeset
|
1830 |
} |
3523
168ee460418b
(svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents:
3522
diff
changeset
|
1831 |
break; |
168ee460418b
(svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents:
3522
diff
changeset
|
1832 |
} |
168ee460418b
(svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents:
3522
diff
changeset
|
1833 |
|
4182
20d711816338
(svn r5624) Use {IsPlainRailTile,IsRailDepot,IsRailWaypoint,HasSignals}() instead of GetRailTile{T,Subt}ype() - this is more concise and a bit more flexible if/when the rail tile encoding changes
tron
parents:
4180
diff
changeset
|
1834 |
if (!IsPlainRailTile(tile)) return; |
0 | 1835 |
|
3523
168ee460418b
(svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents:
3522
diff
changeset
|
1836 |
new_ground = RAIL_GROUND_GRASS; |
0 | 1837 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
1838 |
if (old_ground != RAIL_GROUND_BARREN) { // wait until bottom is green |
0 | 1839 |
/* determine direction of fence */ |
3267
591027d10884
(svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents:
3265
diff
changeset
|
1840 |
TrackBits rail = GetTrackBits(tile); |
0 | 1841 |
|
2839
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1842 |
switch (rail) { |
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1843 |
case TRACK_BIT_UPPER: new_ground = RAIL_GROUND_FENCE_HORIZ1; break; |
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1844 |
case TRACK_BIT_LOWER: new_ground = RAIL_GROUND_FENCE_HORIZ2; break; |
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1845 |
case TRACK_BIT_LEFT: new_ground = RAIL_GROUND_FENCE_VERT1; break; |
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1846 |
case TRACK_BIT_RIGHT: new_ground = RAIL_GROUND_FENCE_VERT2; break; |
0 | 1847 |
|
2839
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1848 |
default: { |
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1849 |
PlayerID owner = GetTileOwner(tile); |
0 | 1850 |
|
2839
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1851 |
if (rail == (TRACK_BIT_LOWER | TRACK_BIT_RIGHT) || ( |
3258
94a915e7485f
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
1852 |
(rail & TRACK_BIT_3WAY_NW) == 0 && |
3102
fde95020fc8e
(svn r3697) Rename DIAG1/DIAG2 to X resp. Y as this conveys a bit better in which direction a pieces of rail goes
tron
parents:
3101
diff
changeset
|
1853 |
(rail & TRACK_BIT_X) |
2839
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1854 |
)) { |
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1855 |
TileIndex n = tile + TileDiffXY(0, -1); |
3524
be2b44204623
(svn r4380) -Codechange: Make use of GetTrackBits where appropriate
celestar
parents:
3523
diff
changeset
|
1856 |
TrackBits nrail = GetTrackBits(n); |
0 | 1857 |
|
2839
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1858 |
if (!IsTileType(n, MP_RAILWAY) || |
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1859 |
!IsTileOwner(n, owner) || |
3524
be2b44204623
(svn r4380) -Codechange: Make use of GetTrackBits where appropriate
celestar
parents:
3523
diff
changeset
|
1860 |
nrail == TRACK_BIT_UPPER || |
be2b44204623
(svn r4380) -Codechange: Make use of GetTrackBits where appropriate
celestar
parents:
3523
diff
changeset
|
1861 |
nrail == TRACK_BIT_LEFT) { |
2839
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1862 |
new_ground = RAIL_GROUND_FENCE_NW; |
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1863 |
} |
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1864 |
} |
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1865 |
|
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1866 |
if (rail == (TRACK_BIT_UPPER | TRACK_BIT_LEFT) || ( |
3258
94a915e7485f
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
1867 |
(rail & TRACK_BIT_3WAY_SE) == 0 && |
3102
fde95020fc8e
(svn r3697) Rename DIAG1/DIAG2 to X resp. Y as this conveys a bit better in which direction a pieces of rail goes
tron
parents:
3101
diff
changeset
|
1868 |
(rail & TRACK_BIT_X) |
2839
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1869 |
)) { |
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1870 |
TileIndex n = tile + TileDiffXY(0, 1); |
3524
be2b44204623
(svn r4380) -Codechange: Make use of GetTrackBits where appropriate
celestar
parents:
3523
diff
changeset
|
1871 |
TrackBits nrail = GetTrackBits(n); |
2839
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1872 |
|
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1873 |
if (!IsTileType(n, MP_RAILWAY) || |
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1874 |
!IsTileOwner(n, owner) || |
3524
be2b44204623
(svn r4380) -Codechange: Make use of GetTrackBits where appropriate
celestar
parents:
3523
diff
changeset
|
1875 |
nrail == TRACK_BIT_LOWER || |
be2b44204623
(svn r4380) -Codechange: Make use of GetTrackBits where appropriate
celestar
parents:
3523
diff
changeset
|
1876 |
nrail == TRACK_BIT_RIGHT) { |
2839
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1877 |
new_ground = (new_ground == RAIL_GROUND_FENCE_NW) ? |
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1878 |
RAIL_GROUND_FENCE_SENW : RAIL_GROUND_FENCE_SE; |
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1879 |
} |
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1880 |
} |
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1881 |
|
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1882 |
if (rail == (TRACK_BIT_LOWER | TRACK_BIT_LEFT) || ( |
3258
94a915e7485f
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
1883 |
(rail & TRACK_BIT_3WAY_NE) == 0 && |
3102
fde95020fc8e
(svn r3697) Rename DIAG1/DIAG2 to X resp. Y as this conveys a bit better in which direction a pieces of rail goes
tron
parents:
3101
diff
changeset
|
1884 |
(rail & TRACK_BIT_Y) |
2839
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1885 |
)) { |
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1886 |
TileIndex n = tile + TileDiffXY(-1, 0); |
3524
be2b44204623
(svn r4380) -Codechange: Make use of GetTrackBits where appropriate
celestar
parents:
3523
diff
changeset
|
1887 |
TrackBits nrail = GetTrackBits(n); |
2839
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1888 |
|
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1889 |
if (!IsTileType(n, MP_RAILWAY) || |
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1890 |
!IsTileOwner(n, owner) || |
3524
be2b44204623
(svn r4380) -Codechange: Make use of GetTrackBits where appropriate
celestar
parents:
3523
diff
changeset
|
1891 |
nrail == TRACK_BIT_UPPER || |
be2b44204623
(svn r4380) -Codechange: Make use of GetTrackBits where appropriate
celestar
parents:
3523
diff
changeset
|
1892 |
nrail == TRACK_BIT_RIGHT) { |
2839
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1893 |
new_ground = RAIL_GROUND_FENCE_NE; |
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1894 |
} |
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1895 |
} |
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1896 |
|
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1897 |
if (rail == (TRACK_BIT_UPPER | TRACK_BIT_RIGHT) || ( |
3265 | 1898 |
(rail & TRACK_BIT_3WAY_SW) == 0 && |
3102
fde95020fc8e
(svn r3697) Rename DIAG1/DIAG2 to X resp. Y as this conveys a bit better in which direction a pieces of rail goes
tron
parents:
3101
diff
changeset
|
1899 |
(rail & TRACK_BIT_Y) |
2839
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1900 |
)) { |
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1901 |
TileIndex n = tile + TileDiffXY(1, 0); |
3524
be2b44204623
(svn r4380) -Codechange: Make use of GetTrackBits where appropriate
celestar
parents:
3523
diff
changeset
|
1902 |
TrackBits nrail = GetTrackBits(n); |
2839
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1903 |
|
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1904 |
if (!IsTileType(n, MP_RAILWAY) || |
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1905 |
!IsTileOwner(n, owner) || |
3524
be2b44204623
(svn r4380) -Codechange: Make use of GetTrackBits where appropriate
celestar
parents:
3523
diff
changeset
|
1906 |
nrail == TRACK_BIT_LOWER || |
be2b44204623
(svn r4380) -Codechange: Make use of GetTrackBits where appropriate
celestar
parents:
3523
diff
changeset
|
1907 |
nrail == TRACK_BIT_LEFT) { |
2839
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1908 |
new_ground = (new_ground == RAIL_GROUND_FENCE_NE) ? |
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1909 |
RAIL_GROUND_FENCE_NESW : RAIL_GROUND_FENCE_SW; |
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1910 |
} |
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1911 |
} |
665d7c92448b
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1912 |
break; |
0 | 1913 |
} |
1914 |
} |
|
1915 |
} |
|
1916 |
||
4482
4532293483d6
(svn r6267) Simplify the control flow in the rail tile loop by eliminating a bool flag and replacing it by a simple goto
tron
parents:
4479
diff
changeset
|
1917 |
set_ground: |
2667
78b3c154afa4
(svn r3209) In TileLoop_Track(), use names based on function rather than their place in the map array.
peter1138
parents:
2645
diff
changeset
|
1918 |
if (old_ground != new_ground) { |
3523
168ee460418b
(svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents:
3522
diff
changeset
|
1919 |
SetRailGroundType(tile, new_ground); |
0 | 1920 |
MarkTileDirtyByTile(tile); |
1921 |
} |
|
1922 |
} |
|
1923 |
||
1924 |
||
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1925 |
static uint32 GetTileTrackStatus_Track(TileIndex tile, TransportType mode, uint sub_mode) |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1963
diff
changeset
|
1926 |
{ |
2639 | 1927 |
if (mode != TRANSPORT_RAIL) return 0; |
0 | 1928 |
|
6513
8342666220ae
(svn r8966) -Codechange: replace some if-cascades by switches.
rubidium
parents:
6498
diff
changeset
|
1929 |
switch (GetRailTileType(tile)) { |
8342666220ae
(svn r8966) -Codechange: replace some if-cascades by switches.
rubidium
parents:
6498
diff
changeset
|
1930 |
default: NOT_REACHED(); |
8342666220ae
(svn r8966) -Codechange: replace some if-cascades by switches.
rubidium
parents:
6498
diff
changeset
|
1931 |
case RAIL_TILE_NORMAL: { |
8342666220ae
(svn r8966) -Codechange: replace some if-cascades by switches.
rubidium
parents:
6498
diff
changeset
|
1932 |
TrackBits rails = GetTrackBits(tile); |
8342666220ae
(svn r8966) -Codechange: replace some if-cascades by switches.
rubidium
parents:
6498
diff
changeset
|
1933 |
uint32 ret = rails * 0x101; |
8342666220ae
(svn r8966) -Codechange: replace some if-cascades by switches.
rubidium
parents:
6498
diff
changeset
|
1934 |
return (rails == TRACK_BIT_CROSS) ? ret | 0x40 : ret; |
8342666220ae
(svn r8966) -Codechange: replace some if-cascades by switches.
rubidium
parents:
6498
diff
changeset
|
1935 |
} |
3267
591027d10884
(svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents:
3265
diff
changeset
|
1936 |
|
6513
8342666220ae
(svn r8966) -Codechange: replace some if-cascades by switches.
rubidium
parents:
6498
diff
changeset
|
1937 |
case RAIL_TILE_SIGNALS: { |
8342666220ae
(svn r8966) -Codechange: replace some if-cascades by switches.
rubidium
parents:
6498
diff
changeset
|
1938 |
uint32 ret = GetTrackBits(tile) * 0x101; |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1939 |
byte a = GetPresentSignals(tile); |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1940 |
uint b = GetSignalStates(tile); |
0 | 1941 |
|
1942 |
b &= a; |
|
1943 |
||
22 | 1944 |
/* When signals are not present (in neither |
1945 |
* direction), we pretend them to be green. (So if |
|
1946 |
* signals are only one way, the other way will |
|
1947 |
* implicitely become `red' */ |
|
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1948 |
if ((a & 0xC) == 0) b |= 0xC; |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1949 |
if ((a & 0x3) == 0) b |= 0x3; |
0 | 1950 |
|
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1951 |
if ((b & 0x8) == 0) ret |= 0x10070000; |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1952 |
if ((b & 0x4) == 0) ret |= 0x07100000; |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1953 |
if ((b & 0x2) == 0) ret |= 0x20080000; |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1954 |
if ((b & 0x1) == 0) ret |= 0x08200000; |
6513
8342666220ae
(svn r8966) -Codechange: replace some if-cascades by switches.
rubidium
parents:
6498
diff
changeset
|
1955 |
|
8342666220ae
(svn r8966) -Codechange: replace some if-cascades by switches.
rubidium
parents:
6498
diff
changeset
|
1956 |
return ret; |
0 | 1957 |
} |
6513
8342666220ae
(svn r8966) -Codechange: replace some if-cascades by switches.
rubidium
parents:
6498
diff
changeset
|
1958 |
|
8342666220ae
(svn r8966) -Codechange: replace some if-cascades by switches.
rubidium
parents:
6498
diff
changeset
|
1959 |
case RAIL_TILE_DEPOT: return AxisToTrackBits(DiagDirToAxis(GetRailDepotDirection(tile))) * 0x101; |
8342666220ae
(svn r8966) -Codechange: replace some if-cascades by switches.
rubidium
parents:
6498
diff
changeset
|
1960 |
case RAIL_TILE_WAYPOINT: return GetRailWaypointBits(tile) * 0x101; |
3267
591027d10884
(svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents:
3265
diff
changeset
|
1961 |
} |
0 | 1962 |
} |
1963 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1963
diff
changeset
|
1964 |
static void ClickTile_Track(TileIndex tile) |
0 | 1965 |
{ |
6513
8342666220ae
(svn r8966) -Codechange: replace some if-cascades by switches.
rubidium
parents:
6498
diff
changeset
|
1966 |
switch (GetRailTileType(tile)) { |
9895
7bd07f43b0e3
(svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents:
6513
diff
changeset
|
1967 |
case RAIL_TILE_DEPOT: ShowDepotWindow(tile, VEH_TRAIN); break; |
6513
8342666220ae
(svn r8966) -Codechange: replace some if-cascades by switches.
rubidium
parents:
6498
diff
changeset
|
1968 |
case RAIL_TILE_WAYPOINT: ShowRenameWaypointWindow(GetWaypointByTile(tile)); break; |
8342666220ae
(svn r8966) -Codechange: replace some if-cascades by switches.
rubidium
parents:
6498
diff
changeset
|
1969 |
default: break; |
2548
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2544
diff
changeset
|
1970 |
} |
0 | 1971 |
} |
1972 |
||
1590
4e39d1da10c7
(svn r2094) In GetTileDesc_Track(): uint -> TileIndex, use enums, if () cascade -> switch
tron
parents:
1555
diff
changeset
|
1973 |
static void GetTileDesc_Track(TileIndex tile, TileDesc *td) |
0 | 1974 |
{ |
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
|
1975 |
td->owner = GetTileOwner(tile); |
1942
634961366cdc
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
1976 |
switch (GetRailTileType(tile)) { |
3792
2eb8388731bf
(svn r4788) - Codechange: RAILTYPE_{NORMAL,ELECTRIC,...} and RAIL_TYPE_{NORMAL,SIGNAL,...} have nearly the same name, rename RAIL_TYPE_* to RAIL_TILE_* of extra clarity
rubidium
parents:
3778
diff
changeset
|
1977 |
case RAIL_TILE_NORMAL: |
0 | 1978 |
td->str = STR_1021_RAILROAD_TRACK; |
1590
4e39d1da10c7
(svn r2094) In GetTileDesc_Track(): uint -> TileIndex, use enums, if () cascade -> switch
tron
parents:
1555
diff
changeset
|
1979 |
break; |
4e39d1da10c7
(svn r2094) In GetTileDesc_Track(): uint -> TileIndex, use enums, if () cascade -> switch
tron
parents:
1555
diff
changeset
|
1980 |
|
3792
2eb8388731bf
(svn r4788) - Codechange: RAILTYPE_{NORMAL,ELECTRIC,...} and RAIL_TYPE_{NORMAL,SIGNAL,...} have nearly the same name, rename RAIL_TYPE_* to RAIL_TILE_* of extra clarity
rubidium
parents:
3778
diff
changeset
|
1981 |
case RAIL_TILE_SIGNALS: { |
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1982 |
const StringID signal_type[4][4] = { |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1983 |
{ |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1984 |
STR_RAILROAD_TRACK_WITH_NORMAL_SIGNALS, |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1985 |
STR_RAILROAD_TRACK_WITH_NORMAL_PRESIGNALS, |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1986 |
STR_RAILROAD_TRACK_WITH_NORMAL_EXITSIGNALS, |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1987 |
STR_RAILROAD_TRACK_WITH_NORMAL_COMBOSIGNALS |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1988 |
}, |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1989 |
{ |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1990 |
STR_RAILROAD_TRACK_WITH_NORMAL_PRESIGNALS, |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1991 |
STR_RAILROAD_TRACK_WITH_PRESIGNALS, |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1992 |
STR_RAILROAD_TRACK_WITH_PRE_EXITSIGNALS, |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1993 |
STR_RAILROAD_TRACK_WITH_PRE_COMBOSIGNALS |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1994 |
}, |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1995 |
{ |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1996 |
STR_RAILROAD_TRACK_WITH_NORMAL_EXITSIGNALS, |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1997 |
STR_RAILROAD_TRACK_WITH_PRE_EXITSIGNALS, |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1998 |
STR_RAILROAD_TRACK_WITH_EXITSIGNALS, |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
1999 |
STR_RAILROAD_TRACK_WITH_EXIT_COMBOSIGNALS |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
2000 |
}, |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
2001 |
{ |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
2002 |
STR_RAILROAD_TRACK_WITH_NORMAL_COMBOSIGNALS, |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
2003 |
STR_RAILROAD_TRACK_WITH_PRE_COMBOSIGNALS, |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
2004 |
STR_RAILROAD_TRACK_WITH_EXIT_COMBOSIGNALS, |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
2005 |
STR_RAILROAD_TRACK_WITH_COMBOSIGNALS |
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
2006 |
} |
1590
4e39d1da10c7
(svn r2094) In GetTileDesc_Track(): uint -> TileIndex, use enums, if () cascade -> switch
tron
parents:
1555
diff
changeset
|
2007 |
}; |
4e39d1da10c7
(svn r2094) In GetTileDesc_Track(): uint -> TileIndex, use enums, if () cascade -> switch
tron
parents:
1555
diff
changeset
|
2008 |
|
9912
1ac8aac92385
(svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents:
9911
diff
changeset
|
2009 |
td->str = signal_type[GetSignalType(tile, TRACK_UPPER)][GetSignalType(tile, TRACK_LOWER)]; |
1590
4e39d1da10c7
(svn r2094) In GetTileDesc_Track(): uint -> TileIndex, use enums, if () cascade -> switch
tron
parents:
1555
diff
changeset
|
2010 |
break; |
0 | 2011 |
} |
1590
4e39d1da10c7
(svn r2094) In GetTileDesc_Track(): uint -> TileIndex, use enums, if () cascade -> switch
tron
parents:
1555
diff
changeset
|
2012 |
|
6498
aff910a05c6e
(svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents:
6486
diff
changeset
|
2013 |
case RAIL_TILE_DEPOT: |
aff910a05c6e
(svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents:
6486
diff
changeset
|
2014 |
td->str = STR_1023_RAILROAD_TRAIN_DEPOT; |
aff910a05c6e
(svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents:
6486
diff
changeset
|
2015 |
break; |
aff910a05c6e
(svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents:
6486
diff
changeset
|
2016 |
|
aff910a05c6e
(svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents:
6486
diff
changeset
|
2017 |
case RAIL_TILE_WAYPOINT: |
1590
4e39d1da10c7
(svn r2094) In GetTileDesc_Track(): uint -> TileIndex, use enums, if () cascade -> switch
tron
parents:
1555
diff
changeset
|
2018 |
default: |
6498
aff910a05c6e
(svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents:
6486
diff
changeset
|
2019 |
td->str = STR_LANDINFO_WAYPOINT; |
1590
4e39d1da10c7
(svn r2094) In GetTileDesc_Track(): uint -> TileIndex, use enums, if () cascade -> switch
tron
parents:
1555
diff
changeset
|
2020 |
break; |
0 | 2021 |
} |
2022 |
} |
|
2023 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
2024 |
static void ChangeTileOwner_Track(TileIndex tile, PlayerID old_player, PlayerID new_player) |
0 | 2025 |
{ |
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
|
2026 |
if (!IsTileOwner(tile, old_player)) return; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
2027 |
|
4848
56549aa3e234
(svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents:
4792
diff
changeset
|
2028 |
if (new_player != PLAYER_SPECTATOR) { |
1902 | 2029 |
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:
4388
diff
changeset
|
2030 |
} 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:
3486
diff
changeset
|
2031 |
DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); |
0 | 2032 |
} |
2033 |
} |
|
2034 |
||
2035 |
static const byte _fractcoords_behind[4] = { 0x8F, 0x8, 0x80, 0xF8 }; |
|
2036 |
static const byte _fractcoords_enter[4] = { 0x8A, 0x48, 0x84, 0xA8 }; |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
2037 |
static const signed char _deltacoord_leaveoffset[8] = { |
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
2038 |
-1, 0, 1, 0, /* x */ |
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
2039 |
0, 1, 0, -1 /* y */ |
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
2040 |
}; |
0 | 2041 |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1963
diff
changeset
|
2042 |
static uint32 VehicleEnter_Track(Vehicle *v, TileIndex tile, int x, int y) |
0 | 2043 |
{ |
2044 |
byte fract_coord; |
|
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
2045 |
byte fract_coord_leave; |
3157
40de8616c04c
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3154
diff
changeset
|
2046 |
DiagDirection dir; |
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
2047 |
int length; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
2048 |
|
9908
0fa543611bbe
(svn r10112) [gamebalance] -Sync: r9520:9620 from trunk
celestar
parents:
9907
diff
changeset
|
2049 |
/* this routine applies only to trains in depot tiles */ |
9895
7bd07f43b0e3
(svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents:
6513
diff
changeset
|
2050 |
if (v->type != VEH_TRAIN || !IsTileDepotType(tile, TRANSPORT_RAIL)) return VETSB_CONTINUE; |
0 | 2051 |
|
2052 |
/* depot direction */ |
|
3185 | 2053 |
dir = GetRailDepotDirection(tile); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
2054 |
|
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
2055 |
/* calculate the point where the following wagon should be activated */ |
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
2056 |
/* this depends on the length of the current vehicle */ |
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
2057 |
length = v->u.rail.cached_veh_length; |
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
2058 |
|
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
2059 |
fract_coord_leave = |
4434
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4388
diff
changeset
|
2060 |
((_fractcoords_enter[dir] & 0x0F) + // x |
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
2061 |
(length + 1) * _deltacoord_leaveoffset[dir]) + |
4434
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4388
diff
changeset
|
2062 |
(((_fractcoords_enter[dir] >> 4) + // y |
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
2063 |
((length + 1) * _deltacoord_leaveoffset[dir+4])) << 4); |
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
2064 |
|
0 | 2065 |
fract_coord = (x & 0xF) + ((y & 0xF) << 4); |
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
2066 |
|
0 | 2067 |
if (_fractcoords_behind[dir] == fract_coord) { |
2068 |
/* make sure a train is not entering the tile from behind */ |
|
6317
c73bda71ac16
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents:
5989
diff
changeset
|
2069 |
return VETSB_CANNOT_ENTER; |
0 | 2070 |
} else if (_fractcoords_enter[dir] == fract_coord) { |
3157
40de8616c04c
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3154
diff
changeset
|
2071 |
if (DiagDirToDir(ReverseDiagDir(dir)) == v->direction) { |
0 | 2072 |
/* enter the depot */ |
6319
27e68b914d3d
(svn r8701) -Codechange: replace magic numbers with enums for u.rail.track.
rubidium
parents:
6317
diff
changeset
|
2073 |
v->u.rail.track = TRACK_BIT_DEPOT, |
0 | 2074 |
v->vehstatus |= VS_HIDDEN; /* hide it */ |
3157
40de8616c04c
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3154
diff
changeset
|
2075 |
v->direction = ReverseDir(v->direction); |
5198
2547d72f2db4
(svn r7313) -Codechange: Calling invalidate data on a window will surely warrant a redraw, so call
Darkvater
parents:
5116
diff
changeset
|
2076 |
if (v->next == NULL) VehicleEnterDepot(v); |
2547d72f2db4
(svn r7313) -Codechange: Calling invalidate data on a window will surely warrant a redraw, so call
Darkvater
parents:
5116
diff
changeset
|
2077 |
v->tile = tile; |
2547d72f2db4
(svn r7313) -Codechange: Calling invalidate data on a window will surely warrant a redraw, so call
Darkvater
parents:
5116
diff
changeset
|
2078 |
|
4739
bd535b408617
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4725
diff
changeset
|
2079 |
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile); |
6317
c73bda71ac16
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents:
5989
diff
changeset
|
2080 |
return VETSB_ENTERED_WORMHOLE; |
0 | 2081 |
} |
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
2082 |
} else if (fract_coord_leave == fract_coord) { |
3157
40de8616c04c
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3154
diff
changeset
|
2083 |
if (DiagDirToDir(dir) == v->direction) { |
0 | 2084 |
/* leave the depot? */ |
2951 | 2085 |
if ((v = v->next) != NULL) { |
0 | 2086 |
v->vehstatus &= ~VS_HIDDEN; |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
2087 |
v->u.rail.track = (DiagDirToAxis(dir) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y); |
0 | 2088 |
} |
2089 |
} |
|
2090 |
} |
|
2091 |
||
6317
c73bda71ac16
(svn r8698) -Codechange: enumify the returns of VehicleEnterTile
rubidium
parents:
5989
diff
changeset
|
2092 |
return VETSB_CONTINUE; |
0 | 2093 |
} |
2094 |
||
2095 |
||
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
2096 |
extern const TileTypeProcs _tile_type_rail_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:
4253
diff
changeset
|
2097 |
DrawTile_Track, /* 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:
4253
diff
changeset
|
2098 |
GetSlopeZ_Track, /* 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:
4253
diff
changeset
|
2099 |
ClearTile_Track, /* 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:
4253
diff
changeset
|
2100 |
GetAcceptedCargo_Track, /* 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:
4253
diff
changeset
|
2101 |
GetTileDesc_Track, /* 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:
4253
diff
changeset
|
2102 |
GetTileTrackStatus_Track, /* 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:
4253
diff
changeset
|
2103 |
ClickTile_Track, /* 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:
4253
diff
changeset
|
2104 |
AnimateTile_Track, /* 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:
4253
diff
changeset
|
2105 |
TileLoop_Track, /* 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:
4253
diff
changeset
|
2106 |
ChangeTileOwner_Track, /* 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:
4253
diff
changeset
|
2107 |
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:
4253
diff
changeset
|
2108 |
VehicleEnter_Track, /* vehicle_enter_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:
4253
diff
changeset
|
2109 |
GetSlopeTileh_Track, /* get_slope_tileh_proc */ |
0 | 2110 |
}; |