author | rubidium |
Thu, 01 Feb 2007 15:49:12 +0000 | |
changeset 5893 | 7e431a4abebb |
parent 5738 | 5e2281cf6258 |
child 5991 | ec2eebfe86de |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1818
diff
changeset
|
4 |
#include "openttd.h" |
3189
bf047128dee7
(svn r3846) Add functions to set the type of stuff (clear, water, rail, road) under bridges
tron
parents:
3185
diff
changeset
|
5 |
#include "bridge_map.h" |
1922
bda6f85eefaa
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
6 |
#include "debug.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2148
diff
changeset
|
7 |
#include "functions.h" |
3101
a44fdf9faef1
(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
|
8 |
#include "rail_map.h" |
3144
33e42feae531
(svn r3763) Adapt to the new 'map accessors go in foo_map.h'-scheme
tron
parents:
3142
diff
changeset
|
9 |
#include "road_map.h" |
1363
775a7ee52369
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1330
diff
changeset
|
10 |
#include "table/sprites.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
497
diff
changeset
|
11 |
#include "table/strings.h" |
679
04ca2cd69420
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
555
diff
changeset
|
12 |
#include "map.h" |
1209
2e00193652b2
(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
|
13 |
#include "tile.h" |
3319
16c0f06829a5
(svn r4085) Add GetTown{Index,ByTile}() to get the town index resp. the town from a tile
tron
parents:
3286
diff
changeset
|
14 |
#include "town_map.h" |
3154 | 15 |
#include "tunnel_map.h" |
0 | 16 |
#include "vehicle.h" |
17 |
#include "viewport.h" |
|
18 |
#include "command.h" |
|
19 |
#include "pathfind.h" |
|
1922
bda6f85eefaa
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
20 |
#include "engine.h" |
0 | 21 |
#include "town.h" |
337
cbe0c766c947
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
283
diff
changeset
|
22 |
#include "sound.h" |
389
16ee9854091e
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
337
diff
changeset
|
23 |
#include "station.h" |
405
415546028e8d
(svn r602) -newgrf: Move DrawTileSeqStruct & co and struct SpriteGroup to sprite.h (pasky)
darkvater
parents:
403
diff
changeset
|
24 |
#include "sprite.h" |
1313
f1013ec3d318
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1247
diff
changeset
|
25 |
#include "depot.h" |
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1536
diff
changeset
|
26 |
#include "waypoint.h" |
4440
292881d13622
(svn r6212) Remove dependency on window.h from station.h
tron
parents:
4434
diff
changeset
|
27 |
#include "window.h" |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
28 |
#include "rail.h" |
2236 | 29 |
#include "railtypes.h" // include table for railtypes |
3638
3e655c6e0914
(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
|
30 |
#include "newgrf.h" |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
31 |
#include "yapf/yapf.h" |
3757
0c6a690e6b41
(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
|
32 |
#include "newgrf_callbacks.h" |
0c6a690e6b41
(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
|
33 |
#include "newgrf_station.h" |
4556
cb82978e84ed
(svn r6395) -Fix: when converting a depot from/to elrail, update the power of trains that are in it
glx
parents:
4549
diff
changeset
|
34 |
#include "train.h" |
0 | 35 |
|
2261
d3554e5d3e86
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2254
diff
changeset
|
36 |
const byte _track_sloped_sprites[14] = { |
d3554e5d3e86
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2254
diff
changeset
|
37 |
14, 15, 22, 13, |
d3554e5d3e86
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2254
diff
changeset
|
38 |
0, 21, 17, 12, |
d3554e5d3e86
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2254
diff
changeset
|
39 |
23, 0, 18, 20, |
d3554e5d3e86
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2254
diff
changeset
|
40 |
19, 16 |
d3554e5d3e86
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2254
diff
changeset
|
41 |
}; |
d3554e5d3e86
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2254
diff
changeset
|
42 |
|
0 | 43 |
|
44 |
/* 4 |
|
45 |
* --------- |
|
46 |
* |\ /| |
|
47 |
* | \ 1/ | |
|
48 |
* | \ / | |
|
49 |
* | \ / | |
|
50 |
* 16| \ |32 |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
51 |
* | / \2 | |
0 | 52 |
* | / \ | |
53 |
* | / \ | |
|
54 |
* |/ \| |
|
55 |
* --------- |
|
56 |
* 8 |
|
57 |
*/ |
|
58 |
||
59 |
||
60 |
||
22 | 61 |
/* 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
|
62 |
* MAP3LO byte: abcd???? => Signal Exists? |
4434
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4388
diff
changeset
|
63 |
* a and b are for diagonals, upper and left, |
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4388
diff
changeset
|
64 |
* one for each direction. (ie a == NE->SW, b == |
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4388
diff
changeset
|
65 |
* SW->NE, or v.v., I don't know. b and c are |
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4388
diff
changeset
|
66 |
* similar for lower and right. |
0 | 67 |
* MAP2 byte: ????abcd => Type of ground. |
68 |
* MAP3LO byte: ????abcd => Type of rail. |
|
69 |
* MAP5: 00abcdef => rail |
|
70 |
* 01abcdef => rail w/ signals |
|
71 |
* 10uuuuuu => unused |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
72 |
* 11uuuudd => rail depot |
0 | 73 |
*/ |
74 |
||
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
75 |
static bool CheckTrackCombination(TileIndex tile, TrackBits to_build, uint flags) |
0 | 76 |
{ |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
77 |
TrackBits current; /* The current track layout */ |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
78 |
TrackBits future; /* The track layout we want to build */ |
0 | 79 |
_error_message = STR_1001_IMPOSSIBLE_TRACK_COMBINATION; |
80 |
||
4182
48dba107ff43
(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
|
81 |
if (!IsPlainRailTile(tile)) return false; |
0 | 82 |
|
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
83 |
/* So, we have a tile with tracks on it (and possibly signals). Let's see |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
84 |
* what tracks first */ |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
85 |
current = GetTrackBits(tile); |
1946
f197fb0d840f
(svn r2452) Fix defect in r2448 which caused building tracks unexpectedly fail or succeed
tron
parents:
1942
diff
changeset
|
86 |
future = current | to_build; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
87 |
|
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
88 |
/* Are we really building something new? */ |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
89 |
if (current == future) { |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
90 |
/* Nothing new is being built */ |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
91 |
_error_message = STR_1007_ALREADY_BUILT; |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
92 |
return false; |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
93 |
} |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
94 |
|
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
95 |
/* Let's see if we may build this */ |
4182
48dba107ff43
(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
|
96 |
if (flags & DC_NO_RAIL_OVERLAP || HasSignals(tile)) { |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
97 |
/* If we are not allowed to overlap (flag is on for ai players or we have |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
98 |
* signals on the tile), check that */ |
3258
1c079364726d
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
99 |
return future == TRACK_BIT_HORZ || future == TRACK_BIT_VERT; |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
100 |
} else { |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
101 |
/* Normally, we may overlap and any combination is valid */ |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
102 |
return true; |
0 | 103 |
} |
104 |
} |
|
105 |
||
106 |
||
4067
5ef297943eff
(svn r5363) Revert 5312, 5288, 5248, 3992, 3249, 3228
tron
parents:
4052
diff
changeset
|
107 |
static const TrackBits _valid_tileh_slopes[][15] = { |
0 | 108 |
|
109 |
// set of normal ones |
|
110 |
{ |
|
3258
1c079364726d
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
111 |
TRACK_BIT_ALL, |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
112 |
TRACK_BIT_RIGHT, |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
113 |
TRACK_BIT_UPPER, |
3102
f9ca4379db9d
(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
|
114 |
TRACK_BIT_X, |
0 | 115 |
|
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
116 |
TRACK_BIT_LEFT, |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
117 |
TRACK_BIT_NONE, |
3102
f9ca4379db9d
(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
|
118 |
TRACK_BIT_Y, |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
119 |
TRACK_BIT_LOWER, |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
120 |
|
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
121 |
TRACK_BIT_LOWER, |
3102
f9ca4379db9d
(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
|
122 |
TRACK_BIT_Y, |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
123 |
TRACK_BIT_NONE, |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
124 |
TRACK_BIT_LEFT, |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
125 |
|
3102
f9ca4379db9d
(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
|
126 |
TRACK_BIT_X, |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
127 |
TRACK_BIT_UPPER, |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
128 |
TRACK_BIT_RIGHT, |
0 | 129 |
}, |
130 |
||
131 |
// allowed rail for an evenly raised platform |
|
132 |
{ |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
133 |
TRACK_BIT_NONE, |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
134 |
TRACK_BIT_LEFT, |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
135 |
TRACK_BIT_LOWER, |
3102
f9ca4379db9d
(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
|
136 |
TRACK_BIT_Y | TRACK_BIT_LOWER | TRACK_BIT_LEFT, |
0 | 137 |
|
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
138 |
TRACK_BIT_RIGHT, |
3258
1c079364726d
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
139 |
TRACK_BIT_ALL, |
3102
f9ca4379db9d
(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
|
140 |
TRACK_BIT_X | TRACK_BIT_LOWER | TRACK_BIT_RIGHT, |
3258
1c079364726d
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
141 |
TRACK_BIT_ALL, |
0 | 142 |
|
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
143 |
TRACK_BIT_UPPER, |
3102
f9ca4379db9d
(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
|
144 |
TRACK_BIT_X | TRACK_BIT_UPPER | TRACK_BIT_LEFT, |
3258
1c079364726d
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
145 |
TRACK_BIT_ALL, |
1c079364726d
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
146 |
TRACK_BIT_ALL, |
0 | 147 |
|
3102
f9ca4379db9d
(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
|
148 |
TRACK_BIT_Y | TRACK_BIT_UPPER | TRACK_BIT_RIGHT, |
3258
1c079364726d
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
149 |
TRACK_BIT_ALL, |
1c079364726d
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
150 |
TRACK_BIT_ALL |
3276
97da497e3a29
(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
|
151 |
} |
0 | 152 |
}; |
153 |
||
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
154 |
uint GetRailFoundation(Slope tileh, TrackBits bits) |
0 | 155 |
{ |
3878
ef06782573c0
(svn r4927) Replace 3 big ifs (which regard foundations) by a bit less confusing code
tron
parents:
3869
diff
changeset
|
156 |
uint i; |
0 | 157 |
|
4246
6dcc0e44a367
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
158 |
if (!IsSteepSlope(tileh)) { |
6dcc0e44a367
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
159 |
if ((~_valid_tileh_slopes[0][tileh] & bits) == 0) return 0; |
6dcc0e44a367
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
160 |
if ((~_valid_tileh_slopes[1][tileh] & bits) == 0) return tileh; |
6dcc0e44a367
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
161 |
} |
3878
ef06782573c0
(svn r4927) Replace 3 big ifs (which regard foundations) by a bit less confusing code
tron
parents:
3869
diff
changeset
|
162 |
|
ef06782573c0
(svn r4927) Replace 3 big ifs (which regard foundations) by a bit less confusing code
tron
parents:
3869
diff
changeset
|
163 |
switch (bits) { |
4253
b468db807b66
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
164 |
default: NOT_REACHED(); |
3878
ef06782573c0
(svn r4927) Replace 3 big ifs (which regard foundations) by a bit less confusing code
tron
parents:
3869
diff
changeset
|
165 |
case TRACK_BIT_X: i = 0; break; |
ef06782573c0
(svn r4927) Replace 3 big ifs (which regard foundations) by a bit less confusing code
tron
parents:
3869
diff
changeset
|
166 |
case TRACK_BIT_Y: i = 1; break; |
4253
b468db807b66
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
167 |
case TRACK_BIT_LEFT: return 15 + 8 + (tileh == SLOPE_STEEP_W ? 4 : 0); |
b468db807b66
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
168 |
case TRACK_BIT_LOWER: return 15 + 8 + (tileh == SLOPE_STEEP_S ? 5 : 1); |
b468db807b66
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
169 |
case TRACK_BIT_RIGHT: return 15 + 8 + (tileh == SLOPE_STEEP_E ? 6 : 2); |
b468db807b66
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
170 |
case TRACK_BIT_UPPER: return 15 + 8 + (tileh == SLOPE_STEEP_N ? 7 : 3); |
2951 | 171 |
} |
3878
ef06782573c0
(svn r4927) Replace 3 big ifs (which regard foundations) by a bit less confusing code
tron
parents:
3869
diff
changeset
|
172 |
switch (tileh) { |
4246
6dcc0e44a367
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
173 |
case SLOPE_W: |
6dcc0e44a367
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
174 |
case SLOPE_STEEP_W: i += 0; break; |
6dcc0e44a367
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
175 |
case SLOPE_S: |
6dcc0e44a367
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
176 |
case SLOPE_STEEP_S: i += 2; break; |
6dcc0e44a367
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
177 |
case SLOPE_E: |
6dcc0e44a367
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
178 |
case SLOPE_STEEP_E: i += 4; break; |
6dcc0e44a367
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
179 |
case SLOPE_N: |
6dcc0e44a367
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
180 |
case SLOPE_STEEP_N: i += 6; break; |
6dcc0e44a367
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
181 |
default: return 0; |
3878
ef06782573c0
(svn r4927) Replace 3 big ifs (which regard foundations) by a bit less confusing code
tron
parents:
3869
diff
changeset
|
182 |
} |
ef06782573c0
(svn r4927) Replace 3 big ifs (which regard foundations) by a bit less confusing code
tron
parents:
3869
diff
changeset
|
183 |
return i + 15; |
0 | 184 |
} |
185 |
||
2639 | 186 |
|
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
187 |
static uint32 CheckRailSlope(Slope tileh, TrackBits rail_bits, TrackBits existing, TileIndex tile) |
0 | 188 |
{ |
4246
6dcc0e44a367
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
189 |
if (IsSteepSlope(tileh)) { |
4253
b468db807b66
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
190 |
if (existing == 0) { |
b468db807b66
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
191 |
TrackBits valid = TRACK_BIT_CROSS | (HASBIT(1 << SLOPE_STEEP_W | 1 << SLOPE_STEEP_E, tileh) ? TRACK_BIT_VERT : TRACK_BIT_HORZ); |
b468db807b66
(svn r5864) -Feature: Also allow horizontal and vertical rails on steep slopes
tron
parents:
4246
diff
changeset
|
192 |
if (valid & rail_bits) return _price.terraform; |
4246
6dcc0e44a367
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
193 |
} |
6dcc0e44a367
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
194 |
} else { |
0 | 195 |
rail_bits |= existing; |
196 |
||
197 |
// don't allow building on the lower side of a coast |
|
1627
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
198 |
if (IsTileType(tile, MP_WATER) && |
3276
97da497e3a29
(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
|
199 |
~_valid_tileh_slopes[1][tileh] & rail_bits) { |
0 | 200 |
return_cmd_error(STR_3807_CAN_T_BUILD_ON_WATER); |
201 |
} |
|
202 |
||
203 |
// no special foundation |
|
204 |
if ((~_valid_tileh_slopes[0][tileh] & rail_bits) == 0) |
|
205 |
return 0; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
206 |
|
1627
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
207 |
if ((~_valid_tileh_slopes[1][tileh] & rail_bits) == 0 || ( // whole tile is leveled up |
3102
f9ca4379db9d
(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
|
208 |
(rail_bits == TRACK_BIT_X || rail_bits == TRACK_BIT_Y) && |
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
209 |
(tileh == SLOPE_W || tileh == SLOPE_S || tileh == SLOPE_E || tileh == SLOPE_N) |
1627
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
210 |
)) { // partly up |
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
211 |
if (existing != 0) { |
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
212 |
return 0; |
2422
897a01f7c624
(svn r2948) -Fix: the old AI needs a special flag that triggers all kind of special
truelight
parents:
2364
diff
changeset
|
213 |
} else if (!_patches.build_on_slopes || _is_old_ai_player) { |
1627
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
214 |
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
215 |
} else { |
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
216 |
return _price.terraform; |
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
217 |
} |
0 | 218 |
} |
219 |
} |
|
220 |
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
|
221 |
} |
|
222 |
||
1775
548dc04d50e2
(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
|
223 |
/* Validate functions for rail building */ |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
224 |
static inline bool ValParamTrackOrientation(Track track) {return IsValidTrack(track);} |
1775
548dc04d50e2
(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 |
|
548dc04d50e2
(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
|
226 |
/** Build a single piece of rail |
3491
35d747bb5e82
(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
|
227 |
* @param tile tile to build on |
1775
548dc04d50e2
(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 |
* @param p1 railtype of being built piece (normal, mono, maglev) |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
229 |
* @param p2 rail track to build |
1775
548dc04d50e2
(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
|
230 |
*/ |
3491
35d747bb5e82
(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
|
231 |
int32 CmdBuildSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 232 |
{ |
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
233 |
Slope tileh; |
5058
8175de8766c0
(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
|
234 |
RailType railtype; |
8175de8766c0
(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
|
235 |
Track track; |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
236 |
TrackBits trackbit; |
1627
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
237 |
int32 cost = 0; |
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
238 |
int32 ret; |
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
239 |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
240 |
if (!ValParamRailtype(p1) || !ValParamTrackOrientation((Track)p2)) return CMD_ERROR; |
5058
8175de8766c0
(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
|
241 |
railtype = (RailType)p1; |
8175de8766c0
(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
|
242 |
track = (Track)p2; |
1627
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
243 |
|
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
244 |
tileh = GetTileSlope(tile, NULL); |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
245 |
trackbit = TrackToTrackBits(track); |
0 | 246 |
|
247 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
|
248 |
||
1627
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
249 |
switch (GetTileType(tile)) { |
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
250 |
case MP_RAILWAY: |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
251 |
if (!CheckTrackCombination(tile, trackbit, flags) || |
1627
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
252 |
!EnsureNoVehicle(tile)) { |
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
253 |
return CMD_ERROR; |
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
254 |
} |
4180
159e7febf0ce
(svn r5618) Remove a redundant check, CheckTrackCombination() a few lines above performs the same test
tron
parents:
4158
diff
changeset
|
255 |
if (!IsTileOwner(tile, _current_player) || |
5394
bce82a9368c7
(svn r7583) -Fix (r7573): Merging of bridge branch broke (partially reverted?) automatic railtype conversion when building track on existing rail.
peter1138
parents:
5385
diff
changeset
|
256 |
!IsCompatibleRail(GetRailType(tile), railtype)) { |
1627
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
257 |
// Get detailed error message |
3491
35d747bb5e82
(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
|
258 |
return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
1627
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
259 |
} |
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
260 |
|
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
261 |
ret = CheckRailSlope(tileh, trackbit, GetTrackBits(tile), tile); |
1691
852ca27d6eef
(svn r2195) Add CmdFailed() as the One True Way(tm) to check if a command failed.
tron
parents:
1669
diff
changeset
|
262 |
if (CmdFailed(ret)) return ret; |
0 | 263 |
cost += ret; |
264 |
||
5059
fec3defb6e67
(svn r7112) -Codechange (r7106): Improve the test for determining if the rail type should be converted
peter1138
parents:
5058
diff
changeset
|
265 |
/* If the rail types don't match, try to convert only if engines of |
fec3defb6e67
(svn r7112) -Codechange (r7106): Improve the test for determining if the rail type should be converted
peter1138
parents:
5058
diff
changeset
|
266 |
* the present rail type are powered on the new rail type. */ |
fec3defb6e67
(svn r7112) -Codechange (r7106): Improve the test for determining if the rail type should be converted
peter1138
parents:
5058
diff
changeset
|
267 |
if (GetRailType(tile) != railtype && HasPowerOnRail(GetRailType(tile), railtype)) { |
5058
8175de8766c0
(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
|
268 |
ret = DoCommand(tile, tile, railtype, flags, CMD_CONVERT_RAIL); |
5054
45cfda0fd7eb
(svn r7106) -Feature: Allow over-building of compatible railtypes, i.e. normal and
peter1138
parents:
5015
diff
changeset
|
269 |
if (CmdFailed(ret)) return ret; |
45cfda0fd7eb
(svn r7106) -Feature: Allow over-building of compatible railtypes, i.e. normal and
peter1138
parents:
5015
diff
changeset
|
270 |
cost += ret; |
45cfda0fd7eb
(svn r7106) -Feature: Allow over-building of compatible railtypes, i.e. normal and
peter1138
parents:
5015
diff
changeset
|
271 |
} |
45cfda0fd7eb
(svn r7106) -Feature: Allow over-building of compatible railtypes, i.e. normal and
peter1138
parents:
5015
diff
changeset
|
272 |
|
1719
ddb7e8c7d1a4
(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
|
273 |
if (flags & DC_EXEC) { |
3523
549603ffba5d
(svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents:
3522
diff
changeset
|
274 |
SetRailGroundType(tile, RAIL_GROUND_BARREN); |
5411
9ad8285b2f0d
(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:
5394
diff
changeset
|
275 |
SetTrackBits(tile, GetTrackBits(tile) | trackbit); |
1719
ddb7e8c7d1a4
(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 |
} |
1627
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
277 |
break; |
0 | 278 |
|
1627
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
279 |
case MP_STREET: |
3142
ef213f02d4bf
(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
|
280 |
#define M(x) (1 << (x)) |
ef213f02d4bf
(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
|
281 |
/* Level crossings may only be built on these slopes */ |
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
282 |
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
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
283 |
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
3142
ef213f02d4bf
(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 |
} |
ef213f02d4bf
(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 |
#undef M |
ef213f02d4bf
(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
|
286 |
|
1627
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
287 |
if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
0 | 288 |
|
4140
1765a8dd17dc
(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
|
289 |
if (GetRoadTileType(tile) == ROAD_TILE_NORMAL) { |
1765a8dd17dc
(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
|
290 |
if (HasRoadWorks(tile)) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS); |
1765a8dd17dc
(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
|
291 |
|
1765a8dd17dc
(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
|
292 |
if ((track == TRACK_X && GetRoadBits(tile) == ROAD_Y) || |
1765a8dd17dc
(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 |
(track == TRACK_Y && GetRoadBits(tile) == ROAD_X)) { |
1765a8dd17dc
(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 (flags & DC_EXEC) { |
5058
8175de8766c0
(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
|
295 |
MakeRoadCrossing(tile, GetTileOwner(tile), _current_player, (track == TRACK_X ? AXIS_Y : AXIS_X), railtype, GetTownIndex(tile)); |
4140
1765a8dd17dc
(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
|
296 |
} |
1765a8dd17dc
(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
|
297 |
break; |
4139
611ec4ec9a3b
(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
|
298 |
} |
1627
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
299 |
} |
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
300 |
|
3267
feff95208a9f
(svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents:
3265
diff
changeset
|
301 |
if (IsLevelCrossing(tile) && GetCrossingRailBits(tile) == trackbit) { |
1627
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
302 |
return_cmd_error(STR_1007_ALREADY_BUILT); |
3267
feff95208a9f
(svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents:
3265
diff
changeset
|
303 |
} |
1627
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
304 |
/* FALLTHROUGH */ |
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
305 |
|
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
306 |
default: |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
307 |
ret = CheckRailSlope(tileh, trackbit, TRACK_BIT_NONE, tile); |
1691
852ca27d6eef
(svn r2195) Add CmdFailed() as the One True Way(tm) to check if a command failed.
tron
parents:
1669
diff
changeset
|
308 |
if (CmdFailed(ret)) return ret; |
1627
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
309 |
cost += ret; |
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
310 |
|
3491
35d747bb5e82
(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
|
311 |
ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
1691
852ca27d6eef
(svn r2195) Add CmdFailed() as the One True Way(tm) to check if a command failed.
tron
parents:
1669
diff
changeset
|
312 |
if (CmdFailed(ret)) return ret; |
1627
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
313 |
cost += ret; |
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
314 |
|
5058
8175de8766c0
(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
|
315 |
if (flags & DC_EXEC) MakeRailNormal(tile, _current_player, trackbit, railtype); |
1627
f365c96e74a4
(svn r2131) -Fix: Rewrite CmdBuildSingleRail(), this addresses several issues:
tron
parents:
1609
diff
changeset
|
316 |
break; |
0 | 317 |
} |
318 |
||
319 |
if (flags & DC_EXEC) { |
|
320 |
MarkTileDirtyByTile(tile); |
|
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
321 |
SetSignalsOnBothDir(tile, track); |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
322 |
YapfNotifyTrackLayoutChange(tile, track); |
0 | 323 |
} |
324 |
||
325 |
return cost + _price.build_rail; |
|
326 |
} |
|
327 |
||
1775
548dc04d50e2
(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
|
328 |
/** Remove a single piece of track |
3491
35d747bb5e82
(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
|
329 |
* @param tile tile to remove track from |
1775
548dc04d50e2
(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
|
330 |
* @param p1 unused |
548dc04d50e2
(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
|
331 |
* @param p2 rail orientation |
0 | 332 |
*/ |
3491
35d747bb5e82
(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
|
333 |
int32 CmdRemoveSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 334 |
{ |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
335 |
Track track = (Track)p2; |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
336 |
TrackBits trackbit; |
1963
877cc0deb5b1
(svn r2469) - Add: When removing tracks with the 'remove' tool, have it automatically remove signals on the tracks.
hackykid
parents:
1954
diff
changeset
|
337 |
int32 cost = _price.remove_rail; |
3284
84eda61a0167
(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
|
338 |
bool crossing = false; |
1775
548dc04d50e2
(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
|
339 |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
340 |
if (!ValParamTrackOrientation((Track)p2)) return CMD_ERROR; |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
341 |
trackbit = TrackToTrackBits(track); |
0 | 342 |
|
343 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
|
344 |
||
3273
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
345 |
switch (GetTileType(tile)) { |
3071
6f3417a859d4
(svn r3660) Convert further road bits and type references to the functions/enums
tron
parents:
3069
diff
changeset
|
346 |
case MP_STREET: { |
3273
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
347 |
if (!IsLevelCrossing(tile) || |
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
348 |
GetCrossingRailBits(tile) != trackbit || |
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
349 |
(_current_player != OWNER_WATER && !CheckTileOwnership(tile)) || |
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
350 |
!EnsureNoVehicle(tile)) { |
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
351 |
return CMD_ERROR; |
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
352 |
} |
0 | 353 |
|
3273
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
354 |
if (flags & DC_EXEC) { |
3319
16c0f06829a5
(svn r4085) Add GetTown{Index,ByTile}() to get the town index resp. the town from a tile
tron
parents:
3286
diff
changeset
|
355 |
MakeRoadNormal(tile, GetCrossingRoadOwner(tile), GetCrossingRoadBits(tile), GetTownIndex(tile)); |
3273
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
356 |
} |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
357 |
break; |
3071
6f3417a859d4
(svn r3660) Convert further road bits and type references to the functions/enums
tron
parents:
3069
diff
changeset
|
358 |
} |
2548
49c8a096033f
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2544
diff
changeset
|
359 |
|
3273
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
360 |
case MP_RAILWAY: { |
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
361 |
TrackBits present; |
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
362 |
|
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
363 |
if (!IsPlainRailTile(tile) || |
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
364 |
(_current_player != OWNER_WATER && !CheckTileOwnership(tile)) || |
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
365 |
!EnsureNoVehicle(tile)) { |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
366 |
return CMD_ERROR; |
3273
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
367 |
} |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
368 |
|
3273
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
369 |
present = GetTrackBits(tile); |
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
370 |
if ((present & trackbit) == 0) return CMD_ERROR; |
3284
84eda61a0167
(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
|
371 |
if (present == (TRACK_BIT_X | TRACK_BIT_Y)) crossing = true; |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
372 |
|
1963
877cc0deb5b1
(svn r2469) - Add: When removing tracks with the 'remove' tool, have it automatically remove signals on the tracks.
hackykid
parents:
1954
diff
changeset
|
373 |
/* Charge extra to remove signals on the track, if they are there */ |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
374 |
if (HasSignalOnTrack(tile, track)) |
3491
35d747bb5e82
(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
|
375 |
cost += DoCommand(tile, track, 0, flags, CMD_REMOVE_SIGNALS); |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
376 |
|
3273
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
377 |
if (flags & DC_EXEC) { |
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
378 |
present ^= trackbit; |
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
379 |
if (present == 0) { |
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
380 |
DoClearSquare(tile); |
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
381 |
} else { |
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
382 |
SetTrackBits(tile, present); |
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
383 |
} |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
384 |
} |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
385 |
break; |
3273
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
386 |
} |
2548
49c8a096033f
(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
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
388 |
default: return CMD_ERROR; |
0 | 389 |
} |
390 |
||
3273
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
391 |
if (flags & DC_EXEC) { |
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
392 |
MarkTileDirtyByTile(tile); |
3284
84eda61a0167
(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
|
393 |
if (crossing) { |
84eda61a0167
(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
|
394 |
/* crossing is set when only TRACK_BIT_X and TRACK_BIT_Y are set. As we |
84eda61a0167
(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
|
395 |
* are removing one of these pieces, we'll need to update signals for |
84eda61a0167
(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
|
396 |
* both directions explicitly, as after the track is removed it won't |
84eda61a0167
(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
|
397 |
* 'connect' with the other piece. */ |
84eda61a0167
(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
|
398 |
SetSignalsOnBothDir(tile, TRACK_X); |
84eda61a0167
(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 |
SetSignalsOnBothDir(tile, TRACK_Y); |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
400 |
YapfNotifyTrackLayoutChange(tile, TRACK_X); |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
401 |
YapfNotifyTrackLayoutChange(tile, TRACK_Y); |
3284
84eda61a0167
(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
|
402 |
} else { |
84eda61a0167
(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
|
403 |
SetSignalsOnBothDir(tile, track); |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
404 |
YapfNotifyTrackLayoutChange(tile, track); |
3284
84eda61a0167
(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
|
405 |
} |
3273
3089ecca8e21
(svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents:
3271
diff
changeset
|
406 |
} |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
407 |
|
1963
877cc0deb5b1
(svn r2469) - Add: When removing tracks with the 'remove' tool, have it automatically remove signals on the tracks.
hackykid
parents:
1954
diff
changeset
|
408 |
return cost; |
0 | 409 |
} |
410 |
||
411 |
||
3493
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
412 |
static const TileIndexDiffC _trackdelta[] = { |
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
413 |
{ -1, 0 }, { 0, 1 }, { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, 1 }, |
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
414 |
{ 0, 0 }, |
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
415 |
{ 0, 0 }, |
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
416 |
{ 1, 0 }, { 0, -1 }, { 0, -1 }, { 1, 0 }, { 0, -1 }, { -1, 0 }, |
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
417 |
{ 0, 0 }, |
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
418 |
{ 0, 0 } |
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
419 |
}; |
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
420 |
|
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
421 |
|
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
422 |
static int32 ValidateAutoDrag(Trackdir *trackdir, TileIndex start, TileIndex end) |
1227
1d940a5e02d2
(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
|
423 |
{ |
3493
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
424 |
int x = TileX(start); |
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
425 |
int y = TileY(start); |
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
426 |
int ex = TileX(end); |
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
427 |
int ey = TileY(end); |
1227
1d940a5e02d2
(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
|
428 |
int dx, dy, trdx, trdy; |
0 | 429 |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
430 |
if (!ValParamTrackOrientation(TrackdirToTrack(*trackdir))) return CMD_ERROR; |
1227
1d940a5e02d2
(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
|
431 |
|
1d940a5e02d2
(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
|
432 |
// calculate delta x,y from start to end tile |
1d940a5e02d2
(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
|
433 |
dx = ex - x; |
1d940a5e02d2
(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
|
434 |
dy = ey - y; |
1d940a5e02d2
(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
|
435 |
|
1d940a5e02d2
(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
|
436 |
// calculate delta x,y for the first direction |
3493
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
437 |
trdx = _trackdelta[*trackdir].x; |
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
438 |
trdy = _trackdelta[*trackdir].y; |
1227
1d940a5e02d2
(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
|
439 |
|
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
440 |
if (!IsDiagonalTrackdir(*trackdir)) { |
3493
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
441 |
trdx += _trackdelta[*trackdir ^ 1].x; |
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
442 |
trdy += _trackdelta[*trackdir ^ 1].y; |
1227
1d940a5e02d2
(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
|
443 |
} |
1d940a5e02d2
(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
|
444 |
|
1d940a5e02d2
(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
|
445 |
// validate the direction |
2951 | 446 |
while ( |
447 |
(trdx <= 0 && dx > 0) || |
|
448 |
(trdx >= 0 && dx < 0) || |
|
449 |
(trdy <= 0 && dy > 0) || |
|
450 |
(trdy >= 0 && dy < 0) |
|
451 |
) { |
|
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
452 |
if (!HASBIT(*trackdir, 3)) { // first direction is invalid, try the other |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
453 |
*trackdir = SetBitT(*trackdir, 3); // reverse the direction |
1227
1d940a5e02d2
(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
|
454 |
trdx = -trdx; |
1d940a5e02d2
(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
|
455 |
trdy = -trdy; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
456 |
} else { // other direction is invalid too, invalid drag |
1227
1d940a5e02d2
(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 |
return CMD_ERROR; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
458 |
} |
1227
1d940a5e02d2
(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
|
459 |
} |
1d940a5e02d2
(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 |
|
1d940a5e02d2
(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
|
461 |
// (for diagonal tracks, this is already made sure of by above test), but: |
1d940a5e02d2
(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 |
// for non-diagonal tracks, check if the start and end tile are on 1 line |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
463 |
if (!IsDiagonalTrackdir(*trackdir)) { |
3493
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
464 |
trdx = _trackdelta[*trackdir].x; |
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
465 |
trdy = _trackdelta[*trackdir].y; |
2951 | 466 |
if (abs(dx) != abs(dy) && abs(dx) + abs(trdy) != abs(dy) + abs(trdx)) |
1227
1d940a5e02d2
(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
|
467 |
return CMD_ERROR; |
1d940a5e02d2
(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 |
} |
1d940a5e02d2
(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
|
469 |
|
1d940a5e02d2
(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
|
470 |
return 0; |
1d940a5e02d2
(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
|
471 |
} |
1d940a5e02d2
(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 |
|
1775
548dc04d50e2
(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
|
473 |
/** Build a stretch of railroad tracks. |
3491
35d747bb5e82
(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
|
474 |
* @param tile start tile of drag |
1775
548dc04d50e2
(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
|
475 |
* @param p1 end tile of drag |
548dc04d50e2
(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
|
476 |
* @param p2 various bitstuffed elements |
548dc04d50e2
(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
|
477 |
* - p2 = (bit 0-3) - railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev) |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
478 |
* - p2 = (bit 4-6) - track-orientation, valid values: 0-5 (Track enum) |
1775
548dc04d50e2
(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
|
479 |
* - p2 = (bit 7) - 0 = build, 1 = remove tracks |
0 | 480 |
*/ |
3491
35d747bb5e82
(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
|
481 |
static int32 CmdRailTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
1227
1d940a5e02d2
(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
|
482 |
{ |
1d940a5e02d2
(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 |
int32 ret, total_cost = 0; |
2140
a04d0142ad65
(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
|
484 |
Track track = (Track)GB(p2, 4, 3); |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
485 |
Trackdir trackdir; |
1227
1d940a5e02d2
(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 |
byte mode = HASBIT(p2, 7); |
2604
e3e60351c067
(svn r3141) Replace incorrect railtype bitmask in CmdRailTrackHelper with appropriate GB()
peter1138
parents:
2549
diff
changeset
|
487 |
RailType railtype = (RailType)GB(p2, 0, 4); |
3493
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
488 |
TileIndex end_tile; |
0 | 489 |
|
2604
e3e60351c067
(svn r3141) Replace incorrect railtype bitmask in CmdRailTrackHelper with appropriate GB()
peter1138
parents:
2549
diff
changeset
|
490 |
if (!ValParamRailtype(railtype) || !ValParamTrackOrientation(track)) return CMD_ERROR; |
2934
3f29a7212713
(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
|
491 |
if (p1 >= MapSize()) return CMD_ERROR; |
3493
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
492 |
end_tile = p1; |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
493 |
trackdir = TrackToTrackdir(track); |
1775
548dc04d50e2
(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
|
494 |
|
889
64d2f7d5f02b
(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
|
495 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
64d2f7d5f02b
(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
|
496 |
|
3493
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
497 |
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
|
498 |
|
3493
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
499 |
if (flags & DC_EXEC) SndPlayTileFx(SND_20_SPLAT_2, tile); |
0 | 500 |
|
2952 | 501 |
for (;;) { |
3493
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
502 |
ret = DoCommand(tile, railtype, TrackdirToTrack(trackdir), flags, (mode == 0) ? CMD_BUILD_SINGLE_RAIL : CMD_REMOVE_SINGLE_RAIL); |
0 | 503 |
|
1775
548dc04d50e2
(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
|
504 |
if (CmdFailed(ret)) { |
3671
5b6a80e29dd6
(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
|
505 |
if ((_error_message != STR_1007_ALREADY_BUILT) && (mode == 0)) break; |
5b6a80e29dd6
(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
|
506 |
_error_message = INVALID_STRING_ID; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
507 |
} else { |
0 | 508 |
total_cost += ret; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
509 |
} |
0 | 510 |
|
3493
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
511 |
if (tile == end_tile) break; |
0 | 512 |
|
3493
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
513 |
tile += ToTileIndexDiff(_trackdelta[trackdir]); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
514 |
|
1227
1d940a5e02d2
(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
|
515 |
// toggle railbit for the non-diagonal tracks |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
516 |
if (!IsDiagonalTrackdir(trackdir)) trackdir = ToggleBitT(trackdir, 0); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
517 |
} |
0 | 518 |
|
1775
548dc04d50e2
(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
|
519 |
return (total_cost == 0) ? CMD_ERROR : total_cost; |
0 | 520 |
} |
521 |
||
1796
614d996f6be7
(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
|
522 |
/** Build rail on a stretch of track. |
614d996f6be7
(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
|
523 |
* Stub for the unified rail builder/remover |
614d996f6be7
(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
|
524 |
* @see CmdRailTrackHelper |
614d996f6be7
(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
|
525 |
*/ |
3491
35d747bb5e82
(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
|
526 |
int32 CmdBuildRailroadTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
1227
1d940a5e02d2
(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
|
527 |
{ |
3491
35d747bb5e82
(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
|
528 |
return CmdRailTrackHelper(tile, flags, p1, CLRBIT(p2, 7)); |
1227
1d940a5e02d2
(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
|
529 |
} |
0 | 530 |
|
1796
614d996f6be7
(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
|
531 |
/** Build rail on a stretch of track. |
614d996f6be7
(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
|
532 |
* Stub for the unified rail builder/remover |
614d996f6be7
(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
|
533 |
* @see CmdRailTrackHelper |
614d996f6be7
(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
|
534 |
*/ |
3491
35d747bb5e82
(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
|
535 |
int32 CmdRemoveRailroadTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 536 |
{ |
3491
35d747bb5e82
(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
|
537 |
return CmdRailTrackHelper(tile, flags, p1, SETBIT(p2, 7)); |
0 | 538 |
} |
539 |
||
1775
548dc04d50e2
(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
|
540 |
/** Build a train depot |
3491
35d747bb5e82
(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
|
541 |
* @param tile position of the train depot |
1775
548dc04d50e2
(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
|
542 |
* @param p1 rail type |
3333 | 543 |
* @param p2 entrance direction (DiagDirection) |
2085
876f20a0e843
(svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents:
2049
diff
changeset
|
544 |
* |
876f20a0e843
(svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents:
2049
diff
changeset
|
545 |
* @todo When checking for the tile slope, |
876f20a0e843
(svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents:
2049
diff
changeset
|
546 |
* distingush between "Flat land required" and "land sloped in wrong direction" |
0 | 547 |
*/ |
3491
35d747bb5e82
(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
|
548 |
int32 CmdBuildTrainDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 549 |
{ |
1775
548dc04d50e2
(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
|
550 |
Depot *d; |
0 | 551 |
int32 cost, ret; |
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
552 |
Slope tileh; |
0 | 553 |
|
554 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
|
555 |
||
556 |
if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
|
1775
548dc04d50e2
(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
|
557 |
/* check railtype and valid direction for depot (0 through 3), 4 in total */ |
548dc04d50e2
(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
|
558 |
if (!ValParamRailtype(p1) || p2 > 3) return CMD_ERROR; |
0 | 559 |
|
560 |
tileh = GetTileSlope(tile, NULL); |
|
2085
876f20a0e843
(svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents:
2049
diff
changeset
|
561 |
|
876f20a0e843
(svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents:
2049
diff
changeset
|
562 |
/* Prohibit construction if |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4483
diff
changeset
|
563 |
* The tile is non-flat AND |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4483
diff
changeset
|
564 |
* 1) The AI is "old-school" |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4483
diff
changeset
|
565 |
* 2) build-on-slopes is disabled |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4483
diff
changeset
|
566 |
* 3) the tile is steep i.e. spans two height levels |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4483
diff
changeset
|
567 |
* 4) the exit points in the wrong direction |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4483
diff
changeset
|
568 |
*/ |
2085
876f20a0e843
(svn r2595) -Codechange: Introduced "IsSteepTileh" to find whether a tile is steep
celestar
parents:
2049
diff
changeset
|
569 |
|
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
570 |
if (tileh != SLOPE_FLAT && ( |
2548
49c8a096033f
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2544
diff
changeset
|
571 |
_is_old_ai_player || |
49c8a096033f
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2544
diff
changeset
|
572 |
!_patches.build_on_slopes || |
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
573 |
IsSteepSlope(tileh) || |
2548
49c8a096033f
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2544
diff
changeset
|
574 |
!CanBuildDepotByTileh(p2, tileh) |
49c8a096033f
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2544
diff
changeset
|
575 |
)) { |
49c8a096033f
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2544
diff
changeset
|
576 |
return_cmd_error(STR_0007_FLAT_LAND_REQUIRED); |
0 | 577 |
} |
578 |
||
3491
35d747bb5e82
(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
|
579 |
ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
1775
548dc04d50e2
(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
|
580 |
if (CmdFailed(ret)) return CMD_ERROR; |
0 | 581 |
cost = ret; |
582 |
||
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5380
diff
changeset
|
583 |
if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5380
diff
changeset
|
584 |
|
1775
548dc04d50e2
(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
|
585 |
d = AllocateDepot(); |
2639 | 586 |
if (d == NULL) return CMD_ERROR; |
0 | 587 |
|
588 |
if (flags & DC_EXEC) { |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
589 |
DiagDirection dir = (DiagDirection)p2; |
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
590 |
MakeRailDepot(tile, _current_player, dir, (RailType)p1); |
3101
a44fdf9faef1
(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
|
591 |
MarkTileDirtyByTile(tile); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
592 |
|
1775
548dc04d50e2
(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
|
593 |
d->xy = tile; |
548dc04d50e2
(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
|
594 |
d->town_index = ClosestTownFromTile(tile, (uint)-1)->index; |
0 | 595 |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
596 |
UpdateSignalsOnSegment(tile, dir); |
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
597 |
YapfNotifyTrackLayoutChange(tile, TrackdirToTrack(DiagdirToDiagTrackdir(dir))); |
0 | 598 |
} |
599 |
||
600 |
return cost + _price.build_train_depot; |
|
601 |
} |
|
602 |
||
1775
548dc04d50e2
(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
|
603 |
/** Build signals, alternate between double/single, signal/semaphore, |
5731
c68613da5c4d
(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:
5668
diff
changeset
|
604 |
* pre/exit/combo-signals, and what-else not. If the rail piece does not |
c68613da5c4d
(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:
5668
diff
changeset
|
605 |
* have any signals, bit 4 (cycle signal-type) is ignored |
3491
35d747bb5e82
(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
|
606 |
* @param tile tile where to build the signals |
1775
548dc04d50e2
(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
|
607 |
* @param p1 various bitstuffed elements |
5735
9f3729784816
(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:
5731
diff
changeset
|
608 |
* - p1 = (bit 0-2) - track-orientation, valid values: 0-5 (Track enum) |
9f3729784816
(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:
5731
diff
changeset
|
609 |
* - p1 = (bit 3) - 1 = override signal/semaphore, or pre/exit/combo signal (CTRL-toggle) |
9f3729784816
(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:
5731
diff
changeset
|
610 |
* - p1 = (bit 4) - 0 = signals, 1 = semaphores |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
611 |
* @param p2 used for CmdBuildManySignals() to copy direction of first signal |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
612 |
* 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
|
613 |
*/ |
3491
35d747bb5e82
(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
|
614 |
int32 CmdBuildSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 615 |
{ |
5735
9f3729784816
(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:
5731
diff
changeset
|
616 |
Track track = (Track)GB(p1, 0, 3); |
9f3729784816
(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:
5731
diff
changeset
|
617 |
bool pre_signal = HASBIT(p1, 3); |
9f3729784816
(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:
5731
diff
changeset
|
618 |
SignalVariant sigvar = (pre_signal ^ HASBIT(p1, 4)) ? SIG_SEMAPHORE : SIG_ELECTRIC; |
0 | 619 |
int32 cost; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
620 |
|
1775
548dc04d50e2
(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
|
621 |
if (!ValParamTrackOrientation(track) || !IsTileType(tile, MP_RAILWAY) || !EnsureNoVehicle(tile)) |
0 | 622 |
return CMD_ERROR; |
623 |
||
1775
548dc04d50e2
(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
|
624 |
/* Protect against invalid signal copying */ |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
625 |
if (p2 != 0 && (p2 & SignalOnTrack(track)) == 0) return CMD_ERROR; |
0 | 626 |
|
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
627 |
/* You can only build signals on plain rail tiles, and the selected track must exist */ |
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
628 |
if (!IsPlainRailTile(tile) || !HasTrack(tile, track)) return CMD_ERROR; |
1084 | 629 |
|
630 |
if (!CheckTileOwnership(tile)) return CMD_ERROR; |
|
631 |
||
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
|
632 |
_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
|
633 |
|
0 | 634 |
{ |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
635 |
/* See if this is a valid track combination for signals, (ie, no overlap) */ |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
636 |
TrackBits trackbits = GetTrackBits(tile); |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
637 |
if (KILL_FIRST_BIT(trackbits) != 0 && /* More than one track present */ |
3258
1c079364726d
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
638 |
trackbits != TRACK_BIT_HORZ && |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
639 |
trackbits != TRACK_BIT_VERT) { |
0 | 640 |
return CMD_ERROR; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
641 |
} |
0 | 642 |
} |
643 |
||
1084 | 644 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
0 | 645 |
|
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
646 |
if (!HasSignalOnTrack(tile, track)) { |
1084 | 647 |
// build new signals |
0 | 648 |
cost = _price.build_signals; |
1066
eaef1465d3ab
(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
|
649 |
} else { |
3237
2cf19f9603b2
(svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents:
3234
diff
changeset
|
650 |
if (p2 != 0 && sigvar != GetSignalVariant(tile)) { |
1084 | 651 |
// convert signals <-> semaphores |
652 |
cost = _price.build_signals + _price.remove_signals; |
|
653 |
} else { |
|
654 |
// it is free to change orientation/pre-exit-combo signals |
|
655 |
cost = 0; |
|
656 |
} |
|
0 | 657 |
} |
658 |
||
659 |
if (flags & DC_EXEC) { |
|
4182
48dba107ff43
(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
|
660 |
if (!HasSignals(tile)) { |
1084 | 661 |
// there are no signals at all on this tile yet |
3792
67c865c9315c
(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
|
662 |
_m[tile].m5 |= RAIL_TILE_SIGNALS; // change into signals |
2049
538e73c53f54
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2020
diff
changeset
|
663 |
_m[tile].m2 |= 0xF0; // all signals are on |
538e73c53f54
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2020
diff
changeset
|
664 |
_m[tile].m3 &= ~0xF0; // no signals built by default |
3526
782e7afb5e2d
(svn r4382) -Codechange: Make use of SetSignalType where appropriate
celestar
parents:
3525
diff
changeset
|
665 |
SetSignalType(tile, SIGTYPE_NORMAL); |
3237
2cf19f9603b2
(svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents:
3234
diff
changeset
|
666 |
SetSignalVariant(tile, sigvar); |
0 | 667 |
} |
668 |
||
1084 | 669 |
if (p2 == 0) { |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
670 |
if (!HasSignalOnTrack(tile, track)) { |
1084 | 671 |
// build new signals |
2049
538e73c53f54
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2020
diff
changeset
|
672 |
_m[tile].m3 |= SignalOnTrack(track); |
1084 | 673 |
} else { |
674 |
if (pre_signal) { |
|
2916
b687477adcba
(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
|
675 |
// cycle between normal -> pre -> exit -> combo -> ... |
3238
9ebec0a611ee
(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
|
676 |
SignalType type = GetSignalType(tile); |
9ebec0a611ee
(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
|
677 |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
678 |
SetSignalType(tile, type == SIGTYPE_COMBO ? SIGTYPE_NORMAL : (SignalType)(type + 1)); |
1084 | 679 |
} else { |
3522
888ac5081c6e
(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
|
680 |
CycleSignalSide(tile, track); |
1084 | 681 |
} |
682 |
} |
|
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
|
683 |
} else { |
1084 | 684 |
/* If CmdBuildManySignals is called with copying signals, just copy the |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
685 |
* direction of the first signal given as parameter by CmdBuildManySignals */ |
2049
538e73c53f54
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2020
diff
changeset
|
686 |
_m[tile].m3 &= ~SignalOnTrack(track); |
538e73c53f54
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2020
diff
changeset
|
687 |
_m[tile].m3 |= p2 & SignalOnTrack(track); |
3237
2cf19f9603b2
(svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents:
3234
diff
changeset
|
688 |
SetSignalVariant(tile, sigvar); |
0 | 689 |
} |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
690 |
|
0 | 691 |
MarkTileDirtyByTile(tile); |
692 |
SetSignalsOnBothDir(tile, track); |
|
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
693 |
YapfNotifyTrackLayoutChange(tile, track); |
0 | 694 |
} |
695 |
||
696 |
return cost; |
|
697 |
} |
|
698 |
||
4434
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4388
diff
changeset
|
699 |
/** Build many signals by dragging; AutoSignals |
3491
35d747bb5e82
(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
|
700 |
* @param tile start tile of drag |
1796
614d996f6be7
(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
|
701 |
* @param p1 end tile of drag |
614d996f6be7
(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
|
702 |
* @param p2 various bitstuffed elements |
5735
9f3729784816
(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:
5731
diff
changeset
|
703 |
* - p2 = (bit 0- 2) - track-orientation, valid values: 0-5 (Track enum) |
9f3729784816
(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:
5731
diff
changeset
|
704 |
* - p2 = (bit 3) - 1 = override signal/semaphore, or pre/exit/combo signal (CTRL-toggle) |
9f3729784816
(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:
5731
diff
changeset
|
705 |
* - p2 = (bit 4) - 0 = signals, 1 = semaphores |
5731
c68613da5c4d
(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:
5668
diff
changeset
|
706 |
* - p2 = (bit 5) - 0 = build, 1 = remove signals |
1796
614d996f6be7
(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
|
707 |
* - 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
|
708 |
*/ |
3491
35d747bb5e82
(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
|
709 |
static int32 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
|
710 |
{ |
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
|
711 |
int32 ret, total_cost, signal_ctr; |
1954
2beb56cfddbb
(svn r2460) - Fix: Prevent assertion failure when trying to drag signals starting from a non-rail tile.
hackykid
parents:
1946
diff
changeset
|
712 |
byte signals; |
1796
614d996f6be7
(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
|
713 |
bool error = true; |
3493
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
714 |
TileIndex end_tile; |
1796
614d996f6be7
(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
|
715 |
|
5735
9f3729784816
(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:
5731
diff
changeset
|
716 |
Track track = (Track)GB(p2, 0, 3); |
9f3729784816
(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:
5731
diff
changeset
|
717 |
bool mode = HASBIT(p2, 3); |
9f3729784816
(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:
5731
diff
changeset
|
718 |
bool semaphores = HASBIT(p2, 4); |
5731
c68613da5c4d
(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:
5668
diff
changeset
|
719 |
bool remove = HASBIT(p2, 5); |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
720 |
Trackdir trackdir = TrackToTrackdir(track); |
5731
c68613da5c4d
(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:
5668
diff
changeset
|
721 |
byte signal_density = GB(p2, 24, 8); |
1796
614d996f6be7
(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
|
722 |
|
2934
3f29a7212713
(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
|
723 |
if (p1 >= MapSize()) return CMD_ERROR; |
3493
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
724 |
end_tile = p1; |
1796
614d996f6be7
(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
|
725 |
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
|
726 |
|
2639 | 727 |
if (!IsTileType(tile, MP_RAILWAY)) return CMD_ERROR; |
1954
2beb56cfddbb
(svn r2460) - Fix: Prevent assertion failure when trying to drag signals starting from a non-rail tile.
hackykid
parents:
1946
diff
changeset
|
728 |
|
889
64d2f7d5f02b
(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
|
729 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
64d2f7d5f02b
(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
|
730 |
|
1796
614d996f6be7
(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
|
731 |
/* for vertical/horizontal tracks, double the given signals density |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4483
diff
changeset
|
732 |
* since the original amount will be too dense (shorter tracks) */ |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
733 |
if (!IsDiagonalTrack(track)) signal_density *= 2; |
1796
614d996f6be7
(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
|
734 |
|
3493
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
735 |
if (CmdFailed(ValidateAutoDrag(&trackdir, tile, end_tile))) return CMD_ERROR; |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
736 |
|
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
737 |
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
|
738 |
|
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
|
739 |
// copy the signal-style of the first rail-piece if existing |
4182
48dba107ff43
(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
|
740 |
if (HasSignals(tile)) { |
2049
538e73c53f54
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2020
diff
changeset
|
741 |
signals = _m[tile].m3 & SignalOnTrack(track); |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
742 |
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
|
743 |
|
3237
2cf19f9603b2
(svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents:
3234
diff
changeset
|
744 |
// copy signal/semaphores style (independent of CTRL) |
5731
c68613da5c4d
(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:
5668
diff
changeset
|
745 |
semaphores = GetSignalVariant(tile) != SIG_ELECTRIC; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
746 |
} else { // no signals exist, drag a two-way signal stretch |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
747 |
signals = SignalOnTrack(track); |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
748 |
} |
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
|
749 |
|
1954
2beb56cfddbb
(svn r2460) - Fix: Prevent assertion failure when trying to drag signals starting from a non-rail tile.
hackykid
parents:
1946
diff
changeset
|
750 |
/* signal_ctr - amount of tiles already processed |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
751 |
* 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
|
752 |
********** |
1954
2beb56cfddbb
(svn r2460) - Fix: Prevent assertion failure when trying to drag signals starting from a non-rail tile.
hackykid
parents:
1946
diff
changeset
|
753 |
* trackdir - trackdir to build with autorail |
2beb56cfddbb
(svn r2460) - Fix: Prevent assertion failure when trying to drag signals starting from a non-rail tile.
hackykid
parents:
1946
diff
changeset
|
754 |
* semaphores - semaphores or signals |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
755 |
* signals - is there a signal/semaphore on the first tile, copy its style (two-way/single-way) |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4483
diff
changeset
|
756 |
* and convert all others to semaphore/signal |
5731
c68613da5c4d
(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:
5668
diff
changeset
|
757 |
* 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
|
758 |
signal_ctr = total_cost = 0; |
1796
614d996f6be7
(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
|
759 |
for (;;) { |
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 |
// only build/remove signals with the specified density |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
761 |
if (signal_ctr % signal_density == 0) { |
5735
9f3729784816
(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:
5731
diff
changeset
|
762 |
uint32 p1 = GB(TrackdirToTrack(trackdir), 0, 3); |
9f3729784816
(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:
5731
diff
changeset
|
763 |
SB(p1, 3, 1, mode); |
9f3729784816
(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:
5731
diff
changeset
|
764 |
SB(p1, 4, 1, semaphores); |
5731
c68613da5c4d
(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:
5668
diff
changeset
|
765 |
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
|
766 |
|
5069
68beabd19dca
(svn r7127) -Codechange [FS#149]: Improve the usability of the signal-dragger, do not bail out
Darkvater
parents:
5059
diff
changeset
|
767 |
/* Be user-friendly and try placing signals as much as possible */ |
68beabd19dca
(svn r7127) -Codechange [FS#149]: Improve the usability of the signal-dragger, do not bail out
Darkvater
parents:
5059
diff
changeset
|
768 |
if (!CmdFailed(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
|
769 |
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
|
770 |
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
|
771 |
} |
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
|
772 |
} |
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
|
773 |
|
3493
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
774 |
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
|
775 |
|
3493
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
776 |
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
|
777 |
signal_ctr++; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
778 |
|
1227
1d940a5e02d2
(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
|
779 |
// toggle railbit for the non-diagonal tracks (|, -- tracks) |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
780 |
if (!IsDiagonalTrackdir(trackdir)) 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
|
781 |
} |
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
|
782 |
|
2951 | 783 |
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
|
784 |
} |
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
|
785 |
|
1796
614d996f6be7
(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
|
786 |
/** Build signals on a stretch of track. |
614d996f6be7
(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
|
787 |
* Stub for the unified signal builder/remover |
614d996f6be7
(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
|
788 |
* @see CmdSignalTrackHelper |
614d996f6be7
(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
|
789 |
*/ |
3491
35d747bb5e82
(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
|
790 |
int32 CmdBuildSignalTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
1227
1d940a5e02d2
(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
|
791 |
{ |
3491
35d747bb5e82
(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
|
792 |
return CmdSignalTrackHelper(tile, flags, p1, p2); |
1227
1d940a5e02d2
(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
|
793 |
} |
1d940a5e02d2
(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
|
794 |
|
1775
548dc04d50e2
(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
|
795 |
/** Remove signals |
3491
35d747bb5e82
(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
|
796 |
* @param tile coordinates where signal is being deleted from |
5731
c68613da5c4d
(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:
5668
diff
changeset
|
797 |
* @param various bitstuffed elements, only track information is used |
5735
9f3729784816
(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:
5731
diff
changeset
|
798 |
* - p1 = (bit 0- 2) - track-orientation, valid values: 0-5 (Track enum) |
9f3729784816
(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:
5731
diff
changeset
|
799 |
* - p1 = (bit 3) - override signal/semaphore, or pre/exit/combo signal (CTRL-toggle) |
9f3729784816
(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:
5731
diff
changeset
|
800 |
* - p1 = (bit 4) - 0 = signals, 1 = semaphores |
0 | 801 |
*/ |
3491
35d747bb5e82
(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
|
802 |
int32 CmdRemoveSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 803 |
{ |
5735
9f3729784816
(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:
5731
diff
changeset
|
804 |
Track track = (Track)GB(p1, 0, 3); |
1518
9a876c45238b
(svn r2022) Revise CmdRemoveSingleSignal: Check parameters for validity and simplify the function
tron
parents:
1477
diff
changeset
|
805 |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
806 |
if (!ValParamTrackOrientation(track) || |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
807 |
!IsTileType(tile, MP_RAILWAY) || |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
808 |
!EnsureNoVehicle(tile) || |
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
809 |
!HasSignalOnTrack(tile, track)) { |
1518
9a876c45238b
(svn r2022) Revise CmdRemoveSingleSignal: Check parameters for validity and simplify the function
tron
parents:
1477
diff
changeset
|
810 |
return CMD_ERROR; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
811 |
} |
1518
9a876c45238b
(svn r2022) Revise CmdRemoveSingleSignal: Check parameters for validity and simplify the function
tron
parents:
1477
diff
changeset
|
812 |
|
1775
548dc04d50e2
(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
|
813 |
/* Only water can remove signals from anyone */ |
548dc04d50e2
(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
|
814 |
if (_current_player != OWNER_WATER && !CheckTileOwnership(tile)) return CMD_ERROR; |
0 | 815 |
|
816 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
|
817 |
||
818 |
/* Do it? */ |
|
819 |
if (flags & DC_EXEC) { |
|
2049
538e73c53f54
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2020
diff
changeset
|
820 |
_m[tile].m3 &= ~SignalOnTrack(track); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
821 |
|
1066
eaef1465d3ab
(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
|
822 |
/* removed last signal from tile? */ |
2493
f6b4300cc2b0
(svn r3019) -Codechange: Replace explicit shifting/anding/oring with GB and SB
tron
parents:
2472
diff
changeset
|
823 |
if (GB(_m[tile].m3, 4, 4) == 0) { |
f6b4300cc2b0
(svn r3019) -Codechange: Replace explicit shifting/anding/oring with GB and SB
tron
parents:
2472
diff
changeset
|
824 |
SB(_m[tile].m2, 4, 4, 0); |
3792
67c865c9315c
(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
|
825 |
SB(_m[tile].m5, 6, 2, RAIL_TILE_NORMAL >> 6); // XXX >> because the constant is meant for direct application, not use with SB |
3237
2cf19f9603b2
(svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents:
3234
diff
changeset
|
826 |
SetSignalVariant(tile, SIG_ELECTRIC); // remove any possible semaphores |
1066
eaef1465d3ab
(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
|
827 |
} |
1109
ecb98f43ba2c
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1095
diff
changeset
|
828 |
|
1066
eaef1465d3ab
(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
|
829 |
SetSignalsOnBothDir(tile, track); |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
830 |
YapfNotifyTrackLayoutChange(tile, track); |
0 | 831 |
|
832 |
MarkTileDirtyByTile(tile); |
|
833 |
} |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
834 |
|
0 | 835 |
return _price.remove_signals; |
836 |
} |
|
837 |
||
1796
614d996f6be7
(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 |
/** Remove signals on a stretch of track. |
614d996f6be7
(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
|
839 |
* Stub for the unified signal builder/remover |
614d996f6be7
(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
|
840 |
* @see CmdSignalTrackHelper |
614d996f6be7
(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
|
841 |
*/ |
3491
35d747bb5e82
(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
|
842 |
int32 CmdRemoveSignalTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
1227
1d940a5e02d2
(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
|
843 |
{ |
5731
c68613da5c4d
(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:
5668
diff
changeset
|
844 |
return CmdSignalTrackHelper(tile, flags, p1, SETBIT(p2, 5)); // bit 5 is remove bit |
1227
1d940a5e02d2
(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
|
845 |
} |
1d940a5e02d2
(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
|
846 |
|
3355
e414a0b104a6
(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
|
847 |
typedef int32 DoConvertRailProc(TileIndex tile, RailType totype, bool exec); |
0 | 848 |
|
3355
e414a0b104a6
(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
|
849 |
static int32 DoConvertRail(TileIndex tile, RailType totype, bool exec) |
0 | 850 |
{ |
3355
e414a0b104a6
(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
|
851 |
if (!CheckTileOwnership(tile)) return CMD_ERROR; |
e414a0b104a6
(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
|
852 |
|
3778
475b560a739e
(svn r4770) - Revert unindented change to rail_cmd.c in r4769.
peter1138
parents:
3777
diff
changeset
|
853 |
if (!EnsureNoVehicle(tile) && (!IsCompatibleRail(GetRailType(tile), totype) || IsPlainRailTile(tile))) return CMD_ERROR; |
0 | 854 |
|
855 |
// tile is already of requested type? |
|
2549 | 856 |
if (GetRailType(tile) == totype) return CMD_ERROR; |
0 | 857 |
|
5116
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5069
diff
changeset
|
858 |
// 'hidden' elrails can't be downgraded to normal rail when elrails are disabled |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5069
diff
changeset
|
859 |
if (_patches.disable_elrails && totype == RAILTYPE_RAIL && GetRailType(tile) == RAILTYPE_ELECTRIC) return CMD_ERROR; |
3c0c3da214ca
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
5069
diff
changeset
|
860 |
|
0 | 861 |
// change type. |
862 |
if (exec) { |
|
3242
4c32bf21153b
(svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents:
3238
diff
changeset
|
863 |
SetRailType(tile, totype); |
0 | 864 |
MarkTileDirtyByTile(tile); |
3869
0467c594dfb5
(svn r4906) - Fix: Refresh build vehicle window (if opened) when converting rail depot
glx
parents:
3794
diff
changeset
|
865 |
|
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
866 |
// notify YAPF about the track layout change |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
867 |
TrackBits tracks = GetTrackBits(tile); |
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
868 |
while (tracks != TRACK_BIT_NONE) { |
5598
2fadbd43709d
(svn r8052) - Codechange: RemoveFirstTrack() and RemoveFirstTrackdir() now accept pointer to TrackBits/TrackdirBits instead of reference.
KUDr
parents:
5587
diff
changeset
|
869 |
YapfNotifyTrackLayoutChange(tile, RemoveFirstTrack(&tracks)); |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
870 |
} |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
871 |
|
3869
0467c594dfb5
(svn r4906) - Fix: Refresh build vehicle window (if opened) when converting rail depot
glx
parents:
3794
diff
changeset
|
872 |
if (IsTileDepotType(tile, TRANSPORT_RAIL)) { |
4556
cb82978e84ed
(svn r6395) -Fix: when converting a depot from/to elrail, update the power of trains that are in it
glx
parents:
4549
diff
changeset
|
873 |
Vehicle *v; |
cb82978e84ed
(svn r6395) -Fix: when converting a depot from/to elrail, update the power of trains that are in it
glx
parents:
4549
diff
changeset
|
874 |
|
cb82978e84ed
(svn r6395) -Fix: when converting a depot from/to elrail, update the power of trains that are in it
glx
parents:
4549
diff
changeset
|
875 |
/* Update build vehicle window related to this depot */ |
4792
a6fa5fc79715
(svn r6714) -Codechange: replaced a direct manipulation of windows with InvalidateWindowData() in rail_cmd.c
bjarni
parents:
4790
diff
changeset
|
876 |
InvalidateWindowData(WC_BUILD_VEHICLE, tile); |
4556
cb82978e84ed
(svn r6395) -Fix: when converting a depot from/to elrail, update the power of trains that are in it
glx
parents:
4549
diff
changeset
|
877 |
|
cb82978e84ed
(svn r6395) -Fix: when converting a depot from/to elrail, update the power of trains that are in it
glx
parents:
4549
diff
changeset
|
878 |
/* update power of trains in this depot */ |
cb82978e84ed
(svn r6395) -Fix: when converting a depot from/to elrail, update the power of trains that are in it
glx
parents:
4549
diff
changeset
|
879 |
FOR_ALL_VEHICLES(v) { |
cb82978e84ed
(svn r6395) -Fix: when converting a depot from/to elrail, update the power of trains that are in it
glx
parents:
4549
diff
changeset
|
880 |
if (v->type == VEH_Train && IsFrontEngine(v) && v->tile == tile && v->u.rail.track == 0x80) { |
cb82978e84ed
(svn r6395) -Fix: when converting a depot from/to elrail, update the power of trains that are in it
glx
parents:
4549
diff
changeset
|
881 |
TrainPowerChanged(v); |
cb82978e84ed
(svn r6395) -Fix: when converting a depot from/to elrail, update the power of trains that are in it
glx
parents:
4549
diff
changeset
|
882 |
} |
cb82978e84ed
(svn r6395) -Fix: when converting a depot from/to elrail, update the power of trains that are in it
glx
parents:
4549
diff
changeset
|
883 |
} |
3869
0467c594dfb5
(svn r4906) - Fix: Refresh build vehicle window (if opened) when converting rail depot
glx
parents:
3794
diff
changeset
|
884 |
} |
0 | 885 |
} |
886 |
||
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
887 |
return _price.build_rail / 2; |
0 | 888 |
} |
889 |
||
3435
dfba5b1c7c2d
(svn r4265) - Fix: compile warning on VS2005 (parameter 2 different from declaration)
Darkvater
parents:
3418
diff
changeset
|
890 |
extern int32 DoConvertStationRail(TileIndex tile, RailType totype, bool exec); |
dfba5b1c7c2d
(svn r4265) - Fix: compile warning on VS2005 (parameter 2 different from declaration)
Darkvater
parents:
3418
diff
changeset
|
891 |
extern int32 DoConvertStreetRail(TileIndex tile, RailType totype, bool exec); |
dfba5b1c7c2d
(svn r4265) - Fix: compile warning on VS2005 (parameter 2 different from declaration)
Darkvater
parents:
3418
diff
changeset
|
892 |
extern int32 DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec); |
0 | 893 |
|
1782
48749e4c2dc6
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1781
diff
changeset
|
894 |
/** Convert one rail type to the other. You can convert normal rail to |
48749e4c2dc6
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1781
diff
changeset
|
895 |
* monorail/maglev easily or vice-versa. |
3491
35d747bb5e82
(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
|
896 |
* @param tile end tile of rail conversion drag |
1782
48749e4c2dc6
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1781
diff
changeset
|
897 |
* @param p1 start tile of drag |
48749e4c2dc6
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1781
diff
changeset
|
898 |
* @param p2 new railtype to convert to |
48749e4c2dc6
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1781
diff
changeset
|
899 |
*/ |
3491
35d747bb5e82
(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
|
900 |
int32 CmdConvertRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 901 |
{ |
902 |
int32 ret, cost, money; |
|
3491
35d747bb5e82
(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
|
903 |
int ex; |
35d747bb5e82
(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
|
904 |
int ey; |
1782
48749e4c2dc6
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1781
diff
changeset
|
905 |
int sx, sy, x, y; |
0 | 906 |
|
889
64d2f7d5f02b
(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
|
907 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
64d2f7d5f02b
(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
|
908 |
|
1782
48749e4c2dc6
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1781
diff
changeset
|
909 |
if (!ValParamRailtype(p2)) return CMD_ERROR; |
2934
3f29a7212713
(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
|
910 |
if (p1 >= MapSize()) return CMD_ERROR; |
1782
48749e4c2dc6
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1781
diff
changeset
|
911 |
|
0 | 912 |
// make sure sx,sy are smaller than ex,ey |
3493
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
913 |
ex = TileX(tile); |
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
914 |
ey = TileY(tile); |
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
915 |
sx = TileX(p1); |
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
916 |
sy = TileY(p1); |
0 | 917 |
if (ex < sx) intswap(ex, sx); |
918 |
if (ey < sy) intswap(ey, sy); |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
919 |
|
0 | 920 |
money = GetAvailableMoneyForCommand(); |
921 |
cost = 0; |
|
3881 | 922 |
ret = 0; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
923 |
|
3493
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
924 |
for (x = sx; x <= ex; ++x) { |
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
925 |
for (y = sy; y <= ey; ++y) { |
c77bcf04294d
(svn r4344) Use tile coordinates or even TileIndices instead of virtual tile coordinates where it suffices.
tron
parents:
3491
diff
changeset
|
926 |
TileIndex tile = TileXY(x, y); |
2549 | 927 |
DoConvertRailProc* proc; |
1782
48749e4c2dc6
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1781
diff
changeset
|
928 |
|
2549 | 929 |
switch (GetTileType(tile)) { |
930 |
case MP_RAILWAY: proc = DoConvertRail; break; |
|
931 |
case MP_STATION: proc = DoConvertStationRail; break; |
|
932 |
case MP_STREET: proc = DoConvertStreetRail; break; |
|
933 |
case MP_TUNNELBRIDGE: proc = DoConvertTunnelBridgeRail; break; |
|
934 |
default: continue; |
|
935 |
} |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
936 |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
937 |
ret = proc(tile, (RailType)p2, false); |
1782
48749e4c2dc6
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1781
diff
changeset
|
938 |
if (CmdFailed(ret)) continue; |
0 | 939 |
cost += ret; |
940 |
||
941 |
if (flags & DC_EXEC) { |
|
2549 | 942 |
money -= ret; |
943 |
if (money < 0) { |
|
944 |
_additional_cash_required = ret; |
|
945 |
return cost - ret; |
|
946 |
} |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
947 |
proc(tile, (RailType)p2, true); |
0 | 948 |
} |
949 |
} |
|
950 |
} |
|
1782
48749e4c2dc6
(svn r2286) - CodeChange: paramcheck the next batch of commands.
Darkvater
parents:
1781
diff
changeset
|
951 |
|
3881 | 952 |
return (cost == 0) ? ret : cost; |
0 | 953 |
} |
954 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1963
diff
changeset
|
955 |
static int32 RemoveTrainDepot(TileIndex tile, uint32 flags) |
0 | 956 |
{ |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
84
diff
changeset
|
957 |
if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) |
0 | 958 |
return CMD_ERROR; |
959 |
||
960 |
if (!EnsureNoVehicle(tile)) |
|
961 |
return CMD_ERROR; |
|
962 |
||
963 |
if (flags & DC_EXEC) { |
|
3191
b2bebf380cd7
(svn r3851) Rail depots only have an entrance at one side, therefore use UpdateSignalsOnSegment() instead of SetSignalsOnBothDir()
tron
parents:
3189
diff
changeset
|
964 |
DiagDirection dir = GetRailDepotDirection(tile); |
0 | 965 |
|
4388
c8a66d26e146
(svn r6141) -Codechange: introduced DepotID and used it as much as possible
truelight
parents:
4344
diff
changeset
|
966 |
DeleteDepot(GetDepotByTile(tile)); |
3191
b2bebf380cd7
(svn r3851) Rail depots only have an entrance at one side, therefore use UpdateSignalsOnSegment() instead of SetSignalsOnBothDir()
tron
parents:
3189
diff
changeset
|
967 |
UpdateSignalsOnSegment(tile, dir); |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
968 |
YapfNotifyTrackLayoutChange(tile, TrackdirToTrack(DiagdirToDiagTrackdir(dir))); |
0 | 969 |
} |
970 |
||
971 |
return _price.remove_train_depot; |
|
972 |
} |
|
973 |
||
1534
304124d6b5e3
(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
|
974 |
static int32 ClearTile_Track(TileIndex tile, byte flags) |
304124d6b5e3
(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
|
975 |
{ |
304124d6b5e3
(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
|
976 |
int32 cost; |
304124d6b5e3
(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
|
977 |
int32 ret; |
0 | 978 |
|
979 |
if (flags & DC_AUTO) { |
|
1901
03bf9bf99319
(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
|
980 |
if (!IsTileOwner(tile, _current_player)) |
0 | 981 |
return_cmd_error(STR_1024_AREA_IS_OWNED_BY_ANOTHER); |
982 |
||
4182
48dba107ff43
(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
|
983 |
if (IsPlainRailTile(tile)) { |
48dba107ff43
(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
|
984 |
return_cmd_error(STR_1008_MUST_REMOVE_RAILROAD_TRACK); |
48dba107ff43
(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
|
985 |
} else { |
48dba107ff43
(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
|
986 |
return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED); |
48dba107ff43
(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
|
987 |
} |
0 | 988 |
} |
989 |
||
990 |
cost = 0; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
991 |
|
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
992 |
switch (GetRailTileType(tile)) { |
3792
67c865c9315c
(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
|
993 |
case RAIL_TILE_SIGNALS: |
67c865c9315c
(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
|
994 |
case RAIL_TILE_NORMAL: { |
5414
6469dbacdab8
(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:
5411
diff
changeset
|
995 |
TrackBits tracks = GetTrackBits(tile); |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
996 |
while (tracks != TRACK_BIT_NONE) { |
5598
2fadbd43709d
(svn r8052) - Codechange: RemoveFirstTrack() and RemoveFirstTrackdir() now accept pointer to TrackBits/TrackdirBits instead of reference.
KUDr
parents:
5587
diff
changeset
|
997 |
Track track = RemoveFirstTrack(&tracks); |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
998 |
ret = DoCommand(tile, 0, track, flags, CMD_REMOVE_SINGLE_RAIL); |
5411
9ad8285b2f0d
(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:
5394
diff
changeset
|
999 |
if (CmdFailed(ret)) return CMD_ERROR; |
9ad8285b2f0d
(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:
5394
diff
changeset
|
1000 |
cost += ret; |
1534
304124d6b5e3
(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
|
1001 |
} |
304124d6b5e3
(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
|
1002 |
return cost; |
304124d6b5e3
(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
|
1003 |
} |
304124d6b5e3
(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
|
1004 |
|
3792
67c865c9315c
(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
|
1005 |
case RAIL_TILE_DEPOT_WAYPOINT: |
3269
62fb247bf94b
(svn r3981) More work for the rail accessing functions and enums
tron
parents:
3267
diff
changeset
|
1006 |
if (GetRailTileSubtype(tile) == RAIL_SUBTYPE_DEPOT) { |
62fb247bf94b
(svn r3981) More work for the rail accessing functions and enums
tron
parents:
3267
diff
changeset
|
1007 |
return RemoveTrainDepot(tile, flags); |
62fb247bf94b
(svn r3981) More work for the rail accessing functions and enums
tron
parents:
3267
diff
changeset
|
1008 |
} else { |
62fb247bf94b
(svn r3981) More work for the rail accessing functions and enums
tron
parents:
3267
diff
changeset
|
1009 |
return RemoveTrainWaypoint(tile, flags, false); |
1534
304124d6b5e3
(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
|
1010 |
} |
304124d6b5e3
(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
|
1011 |
|
304124d6b5e3
(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
|
1012 |
default: |
304124d6b5e3
(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
|
1013 |
return CMD_ERROR; |
304124d6b5e3
(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
|
1014 |
} |
0 | 1015 |
} |
1016 |
||
1017 |
#include "table/track_land.h" |
|
1018 |
||
3575
f5b56bd958c0
(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
|
1019 |
static void DrawSingleSignal(TileIndex tile, byte condition, uint image, uint pos) |
0 | 1020 |
{ |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
1021 |
bool side = (_opt.road_side != 0) && _patches.signal_side; |
3502
b747d7225871
(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
|
1022 |
static const Point SignalPositions[2][12] = { |
b747d7225871
(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
|
1023 |
{ /* Signals on the left side */ |
b747d7225871
(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
|
1024 |
/* LEFT LEFT RIGHT RIGHT UPPER UPPER */ |
b747d7225871
(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
|
1025 |
{ 8, 5}, {14, 1}, { 1, 14}, { 9, 11}, { 1, 0}, { 3, 10}, |
b747d7225871
(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
|
1026 |
/* LOWER LOWER X X Y Y */ |
b747d7225871
(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
|
1027 |
{11, 4}, {14, 14}, {11, 3}, { 4, 13}, { 3, 4}, {11, 13} |
b747d7225871
(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
|
1028 |
}, { /* Signals on the right side */ |
b747d7225871
(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
|
1029 |
/* LEFT LEFT RIGHT RIGHT UPPER UPPER */ |
b747d7225871
(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
|
1030 |
{14, 1}, {12, 10}, { 4, 6}, { 1, 14}, {10, 4}, { 0, 1}, |
b747d7225871
(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
|
1031 |
/* LOWER LOWER X X Y Y */ |
b747d7225871
(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
|
1032 |
{14, 14}, { 5, 12}, {11, 13}, { 4, 3}, {13, 4}, { 3, 11} |
b747d7225871
(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
|
1033 |
} |
b747d7225871
(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
|
1034 |
}; |
0 | 1035 |
|
3506
226b7faabe40
(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
|
1036 |
static const SpriteID SignalBase[2][2][4] = { |
226b7faabe40
(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
|
1037 |
{ /* Signals on left side */ |
226b7faabe40
(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
|
1038 |
{ 0x4FB, 0x1323, 0x1333, 0x1343}, /* light signals */ |
226b7faabe40
(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
|
1039 |
{ 0x1353, 0x1363, 0x1373, 0x1383} /* semaphores */ |
226b7faabe40
(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
|
1040 |
}, { /* Signals on right side */ |
226b7faabe40
(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
|
1041 |
{ 0x4FB, 0x1323, 0x1333, 0x1343}, /* light signals */ |
226b7faabe40
(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
|
1042 |
{ 0x1446, 0x1456, 0x1466, 0x1476} /* semaphores */ |
226b7faabe40
(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
|
1043 |
/* | | | | */ |
226b7faabe40
(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
|
1044 |
/* normal, entry, exit, combo */ |
226b7faabe40
(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
|
1045 |
} |
226b7faabe40
(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
|
1046 |
}; |
226b7faabe40
(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
|
1047 |
|
3575
f5b56bd958c0
(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
|
1048 |
uint x = TileX(tile) * TILE_SIZE + SignalPositions[side][pos].x; |
f5b56bd958c0
(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
|
1049 |
uint y = TileY(tile) * TILE_SIZE + SignalPositions[side][pos].y; |
f5b56bd958c0
(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
|
1050 |
|
3638
3e655c6e0914
(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
|
1051 |
SpriteID sprite; |
3e655c6e0914
(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
|
1052 |
|
3e655c6e0914
(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
|
1053 |
/* _signal_base is set by our NewGRF Action 5 loader. If it is 0 then we |
3e655c6e0914
(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
|
1054 |
* just draw the standard signals, else we get the offset from _signal_base |
3e655c6e0914
(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
|
1055 |
* and draw that sprite. All the signal sprites are loaded sequentially. */ |
3e655c6e0914
(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
|
1056 |
if (_signal_base == 0 || (GetSignalType(tile) == 0 && GetSignalVariant(tile) == SIG_ELECTRIC)) { |
3e655c6e0914
(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
|
1057 |
sprite = SignalBase[side][GetSignalVariant(tile)][GetSignalType(tile)] + image + condition; |
3e655c6e0914
(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
|
1058 |
} else { |
3e655c6e0914
(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
|
1059 |
sprite = _signal_base + (GetSignalType(tile) - 1) * 16 + GetSignalVariant(tile) * 64 + image + condition; |
3e655c6e0914
(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
|
1060 |
} |
3575
f5b56bd958c0
(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
|
1061 |
|
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1062 |
AddSortableSpriteToDraw(sprite, PAL_NONE, x, y, 1, 1, 10, GetSlopeZ(x,y)); |
0 | 1063 |
} |
1064 |
||
1065 |
static uint32 _drawtile_track_palette; |
|
1066 |
||
1067 |
||
2436
7d5df545bd5d
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
1068 |
static void DrawTrackFence_NW(const TileInfo *ti) |
0 | 1069 |
{ |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1070 |
SpriteID image = 0x515; |
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
1071 |
if (ti->tileh != SLOPE_FLAT) image = (ti->tileh & SLOPE_S) ? 0x519 : 0x51B; |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1072 |
AddSortableSpriteToDraw(image, _drawtile_track_palette, |
2951 | 1073 |
ti->x, ti->y + 1, 16, 1, 4, ti->z); |
0 | 1074 |
} |
1075 |
||
2436
7d5df545bd5d
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
1076 |
static void DrawTrackFence_SE(const TileInfo *ti) |
0 | 1077 |
{ |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1078 |
SpriteID image = 0x515; |
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
1079 |
if (ti->tileh != SLOPE_FLAT) image = (ti->tileh & SLOPE_S) ? 0x519 : 0x51B; |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1080 |
AddSortableSpriteToDraw(image, _drawtile_track_palette, |
3645
7f950533d510
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3638
diff
changeset
|
1081 |
ti->x, ti->y + TILE_SIZE - 1, 16, 1, 4, ti->z); |
0 | 1082 |
} |
1083 |
||
2436
7d5df545bd5d
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
1084 |
static void DrawTrackFence_NW_SE(const TileInfo *ti) |
0 | 1085 |
{ |
1086 |
DrawTrackFence_NW(ti); |
|
1087 |
DrawTrackFence_SE(ti); |
|
1088 |
} |
|
1089 |
||
2436
7d5df545bd5d
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
1090 |
static void DrawTrackFence_NE(const TileInfo *ti) |
0 | 1091 |
{ |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1092 |
SpriteID image = 0x516; |
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
1093 |
if (ti->tileh != SLOPE_FLAT) image = (ti->tileh & SLOPE_S) ? 0x51A : 0x51C; |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1094 |
AddSortableSpriteToDraw(image, _drawtile_track_palette, |
2951 | 1095 |
ti->x + 1, ti->y, 1, 16, 4, ti->z); |
0 | 1096 |
} |
1097 |
||
2436
7d5df545bd5d
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
1098 |
static void DrawTrackFence_SW(const TileInfo *ti) |
0 | 1099 |
{ |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1100 |
SpriteID image = 0x516; |
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
1101 |
if (ti->tileh != SLOPE_FLAT) image = (ti->tileh & SLOPE_S) ? 0x51A : 0x51C; |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1102 |
AddSortableSpriteToDraw(image, _drawtile_track_palette, |
3645
7f950533d510
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3638
diff
changeset
|
1103 |
ti->x + TILE_SIZE - 1, ti->y, 1, 16, 4, ti->z); |
0 | 1104 |
} |
1105 |
||
2436
7d5df545bd5d
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
1106 |
static void DrawTrackFence_NE_SW(const TileInfo *ti) |
0 | 1107 |
{ |
1108 |
DrawTrackFence_NE(ti); |
|
1109 |
DrawTrackFence_SW(ti); |
|
1110 |
} |
|
1111 |
||
2436
7d5df545bd5d
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
1112 |
static void DrawTrackFence_NS_1(const TileInfo *ti) |
0 | 1113 |
{ |
1114 |
int z = ti->z; |
|
3645
7f950533d510
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3638
diff
changeset
|
1115 |
if (ti->tileh & SLOPE_W) z += TILE_HEIGHT; |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1116 |
AddSortableSpriteToDraw(0x517, _drawtile_track_palette, |
3645
7f950533d510
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3638
diff
changeset
|
1117 |
ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z); |
0 | 1118 |
} |
1119 |
||
2436
7d5df545bd5d
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
1120 |
static void DrawTrackFence_NS_2(const TileInfo *ti) |
0 | 1121 |
{ |
1122 |
int z = ti->z; |
|
3645
7f950533d510
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3638
diff
changeset
|
1123 |
if (ti->tileh & SLOPE_E) z += TILE_HEIGHT; |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1124 |
AddSortableSpriteToDraw(0x517, _drawtile_track_palette, |
3645
7f950533d510
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3638
diff
changeset
|
1125 |
ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z); |
0 | 1126 |
} |
1127 |
||
2436
7d5df545bd5d
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
1128 |
static void DrawTrackFence_WE_1(const TileInfo *ti) |
0 | 1129 |
{ |
1130 |
int z = ti->z; |
|
3645
7f950533d510
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3638
diff
changeset
|
1131 |
if (ti->tileh & SLOPE_N) z += TILE_HEIGHT; |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1132 |
AddSortableSpriteToDraw(0x518, _drawtile_track_palette, |
3645
7f950533d510
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3638
diff
changeset
|
1133 |
ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z); |
0 | 1134 |
} |
1135 |
||
2436
7d5df545bd5d
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
1136 |
static void DrawTrackFence_WE_2(const TileInfo *ti) |
0 | 1137 |
{ |
1138 |
int z = ti->z; |
|
3645
7f950533d510
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3638
diff
changeset
|
1139 |
if (ti->tileh & SLOPE_S) z += TILE_HEIGHT; |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1140 |
AddSortableSpriteToDraw(0x518, _drawtile_track_palette, |
3645
7f950533d510
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3638
diff
changeset
|
1141 |
ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 4, z); |
0 | 1142 |
} |
1143 |
||
4040
921eabdb0283
(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
|
1144 |
|
921eabdb0283
(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
|
1145 |
static void DrawTrackDetails(const TileInfo* ti) |
0 | 1146 |
{ |
4040
921eabdb0283
(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
|
1147 |
switch (GetRailGroundType(ti->tile)) { |
921eabdb0283
(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
|
1148 |
case RAIL_GROUND_FENCE_NW: DrawTrackFence_NW(ti); break; |
921eabdb0283
(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
|
1149 |
case RAIL_GROUND_FENCE_SE: DrawTrackFence_SE(ti); break; |
921eabdb0283
(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
|
1150 |
case RAIL_GROUND_FENCE_SENW: DrawTrackFence_NW_SE(ti); break; |
921eabdb0283
(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
|
1151 |
case RAIL_GROUND_FENCE_NE: DrawTrackFence_NE(ti); break; |
921eabdb0283
(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
|
1152 |
case RAIL_GROUND_FENCE_SW: DrawTrackFence_SW(ti); break; |
921eabdb0283
(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
|
1153 |
case RAIL_GROUND_FENCE_NESW: DrawTrackFence_NE_SW(ti); break; |
921eabdb0283
(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
|
1154 |
case RAIL_GROUND_FENCE_VERT1: DrawTrackFence_NS_1(ti); break; |
921eabdb0283
(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
|
1155 |
case RAIL_GROUND_FENCE_VERT2: DrawTrackFence_NS_2(ti); break; |
921eabdb0283
(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
|
1156 |
case RAIL_GROUND_FENCE_HORIZ1: DrawTrackFence_WE_1(ti); break; |
921eabdb0283
(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
|
1157 |
case RAIL_GROUND_FENCE_HORIZ2: DrawTrackFence_WE_2(ti); break; |
921eabdb0283
(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
|
1158 |
default: break; |
921eabdb0283
(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
|
1159 |
} |
0 | 1160 |
} |
1161 |
||
1162 |
||
2472
2711a54b0498
(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
|
1163 |
/** |
2711a54b0498
(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
|
1164 |
* Draw ground sprite and track bits |
2711a54b0498
(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
|
1165 |
* @param ti TileInfo |
2711a54b0498
(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
|
1166 |
* @param track TrackBits to draw |
2711a54b0498
(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
|
1167 |
* @param earth Draw as earth |
2711a54b0498
(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
|
1168 |
* @param snow Draw as snow |
2711a54b0498
(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
|
1169 |
* @param flat Always draw foundation |
2711a54b0498
(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
|
1170 |
*/ |
4081 | 1171 |
static void DrawTrackBits(TileInfo* ti, TrackBits track) |
2472
2711a54b0498
(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
|
1172 |
{ |
2711a54b0498
(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
|
1173 |
const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile)); |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1174 |
SpriteID image; |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1175 |
SpriteID pal = PAL_NONE; |
2472
2711a54b0498
(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
|
1176 |
bool junction = false; |
2711a54b0498
(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
|
1177 |
|
2711a54b0498
(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
|
1178 |
// Select the sprite to use. |
3102
f9ca4379db9d
(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
|
1179 |
(image = rti->base_sprites.track_y, track == TRACK_BIT_Y) || |
f9ca4379db9d
(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
|
1180 |
(image++, track == TRACK_BIT_X) || |
2472
2711a54b0498
(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
|
1181 |
(image++, track == TRACK_BIT_UPPER) || |
2711a54b0498
(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
|
1182 |
(image++, track == TRACK_BIT_LOWER) || |
2711a54b0498
(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
|
1183 |
(image++, track == TRACK_BIT_RIGHT) || |
2711a54b0498
(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
|
1184 |
(image++, track == TRACK_BIT_LEFT) || |
3258
1c079364726d
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
1185 |
(image++, track == TRACK_BIT_CROSS) || |
2472
2711a54b0498
(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
|
1186 |
|
3258
1c079364726d
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
1187 |
(image = rti->base_sprites.track_ns, track == TRACK_BIT_HORZ) || |
1c079364726d
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
1188 |
(image++, track == TRACK_BIT_VERT) || |
2472
2711a54b0498
(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
|
1189 |
|
2711a54b0498
(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
|
1190 |
(junction = true, false) || |
3258
1c079364726d
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
1191 |
(image = rti->base_sprites.ground, (track & TRACK_BIT_3WAY_NE) == 0) || |
1c079364726d
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
1192 |
(image++, (track & TRACK_BIT_3WAY_SW) == 0) || |
1c079364726d
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
1193 |
(image++, (track & TRACK_BIT_3WAY_NW) == 0) || |
1c079364726d
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
1194 |
(image++, (track & TRACK_BIT_3WAY_SE) == 0) || |
2472
2711a54b0498
(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
|
1195 |
(image++, true); |
2711a54b0498
(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
|
1196 |
|
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
1197 |
if (ti->tileh != SLOPE_FLAT) { |
4081 | 1198 |
uint foundation = GetRailFoundation(ti->tileh, track); |
2472
2711a54b0498
(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
|
1199 |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
1200 |
if (foundation != 0) DrawFoundation(ti, foundation); |
2472
2711a54b0498
(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
|
1201 |
|
2711a54b0498
(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
|
1202 |
// DrawFoundation() modifies ti. |
2711a54b0498
(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
|
1203 |
// Default sloped sprites.. |
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
1204 |
if (ti->tileh != SLOPE_FLAT) |
2472
2711a54b0498
(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
|
1205 |
image = _track_sloped_sprites[ti->tileh - 1] + rti->base_sprites.track_y; |
2711a54b0498
(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
|
1206 |
} |
2711a54b0498
(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
|
1207 |
|
4466
903dcec7aa88
(svn r6251) Replace 2 bool variables by a simple switch
tron
parents:
4440
diff
changeset
|
1208 |
switch (GetRailGroundType(ti->tile)) { |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1209 |
case RAIL_GROUND_BARREN: pal = PALETTE_TO_BARE_LAND; break; |
4466
903dcec7aa88
(svn r6251) Replace 2 bool variables by a simple switch
tron
parents:
4440
diff
changeset
|
1210 |
case RAIL_GROUND_ICE_DESERT: image += rti->snow_offset; break; |
903dcec7aa88
(svn r6251) Replace 2 bool variables by a simple switch
tron
parents:
4440
diff
changeset
|
1211 |
default: break; |
2472
2711a54b0498
(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
|
1212 |
} |
2711a54b0498
(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
|
1213 |
|
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1214 |
DrawGroundSprite(image, pal); |
2472
2711a54b0498
(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
|
1215 |
|
2711a54b0498
(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
|
1216 |
// Draw track pieces individually for junction tiles |
2711a54b0498
(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
|
1217 |
if (junction) { |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1218 |
if (track & TRACK_BIT_X) DrawGroundSprite(rti->base_sprites.single_y, PAL_NONE); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1219 |
if (track & TRACK_BIT_Y) DrawGroundSprite(rti->base_sprites.single_x, PAL_NONE); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1220 |
if (track & TRACK_BIT_UPPER) DrawGroundSprite(rti->base_sprites.single_n, PAL_NONE); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1221 |
if (track & TRACK_BIT_LOWER) DrawGroundSprite(rti->base_sprites.single_s, PAL_NONE); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1222 |
if (track & TRACK_BIT_LEFT) DrawGroundSprite(rti->base_sprites.single_w, PAL_NONE); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1223 |
if (track & TRACK_BIT_RIGHT) DrawGroundSprite(rti->base_sprites.single_e, PAL_NONE); |
2472
2711a54b0498
(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
|
1224 |
} |
3355
e414a0b104a6
(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
|
1225 |
|
3361
873c035e5a63
(svn r4156) CodeChange : Little cleanup after Celestar's elrail merge
belugas
parents:
3355
diff
changeset
|
1226 |
if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenary(ti); |
3355
e414a0b104a6
(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
|
1227 |
|
2472
2711a54b0498
(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
|
1228 |
} |
2711a54b0498
(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
|
1229 |
|
3519
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1230 |
static void DrawSignals(TileIndex tile, TrackBits rails) |
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1231 |
{ |
3575
f5b56bd958c0
(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
|
1232 |
#define MAYBE_DRAW_SIGNAL(x,y,z) if (IsSignalPresent(tile, x)) DrawSingleSignal(tile, GetSingleSignalState(tile, x), y - 0x4FB, z) |
3519
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1233 |
|
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1234 |
if (!(rails & TRACK_BIT_Y)) { |
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1235 |
if (!(rails & TRACK_BIT_X)) { |
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1236 |
if (rails & TRACK_BIT_LEFT) { |
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1237 |
MAYBE_DRAW_SIGNAL(2, 0x509, 0); |
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1238 |
MAYBE_DRAW_SIGNAL(3, 0x507, 1); |
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1239 |
} |
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1240 |
if (rails & TRACK_BIT_RIGHT) { |
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1241 |
MAYBE_DRAW_SIGNAL(0, 0x509, 2); |
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1242 |
MAYBE_DRAW_SIGNAL(1, 0x507, 3); |
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1243 |
} |
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1244 |
if (rails & TRACK_BIT_UPPER) { |
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1245 |
MAYBE_DRAW_SIGNAL(3, 0x505, 4); |
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1246 |
MAYBE_DRAW_SIGNAL(2, 0x503, 5); |
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1247 |
} |
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1248 |
if (rails & TRACK_BIT_LOWER) { |
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1249 |
MAYBE_DRAW_SIGNAL(1, 0x505, 6); |
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1250 |
MAYBE_DRAW_SIGNAL(0, 0x503, 7); |
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1251 |
} |
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1252 |
} else { |
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1253 |
MAYBE_DRAW_SIGNAL(3, 0x4FB, 8); |
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1254 |
MAYBE_DRAW_SIGNAL(2, 0x4FD, 9); |
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1255 |
} |
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1256 |
} else { |
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1257 |
MAYBE_DRAW_SIGNAL(3, 0x4FF, 10); |
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1258 |
MAYBE_DRAW_SIGNAL(2, 0x501, 11); |
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1259 |
} |
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1260 |
} |
1b8eb174e528
(svn r4375) -Codechange: Move the signal drawing bit to an own function and rename DrawSignalHelper to DrawSingleSignal
celestar
parents:
3507
diff
changeset
|
1261 |
|
0 | 1262 |
static void DrawTile_Track(TileInfo *ti) |
1263 |
{ |
|
2233
ee31c1e1477c
(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
|
1264 |
const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile)); |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1265 |
SpriteID image; |
0 | 1266 |
|
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1267 |
_drawtile_track_palette = PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)); |
0 | 1268 |
|
4182
48dba107ff43
(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
|
1269 |
if (IsPlainRailTile(ti->tile)) { |
3267
feff95208a9f
(svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents:
3265
diff
changeset
|
1270 |
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
|
1271 |
|
4081 | 1272 |
DrawTrackBits(ti, rails); |
2008
cdb444f6d43c
(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
|
1273 |
|
4040
921eabdb0283
(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
|
1274 |
if (_display_opt & DO_FULL_DETAIL) DrawTrackDetails(ti); |
0 | 1275 |
|
4182
48dba107ff43
(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
|
1276 |
if (HasSignals(ti->tile)) DrawSignals(ti->tile, rails); |
0 | 1277 |
} else { |
4225
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1278 |
// draw depot/waypoint |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1279 |
const DrawTileSprites* dts; |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1280 |
const DrawTileSeqStruct* dtss; |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1281 |
uint32 relocation; |
0 | 1282 |
|
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
1283 |
if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh); |
0 | 1284 |
|
4225
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1285 |
if (GetRailTileSubtype(ti->tile) == RAIL_SUBTYPE_DEPOT) { |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1286 |
dts = &_depot_gfx_table[GetRailDepotDirection(ti->tile)]; |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1287 |
|
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1288 |
relocation = rti->total_offset; |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1289 |
|
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1290 |
image = dts->ground_sprite; |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1291 |
if (image != SPR_FLAT_GRASS_TILE) image += rti->total_offset; |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1292 |
|
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1293 |
// adjust ground tile for desert |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1294 |
// don't adjust for snow, because snow in depots looks weird |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1295 |
if (IsSnowRailGround(ti->tile) && _opt.landscape == LT_DESERT) { |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1296 |
if (image != SPR_FLAT_GRASS_TILE) { |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1297 |
image += rti->snow_offset; // tile with tracks |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1298 |
} else { |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1299 |
image = SPR_FLAT_SNOWY_TILE; // flat ground |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1300 |
} |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1301 |
} |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1302 |
} else { |
389
16ee9854091e
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
337
diff
changeset
|
1303 |
// look for customization |
2670
f2d6a8424e3e
(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
|
1304 |
byte stat_id = GetWaypointByTile(ti->tile)->stat_id; |
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3671
diff
changeset
|
1305 |
const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, stat_id); |
389
16ee9854091e
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
337
diff
changeset
|
1306 |
|
3676
680dfa6336a1
(svn r4593) CodeChange : Renamed spec (when using StationSpec) to statspec.
belugas
parents:
3671
diff
changeset
|
1307 |
if (statspec != NULL) { |
403
dc7aef17c13e
(svn r600) -newgrf: Relocation offset for custom station sprites is now stored separately, making it possible to show different sprites in waypoint selection dialog (pasky).
darkvater
parents:
399
diff
changeset
|
1308 |
// emulate station tile - open with building |
4225
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1309 |
const Station* st = ComposeWaypointStation(ti->tile); |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1310 |
uint gfx = 2; |
3757
0c6a690e6b41
(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
|
1311 |
|
0c6a690e6b41
(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
|
1312 |
if (HASBIT(statspec->callbackmask, CBM_CUSTOM_LAYOUT)) { |
0c6a690e6b41
(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
|
1313 |
uint16 callback = GetStationCallback(CBID_STATION_SPRITE_LAYOUT, 0, 0, statspec, st, ti->tile); |
4225
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1314 |
if (callback != CALLBACK_FAILED) gfx = callback; |
3757
0c6a690e6b41
(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
|
1315 |
} |
0c6a690e6b41
(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
|
1316 |
|
3763
7098c393c172
(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
|
1317 |
if (statspec->renderdata == NULL) { |
4225
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1318 |
dts = GetStationTileLayout(gfx); |
3763
7098c393c172
(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
|
1319 |
} else { |
4225
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1320 |
dts = &statspec->renderdata[(gfx < statspec->tiles ? gfx : 0) + GetWaypointAxis(ti->tile)]; |
3763
7098c393c172
(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
|
1321 |
} |
447
7e4bb71b8752
(svn r657) Do not touch 0x8000 bit in sprite index for custom waypoints. (pasky)
celestar
parents:
438
diff
changeset
|
1322 |
|
4225
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1323 |
if (dts != NULL && dts->seq != NULL) { |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1324 |
relocation = GetCustomStationRelocation(statspec, st, ti->tile); |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1325 |
|
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1326 |
image = dts->ground_sprite; |
5738
5e2281cf6258
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5735
diff
changeset
|
1327 |
if (HASBIT(image, SPRITE_MODIFIER_USE_OFFSET)) { |
3775
0fb5118536c3
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3763
diff
changeset
|
1328 |
image += GetCustomStationGroundRelocation(statspec, st, ti->tile); |
0fb5118536c3
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3763
diff
changeset
|
1329 |
image += rti->custom_ground_offset; |
0fb5118536c3
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3763
diff
changeset
|
1330 |
} else { |
0fb5118536c3
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3763
diff
changeset
|
1331 |
image += rti->total_offset; |
0fb5118536c3
(svn r4767) - Newstations: fix loading / use of custom ground sprites
peter1138
parents:
3763
diff
changeset
|
1332 |
} |
4225
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1333 |
} else { |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1334 |
goto default_waypoint; |
389
16ee9854091e
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
337
diff
changeset
|
1335 |
} |
2549 | 1336 |
} else { |
4225
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1337 |
default_waypoint: |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1338 |
// There is no custom layout, fall back to the default graphics |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1339 |
dts = &_waypoint_gfx_table[GetWaypointAxis(ti->tile)]; |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1340 |
relocation = 0; |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1341 |
image = dts->ground_sprite + rti->total_offset; |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1342 |
if (IsSnowRailGround(ti->tile)) image += rti->snow_offset; |
2549 | 1343 |
} |
0 | 1344 |
} |
1345 |
||
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1346 |
DrawGroundSprite(image, PAL_NONE); |
0 | 1347 |
|
3355
e414a0b104a6
(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
|
1348 |
if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenary(ti); |
e414a0b104a6
(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
|
1349 |
|
4225
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1350 |
foreach_draw_tile_seq(dtss, dts->seq) { |
5738
5e2281cf6258
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5735
diff
changeset
|
1351 |
SpriteID image = dtss->image; |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1352 |
SpriteID pal; |
4225
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1353 |
|
5738
5e2281cf6258
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5735
diff
changeset
|
1354 |
/* Unlike stations, our default waypoint has no variation for |
5e2281cf6258
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5735
diff
changeset
|
1355 |
* different railtype, so don't use the railtype offset if |
5e2281cf6258
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5735
diff
changeset
|
1356 |
* no relocation is set */ |
5e2281cf6258
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5735
diff
changeset
|
1357 |
if (HASBIT(image, SPRITE_MODIFIER_USE_OFFSET)) { |
5e2281cf6258
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5735
diff
changeset
|
1358 |
image += rti->total_offset; |
5e2281cf6258
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5735
diff
changeset
|
1359 |
} else { |
5e2281cf6258
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5735
diff
changeset
|
1360 |
image += relocation; |
5e2281cf6258
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5735
diff
changeset
|
1361 |
} |
5e2281cf6258
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5735
diff
changeset
|
1362 |
|
4225
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1363 |
if (_display_opt & DO_TRANS_BUILDINGS) { |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1364 |
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1365 |
pal = PALETTE_TO_TRANSPARENT; |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1366 |
} else if (HASBIT(image, PALETTE_MODIFIER_COLOR)) { |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1367 |
pal = _drawtile_track_palette; |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1368 |
} else { |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1369 |
pal = dtss->pal; |
4225
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1370 |
} |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1371 |
|
5738
5e2281cf6258
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5735
diff
changeset
|
1372 |
if ((byte)dtss->delta_z != 0x80) { |
5e2281cf6258
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5735
diff
changeset
|
1373 |
AddSortableSpriteToDraw( |
5e2281cf6258
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5735
diff
changeset
|
1374 |
image, pal, |
5e2281cf6258
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5735
diff
changeset
|
1375 |
ti->x + dtss->delta_x, ti->y + dtss->delta_y, |
5e2281cf6258
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5735
diff
changeset
|
1376 |
dtss->size_x, dtss->size_y, |
5e2281cf6258
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5735
diff
changeset
|
1377 |
dtss->size_z, ti->z + dtss->delta_z |
5e2281cf6258
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5735
diff
changeset
|
1378 |
); |
5e2281cf6258
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5735
diff
changeset
|
1379 |
} else { |
5e2281cf6258
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5735
diff
changeset
|
1380 |
AddChildSpriteScreen(image, pal, dtss->delta_x, dtss->delta_y); |
5e2281cf6258
(svn r8283) -Fix (r8128): Custom waypoint drawing used wrong bits since bitshuffling occurred. Also update with other station drawing changes (code duplication,
peter1138
parents:
5735
diff
changeset
|
1381 |
} |
0 | 1382 |
} |
1383 |
} |
|
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5380
diff
changeset
|
1384 |
DrawBridgeMiddle(ti); |
0 | 1385 |
} |
1386 |
||
1387 |
||
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1388 |
static void DrawTileSequence(int x, int y, SpriteID ground, const DrawTileSeqStruct* dtss, uint32 offset) |
4225
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1389 |
{ |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1390 |
SpriteID palette = PLAYER_SPRITE_COLOR(_local_player); |
0 | 1391 |
|
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1392 |
DrawSprite(ground, PAL_NONE, x, y); |
4225
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1393 |
for (; dtss->image != 0; dtss++) { |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1394 |
Point pt = RemapCoords(dtss->delta_x, dtss->delta_y, dtss->delta_z); |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1395 |
SpriteID image = dtss->image + offset; |
0 | 1396 |
|
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1397 |
DrawSprite(image, HASBIT(image, PALETTE_MODIFIER_COLOR) ? palette : PAL_NONE, x + pt.x, y + pt.y); |
0 | 1398 |
} |
1399 |
} |
|
1400 |
||
4225
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1401 |
void DrawTrainDepotSprite(int x, int y, int dir, RailType railtype) |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1402 |
{ |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1403 |
const DrawTileSprites* dts = &_depot_gfx_table[dir]; |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5598
diff
changeset
|
1404 |
SpriteID image = dts->ground_sprite; |
4225
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1405 |
uint32 offset = GetRailTypeInfo(railtype)->total_offset; |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1406 |
|
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1407 |
if (image != SPR_FLAT_GRASS_TILE) image += offset; |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1408 |
DrawTileSequence(x + 33, y + 17, image, dts->seq, offset); |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1409 |
} |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1410 |
|
2520
8a52362c4ada
(svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents:
2502
diff
changeset
|
1411 |
void DrawDefaultWaypointSprite(int x, int y, RailType railtype) |
2261
d3554e5d3e86
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2254
diff
changeset
|
1412 |
{ |
4225
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1413 |
uint32 offset = GetRailTypeInfo(railtype)->total_offset; |
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1414 |
const DrawTileSprites* dts = &_waypoint_gfx_table[AXIS_X]; |
2261
d3554e5d3e86
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2254
diff
changeset
|
1415 |
|
4225
88d760a6a4bf
(svn r5771) Unify several code paths and data structures for drawing train depots and waypoints
tron
parents:
4182
diff
changeset
|
1416 |
DrawTileSequence(x, y, dts->ground_sprite + offset, dts->seq, 0); |
2261
d3554e5d3e86
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2254
diff
changeset
|
1417 |
} |
d3554e5d3e86
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2254
diff
changeset
|
1418 |
|
0 | 1419 |
typedef struct SetSignalsData { |
1420 |
int cur; |
|
1421 |
int cur_stack; |
|
1422 |
bool stop; |
|
1423 |
bool has_presignal; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1424 |
|
0 | 1425 |
// presignal info |
1426 |
int presignal_exits; |
|
1427 |
int presignal_exits_free; |
|
1428 |
||
1429 |
// these are used to keep track of the signals that change. |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
1430 |
TrackdirByte bit[NUM_SSD_ENTRY]; |
0 | 1431 |
TileIndex tile[NUM_SSD_ENTRY]; |
1432 |
||
1433 |
// these are used to keep track of the stack that modifies presignals recursively |
|
1434 |
TileIndex next_tile[NUM_SSD_STACK]; |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
1435 |
DiagDirectionByte next_dir[NUM_SSD_STACK]; |
0 | 1436 |
|
1437 |
} SetSignalsData; |
|
1438 |
||
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
1439 |
static bool SetSignalsEnumProc(TileIndex tile, void* data, Trackdir trackdir, uint length, byte* state) |
0 | 1440 |
{ |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
1441 |
SetSignalsData* ssd = (SetSignalsData*)data; |
4479 | 1442 |
|
3017
a75caf4efa2d
(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
|
1443 |
if (!IsTileType(tile, MP_RAILWAY)) return false; |
a75caf4efa2d
(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
|
1444 |
|
0 | 1445 |
// the tile has signals? |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
1446 |
if (HasSignalOnTrack(tile, TrackdirToTrack(trackdir))) { |
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
1447 |
if (HasSignalOnTrackdir(tile, ReverseTrackdir(trackdir))) { |
3017
a75caf4efa2d
(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
|
1448 |
// yes, add the signal to the list of signals |
a75caf4efa2d
(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
|
1449 |
if (ssd->cur != NUM_SSD_ENTRY) { |
a75caf4efa2d
(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
|
1450 |
ssd->tile[ssd->cur] = tile; // remember the tile index |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
1451 |
ssd->bit[ssd->cur] = trackdir; // and the controlling bit number |
3017
a75caf4efa2d
(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
|
1452 |
ssd->cur++; |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
1453 |
} |
0 | 1454 |
|
3017
a75caf4efa2d
(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
|
1455 |
// remember if this block has a presignal. |
3521
addbba7b20ff
(svn r4377) -Add and make use of a function that finds out whether a signal is an entry or and exit signal to a presignal block (as combos act as both)
celestar
parents:
3520
diff
changeset
|
1456 |
ssd->has_presignal |= IsPresignalEntry(tile); |
3017
a75caf4efa2d
(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
|
1457 |
} |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
1458 |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
1459 |
if (HasSignalOnTrackdir(tile, trackdir) && IsPresignalExit(tile)) { |
3017
a75caf4efa2d
(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
|
1460 |
// this is an exit signal that points out from the segment |
a75caf4efa2d
(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
|
1461 |
ssd->presignal_exits++; |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
1462 |
if (GetSignalStateByTrackdir(tile, trackdir) != SIGNAL_STATE_RED) |
3017
a75caf4efa2d
(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
|
1463 |
ssd->presignal_exits_free++; |
2549 | 1464 |
} |
3017
a75caf4efa2d
(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
|
1465 |
|
a75caf4efa2d
(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
|
1466 |
return true; |
a75caf4efa2d
(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
|
1467 |
} else if (IsTileDepotType(tile, TRANSPORT_RAIL)) { |
a75caf4efa2d
(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
|
1468 |
return true; // don't look further if the tile is a depot |
0 | 1469 |
} |
3017
a75caf4efa2d
(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
|
1470 |
|
0 | 1471 |
return false; |
1472 |
} |
|
1473 |
||
1555
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1474 |
/* Struct to parse data from VehicleFromPos to SignalVehicleCheckProc */ |
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1475 |
typedef struct SignalVehicleCheckStruct { |
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1476 |
TileIndex tile; |
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1477 |
uint track; |
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1478 |
} SignalVehicleCheckStruct; |
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1479 |
|
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1480 |
static void *SignalVehicleCheckProc(Vehicle *v, void *data) |
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1481 |
{ |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
1482 |
const SignalVehicleCheckStruct* dest = (SignalVehicleCheckStruct*)data; |
1555
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1483 |
|
2549 | 1484 |
if (v->type != VEH_Train) return NULL; |
1609
108c0501019e
(svn r2113) -Fix: first check if a vehicle is a train, before accessing u.rail
truelight
parents:
1598
diff
changeset
|
1485 |
|
1555
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1486 |
/* Wrong tile, or no train? Not a match */ |
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5380
diff
changeset
|
1487 |
if (v->tile != dest->tile) return NULL; |
1555
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1488 |
|
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1489 |
/* Are we on the same piece of track? */ |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
1490 |
if (dest->track & v->u.rail.track * 0x101) return v; |
1555
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1491 |
|
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1492 |
return NULL; |
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1493 |
} |
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1494 |
|
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1495 |
/* Special check for SetSignalsAfterProc, to see if there is a vehicle on this tile */ |
2752 | 1496 |
static bool SignalVehicleCheck(TileIndex tile, uint track) |
1555
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1497 |
{ |
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1498 |
SignalVehicleCheckStruct dest; |
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1499 |
|
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1500 |
dest.tile = tile; |
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1501 |
dest.track = track; |
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1502 |
|
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5380
diff
changeset
|
1503 |
/* Locate vehicles in tunnels or on bridges */ |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5380
diff
changeset
|
1504 |
if (IsTunnelTile(tile) || IsBridgeTile(tile)) { |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5380
diff
changeset
|
1505 |
TileIndex end; |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5380
diff
changeset
|
1506 |
DiagDirection direction; |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5380
diff
changeset
|
1507 |
|
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5380
diff
changeset
|
1508 |
if (IsTunnelTile(tile)) { |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5380
diff
changeset
|
1509 |
end = GetOtherTunnelEnd(tile); |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5380
diff
changeset
|
1510 |
direction = GetTunnelDirection(tile); |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5380
diff
changeset
|
1511 |
} else { |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5380
diff
changeset
|
1512 |
end = GetOtherBridgeEnd(tile); |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5380
diff
changeset
|
1513 |
direction = GetBridgeRampDirection(tile); |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5380
diff
changeset
|
1514 |
} |
3154 | 1515 |
|
1816
732d82acc97e
(svn r2320) - Fix: [ 1185176 ] Train in tunnel is not properly detected by signal code (Hackykid)
matthijs
parents:
1813
diff
changeset
|
1516 |
dest.track = 1 << (direction & 1); // get the trackbit the vehicle would have if it has not entered the tunnel yet (ie is still visible) |
732d82acc97e
(svn r2320) - Fix: [ 1185176 ] Train in tunnel is not properly detected by signal code (Hackykid)
matthijs
parents:
1813
diff
changeset
|
1517 |
|
732d82acc97e
(svn r2320) - Fix: [ 1185176 ] Train in tunnel is not properly detected by signal code (Hackykid)
matthijs
parents:
1813
diff
changeset
|
1518 |
// check for a vehicle with that trackdir on the start tile of the tunnel |
1818
56af6f0d6123
(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
|
1519 |
if (VehicleFromPos(tile, &dest, SignalVehicleCheckProc) != NULL) return true; |
1816
732d82acc97e
(svn r2320) - Fix: [ 1185176 ] Train in tunnel is not properly detected by signal code (Hackykid)
matthijs
parents:
1813
diff
changeset
|
1520 |
|
732d82acc97e
(svn r2320) - Fix: [ 1185176 ] Train in tunnel is not properly detected by signal code (Hackykid)
matthijs
parents:
1813
diff
changeset
|
1521 |
// check for a vehicle with that trackdir on the end tile of the tunnel |
3154 | 1522 |
if (VehicleFromPos(end, &dest, SignalVehicleCheckProc) != NULL) return true; |
1816
732d82acc97e
(svn r2320) - Fix: [ 1185176 ] Train in tunnel is not properly detected by signal code (Hackykid)
matthijs
parents:
1813
diff
changeset
|
1523 |
|
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5380
diff
changeset
|
1524 |
// now check all tiles from start to end for a warping vehicle |
1816
732d82acc97e
(svn r2320) - Fix: [ 1185176 ] Train in tunnel is not properly detected by signal code (Hackykid)
matthijs
parents:
1813
diff
changeset
|
1525 |
// NOTE: the hashes for tiles may overlap, so this could maybe be optimised a bit by not checking every tile? |
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5380
diff
changeset
|
1526 |
dest.track = 0x40; //Vehicle inside a tunnel or on a bridge |
4559
aa0c13e39840
(svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents:
4556
diff
changeset
|
1527 |
for (; tile != end; tile += TileOffsByDiagDir(direction)) { |
1816
732d82acc97e
(svn r2320) - Fix: [ 1185176 ] Train in tunnel is not properly detected by signal code (Hackykid)
matthijs
parents:
1813
diff
changeset
|
1528 |
if (VehicleFromPos(tile, &dest, SignalVehicleCheckProc) != NULL) |
732d82acc97e
(svn r2320) - Fix: [ 1185176 ] Train in tunnel is not properly detected by signal code (Hackykid)
matthijs
parents:
1813
diff
changeset
|
1529 |
return true; |
732d82acc97e
(svn r2320) - Fix: [ 1185176 ] Train in tunnel is not properly detected by signal code (Hackykid)
matthijs
parents:
1813
diff
changeset
|
1530 |
} |
732d82acc97e
(svn r2320) - Fix: [ 1185176 ] Train in tunnel is not properly detected by signal code (Hackykid)
matthijs
parents:
1813
diff
changeset
|
1531 |
|
732d82acc97e
(svn r2320) - Fix: [ 1185176 ] Train in tunnel is not properly detected by signal code (Hackykid)
matthijs
parents:
1813
diff
changeset
|
1532 |
// no vehicle found |
732d82acc97e
(svn r2320) - Fix: [ 1185176 ] Train in tunnel is not properly detected by signal code (Hackykid)
matthijs
parents:
1813
diff
changeset
|
1533 |
return false; |
1818
56af6f0d6123
(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
|
1534 |
} |
56af6f0d6123
(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
|
1535 |
|
56af6f0d6123
(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
|
1536 |
return VehicleFromPos(tile, &dest, SignalVehicleCheckProc) != NULL; |
1555
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1537 |
} |
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1538 |
|
0 | 1539 |
static void SetSignalsAfterProc(TrackPathFinder *tpf) |
1540 |
{ |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
1541 |
SetSignalsData *ssd = (SetSignalsData*)tpf->userdata; |
2548
49c8a096033f
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2544
diff
changeset
|
1542 |
const TrackPathFinderLink* link; |
1555
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1543 |
uint offs; |
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1544 |
uint i; |
0 | 1545 |
|
1546 |
ssd->stop = false; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1547 |
|
1555
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1548 |
/* Go through all the PF tiles */ |
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1549 |
for (i = 0; i < lengthof(tpf->hash_head); i++) { |
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1550 |
/* Empty hash item */ |
2639 | 1551 |
if (tpf->hash_head[i] == 0) continue; |
0 | 1552 |
|
1555
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1553 |
/* If 0x8000 is not set, there is only 1 item */ |
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1554 |
if (!(tpf->hash_head[i] & 0x8000)) { |
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1555 |
/* Check if there is a vehicle on this tile */ |
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1556 |
if (SignalVehicleCheck(tpf->hash_tile[i], tpf->hash_head[i])) { |
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1557 |
ssd->stop = true; |
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1558 |
return; |
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1559 |
} |
0 | 1560 |
} else { |
1555
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1561 |
/* There are multiple items, where hash_tile points to the first item in the list */ |
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1562 |
offs = tpf->hash_tile[i]; |
0 | 1563 |
do { |
1555
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1564 |
/* Find the next item */ |
0 | 1565 |
link = PATHFIND_GET_LINK_PTR(tpf, offs); |
1555
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1566 |
/* Check if there is a vehicle on this tile */ |
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1567 |
if (SignalVehicleCheck(link->tile, link->flags)) { |
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1568 |
ssd->stop = true; |
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1569 |
return; |
0 | 1570 |
} |
1555
7259e8f70267
(svn r2059) -Codechange: rewrote SetSignalsAfterProc so now the tiles from the PF
truelight
parents:
1542
diff
changeset
|
1571 |
/* Goto the next item */ |
2951 | 1572 |
} while ((offs = link->next) != 0xFFFF); |
0 | 1573 |
} |
1574 |
} |
|
1575 |
} |
|
1576 |
||
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
1577 |
static const DiagDirection _dir_from_track[14] = { |
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
1578 |
DIAGDIR_NE, DIAGDIR_SE, DIAGDIR_NE, DIAGDIR_SE, DIAGDIR_SW, DIAGDIR_SE, DIAGDIR_NE, DIAGDIR_NE, |
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
1579 |
DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_NW, DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_NE, |
0 | 1580 |
}; |
1581 |
||
1582 |
||
1583 |
static void ChangeSignalStates(SetSignalsData *ssd) |
|
1584 |
{ |
|
1585 |
int i; |
|
1586 |
||
1587 |
// thinking about presignals... |
|
1588 |
// the presignal is green if, |
|
1589 |
// if no train is in the segment AND |
|
1590 |
// there is at least one green exit signal OR |
|
1591 |
// there are no exit signals in the segment |
|
1592 |
||
1593 |
// then mark the signals in the segment accordingly |
|
2549 | 1594 |
for (i = 0; i != ssd->cur; i++) { |
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1963
diff
changeset
|
1595 |
TileIndex tile = ssd->tile[i]; |
2821
cb5abbcc0f0c
(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
|
1596 |
byte bit = SignalAgainstTrackdir(ssd->bit[i]); |
2049
538e73c53f54
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2020
diff
changeset
|
1597 |
uint16 m2 = _m[tile].m2; |
0 | 1598 |
|
1599 |
// presignals don't turn green if there is at least one presignal exit and none are free |
|
3521
addbba7b20ff
(svn r4377) -Add and make use of a function that finds out whether a signal is an entry or and exit signal to a presignal block (as combos act as both)
celestar
parents:
3520
diff
changeset
|
1600 |
if (IsPresignalEntry(tile)) { |
0 | 1601 |
int ex = ssd->presignal_exits, exfree = ssd->presignal_exits_free; |
1602 |
||
1603 |
// subtract for dual combo signals so they don't count themselves |
|
3521
addbba7b20ff
(svn r4377) -Add and make use of a function that finds out whether a signal is an entry or and exit signal to a presignal block (as combos act as both)
celestar
parents:
3520
diff
changeset
|
1604 |
if (IsPresignalExit(tile) && HasSignalOnTrackdir(tile, ssd->bit[i])) { |
0 | 1605 |
ex--; |
3520
a288391e66a3
(svn r4376) -Codechange Renamed GetSignalState to GetSignalStateByTrackdir
celestar
parents:
3519
diff
changeset
|
1606 |
if (GetSignalStateByTrackdir(tile, ssd->bit[i]) != SIGNAL_STATE_RED) exfree--; |
0 | 1607 |
} |
1608 |
||
1609 |
// if we have exits and none are free, make red. |
|
1610 |
if (ex && !exfree) goto make_red; |
|
1611 |
} |
|
1612 |
||
1613 |
// check if the signal is unaffected. |
|
1614 |
if (ssd->stop) { |
|
1615 |
make_red: |
|
1616 |
// turn red |
|
2951 | 1617 |
if ((bit & m2) == 0) continue; |
0 | 1618 |
} else { |
1619 |
// turn green |
|
2951 | 1620 |
if ((bit & m2) != 0) continue; |
0 | 1621 |
} |
1622 |
||
1813
f41543d443b0
(svn r2317) - Fix: [ 1193048 ] Pre-signal stays red when there is only a single exit signal (dinno)
Darkvater
parents:
1796
diff
changeset
|
1623 |
/* Update signals on the other side of this exit-combo signal; it changed. */ |
3521
addbba7b20ff
(svn r4377) -Add and make use of a function that finds out whether a signal is an entry or and exit signal to a presignal block (as combos act as both)
celestar
parents:
3520
diff
changeset
|
1624 |
if (IsPresignalExit(tile)) { |
0 | 1625 |
if (ssd->cur_stack != NUM_SSD_STACK) { |
1626 |
ssd->next_tile[ssd->cur_stack] = tile; |
|
1627 |
ssd->next_dir[ssd->cur_stack] = _dir_from_track[ssd->bit[i]]; |
|
1628 |
ssd->cur_stack++; |
|
1629 |
} else { |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5198
diff
changeset
|
1630 |
DEBUG(misc, 0, "NUM_SSD_STACK too small"); /// @todo WTF is this??? |
0 | 1631 |
} |
1632 |
} |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1633 |
|
0 | 1634 |
// it changed, so toggle it |
2049
538e73c53f54
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2020
diff
changeset
|
1635 |
_m[tile].m2 = m2 ^ bit; |
0 | 1636 |
MarkTileDirtyByTile(tile); |
1637 |
} |
|
1638 |
} |
|
1639 |
||
1640 |
||
3172
ade284ef48ed
(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
|
1641 |
bool UpdateSignalsOnSegment(TileIndex tile, DiagDirection direction) |
0 | 1642 |
{ |
1643 |
SetSignalsData ssd; |
|
1644 |
int result = -1; |
|
1645 |
||
1646 |
ssd.cur_stack = 0; |
|
1647 |
||
2951 | 1648 |
for (;;) { |
0 | 1649 |
// go through one segment and update all signals pointing into that segment. |
2916
b687477adcba
(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
|
1650 |
ssd.cur = ssd.presignal_exits = ssd.presignal_exits_free = 0; |
0 | 1651 |
ssd.has_presignal = false; |
1652 |
||
4479 | 1653 |
FollowTrack(tile, 0xC000 | TRANSPORT_RAIL, direction, SetSignalsEnumProc, SetSignalsAfterProc, &ssd); |
0 | 1654 |
ChangeSignalStates(&ssd); |
1655 |
||
1656 |
// remember the result only for the first iteration. |
|
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
1657 |
if (result < 0) { |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
1658 |
// stay in depot while segment is occupied or while all presignal exits are blocked |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
1659 |
result = ssd.stop || (ssd.presignal_exits > 0 && ssd.presignal_exits_free == 0); |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3884
diff
changeset
|
1660 |
} |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1661 |
|
0 | 1662 |
// if any exit signals were changed, we need to keep going to modify the stuff behind those. |
2639 | 1663 |
if (ssd.cur_stack == 0) break; |
0 | 1664 |
|
1665 |
// one or more exit signals were changed, so we need to update another segment too. |
|
1666 |
tile = ssd.next_tile[--ssd.cur_stack]; |
|
1667 |
direction = ssd.next_dir[ssd.cur_stack]; |
|
1668 |
} |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1669 |
|
3017
a75caf4efa2d
(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
|
1670 |
return result != 0; |
0 | 1671 |
} |
1672 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1963
diff
changeset
|
1673 |
void SetSignalsOnBothDir(TileIndex tile, byte track) |
0 | 1674 |
{ |
3172
ade284ef48ed
(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
|
1675 |
static const DiagDirection _search_dir_1[] = { |
ade284ef48ed
(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
|
1676 |
DIAGDIR_NE, DIAGDIR_SE, DIAGDIR_NE, DIAGDIR_SE, DIAGDIR_SW, DIAGDIR_SE |
ade284ef48ed
(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
|
1677 |
}; |
ade284ef48ed
(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
|
1678 |
static const DiagDirection _search_dir_2[] = { |
ade284ef48ed
(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
|
1679 |
DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_NW, DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_NE |
ade284ef48ed
(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
|
1680 |
}; |
0 | 1681 |
|
1682 |
UpdateSignalsOnSegment(tile, _search_dir_1[track]); |
|
1683 |
UpdateSignalsOnSegment(tile, _search_dir_2[track]); |
|
1684 |
} |
|
1685 |
||
4231
2823b3643862
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4230
diff
changeset
|
1686 |
static uint GetSlopeZ_Track(TileIndex tile, uint x, uint y) |
0 | 1687 |
{ |
4231
2823b3643862
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4230
diff
changeset
|
1688 |
uint z; |
2823b3643862
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4230
diff
changeset
|
1689 |
Slope tileh = GetTileSlope(tile, &z); |
2951 | 1690 |
|
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
1691 |
if (tileh == SLOPE_FLAT) return z; |
4231
2823b3643862
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4230
diff
changeset
|
1692 |
if (IsPlainRailTile(tile)) { |
2823b3643862
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4230
diff
changeset
|
1693 |
uint f = GetRailFoundation(tileh, GetTrackBits(tile)); |
3286
5177aab0ec21
(svn r4000) Rewrite GetSlope{Tileh,Z}_{Road,Track} in a less confusing way
tron
parents:
3284
diff
changeset
|
1694 |
|
5177aab0ec21
(svn r4000) Rewrite GetSlope{Tileh,Z}_{Road,Track} in a less confusing way
tron
parents:
3284
diff
changeset
|
1695 |
if (f != 0) { |
4246
6dcc0e44a367
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
1696 |
if (IsSteepSlope(tileh)) { |
6dcc0e44a367
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
1697 |
z += TILE_HEIGHT; |
6dcc0e44a367
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
1698 |
} else if (f < 15) { |
6dcc0e44a367
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
1699 |
return z + TILE_HEIGHT; // leveled foundation |
6dcc0e44a367
(svn r5833) -Feature: Allow building of (certain) rails, roads and bridge ramps on steep sloped tiles
tron
parents:
4231
diff
changeset
|
1700 |
} |
3286
5177aab0ec21
(svn r4000) Rewrite GetSlope{Tileh,Z}_{Road,Track} in a less confusing way
tron
parents:
3284
diff
changeset
|
1701 |
tileh = _inclined_tileh[f - 15]; // inclined foundation |
0 | 1702 |
} |
4231
2823b3643862
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4230
diff
changeset
|
1703 |
return z + GetPartialZ(x & 0xF, y & 0xF, tileh); |
4182
48dba107ff43
(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
|
1704 |
} else { |
48dba107ff43
(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
|
1705 |
return z + TILE_HEIGHT; |
0 | 1706 |
} |
1707 |
} |
|
1708 |
||
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
1709 |
static Slope GetSlopeTileh_Track(TileIndex tile, Slope tileh) |
39 | 1710 |
{ |
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
1711 |
if (tileh == SLOPE_FLAT) return SLOPE_FLAT; |
4182
48dba107ff43
(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
|
1712 |
if (IsPlainRailTile(tile)) { |
3418
ec9003ebf933
(svn r4242) Pass TileIndex and slope to GetSlopeTileh_*() instead of TileInfo
tron
parents:
3379
diff
changeset
|
1713 |
uint f = GetRailFoundation(tileh, GetTrackBits(tile)); |
3286
5177aab0ec21
(svn r4000) Rewrite GetSlope{Tileh,Z}_{Road,Track} in a less confusing way
tron
parents:
3284
diff
changeset
|
1714 |
|
3418
ec9003ebf933
(svn r4242) Pass TileIndex and slope to GetSlopeTileh_*() instead of TileInfo
tron
parents:
3379
diff
changeset
|
1715 |
if (f == 0) return tileh; |
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3575
diff
changeset
|
1716 |
if (f < 15) return SLOPE_FLAT; // leveled foundation |
3286
5177aab0ec21
(svn r4000) Rewrite GetSlope{Tileh,Z}_{Road,Track} in a less confusing way
tron
parents:
3284
diff
changeset
|
1717 |
return _inclined_tileh[f - 15]; // inclined foundation |
4182
48dba107ff43
(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
|
1718 |
} else { |
48dba107ff43
(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
|
1719 |
return SLOPE_FLAT; |
39 | 1720 |
} |
1721 |
} |
|
1722 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1963
diff
changeset
|
1723 |
static void GetAcceptedCargo_Track(TileIndex tile, AcceptedCargo ac) |
0 | 1724 |
{ |
1725 |
/* not used */ |
|
1726 |
} |
|
1727 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1963
diff
changeset
|
1728 |
static void AnimateTile_Track(TileIndex tile) |
0 | 1729 |
{ |
1730 |
/* not used */ |
|
1731 |
} |
|
1732 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1963
diff
changeset
|
1733 |
static void TileLoop_Track(TileIndex tile) |
0 | 1734 |
{ |
3523
549603ffba5d
(svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents:
3522
diff
changeset
|
1735 |
RailGroundType old_ground = GetRailGroundType(tile); |
4483
286633eb42fc
(svn r6268) Remove now pointless assignment (followup of r6267)
tron
parents:
4482
diff
changeset
|
1736 |
RailGroundType new_ground; |
0 | 1737 |
|
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2626
diff
changeset
|
1738 |
switch (_opt.landscape) { |
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2626
diff
changeset
|
1739 |
case LT_HILLY: |
3562
83a833bbe9ac
(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
|
1740 |
if (GetTileZ(tile) > _opt.snow_line) { |
83a833bbe9ac
(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
|
1741 |
new_ground = RAIL_GROUND_ICE_DESERT; |
4482
5010275cab9e
(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
|
1742 |
goto set_ground; |
3562
83a833bbe9ac
(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
|
1743 |
} |
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2626
diff
changeset
|
1744 |
break; |
0 | 1745 |
|
2631
2ed0eb408229
(svn r3173) Use the trinary operator and switch to improve readability
tron
parents:
2626
diff
changeset
|
1746 |
case LT_DESERT: |
3562
83a833bbe9ac
(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
|
1747 |
if (GetTropicZone(tile) == TROPICZONE_DESERT) { |
83a833bbe9ac
(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
|
1748 |
new_ground = RAIL_GROUND_ICE_DESERT; |
4482
5010275cab9e
(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
|
1749 |
goto set_ground; |
3562
83a833bbe9ac
(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
|
1750 |
} |
3523
549603ffba5d
(svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents:
3522
diff
changeset
|
1751 |
break; |
549603ffba5d
(svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents:
3522
diff
changeset
|
1752 |
} |
549603ffba5d
(svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents:
3522
diff
changeset
|
1753 |
|
4182
48dba107ff43
(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
|
1754 |
if (!IsPlainRailTile(tile)) return; |
0 | 1755 |
|
3523
549603ffba5d
(svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents:
3522
diff
changeset
|
1756 |
new_ground = RAIL_GROUND_GRASS; |
0 | 1757 |
|
3523
549603ffba5d
(svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents:
3522
diff
changeset
|
1758 |
if (old_ground != RAIL_GROUND_BARREN) { /* wait until bottom is green */ |
0 | 1759 |
/* determine direction of fence */ |
3267
feff95208a9f
(svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents:
3265
diff
changeset
|
1760 |
TrackBits rail = GetTrackBits(tile); |
0 | 1761 |
|
2839
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1762 |
switch (rail) { |
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1763 |
case TRACK_BIT_UPPER: new_ground = RAIL_GROUND_FENCE_HORIZ1; break; |
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1764 |
case TRACK_BIT_LOWER: new_ground = RAIL_GROUND_FENCE_HORIZ2; break; |
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1765 |
case TRACK_BIT_LEFT: new_ground = RAIL_GROUND_FENCE_VERT1; break; |
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1766 |
case TRACK_BIT_RIGHT: new_ground = RAIL_GROUND_FENCE_VERT2; break; |
0 | 1767 |
|
2839
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1768 |
default: { |
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1769 |
PlayerID owner = GetTileOwner(tile); |
0 | 1770 |
|
2839
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1771 |
if (rail == (TRACK_BIT_LOWER | TRACK_BIT_RIGHT) || ( |
3258
1c079364726d
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
1772 |
(rail & TRACK_BIT_3WAY_NW) == 0 && |
3102
f9ca4379db9d
(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
|
1773 |
(rail & TRACK_BIT_X) |
2839
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1774 |
)) { |
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1775 |
TileIndex n = tile + TileDiffXY(0, -1); |
3524
0a5fa1095ff4
(svn r4380) -Codechange: Make use of GetTrackBits where appropriate
celestar
parents:
3523
diff
changeset
|
1776 |
TrackBits nrail = GetTrackBits(n); |
0 | 1777 |
|
2839
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1778 |
if (!IsTileType(n, MP_RAILWAY) || |
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1779 |
!IsTileOwner(n, owner) || |
3524
0a5fa1095ff4
(svn r4380) -Codechange: Make use of GetTrackBits where appropriate
celestar
parents:
3523
diff
changeset
|
1780 |
nrail == TRACK_BIT_UPPER || |
0a5fa1095ff4
(svn r4380) -Codechange: Make use of GetTrackBits where appropriate
celestar
parents:
3523
diff
changeset
|
1781 |
nrail == TRACK_BIT_LEFT) { |
2839
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1782 |
new_ground = RAIL_GROUND_FENCE_NW; |
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1783 |
} |
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1784 |
} |
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1785 |
|
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1786 |
if (rail == (TRACK_BIT_UPPER | TRACK_BIT_LEFT) || ( |
3258
1c079364726d
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
1787 |
(rail & TRACK_BIT_3WAY_SE) == 0 && |
3102
f9ca4379db9d
(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
|
1788 |
(rail & TRACK_BIT_X) |
2839
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1789 |
)) { |
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1790 |
TileIndex n = tile + TileDiffXY(0, 1); |
3524
0a5fa1095ff4
(svn r4380) -Codechange: Make use of GetTrackBits where appropriate
celestar
parents:
3523
diff
changeset
|
1791 |
TrackBits nrail = GetTrackBits(n); |
2839
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1792 |
|
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1793 |
if (!IsTileType(n, MP_RAILWAY) || |
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1794 |
!IsTileOwner(n, owner) || |
3524
0a5fa1095ff4
(svn r4380) -Codechange: Make use of GetTrackBits where appropriate
celestar
parents:
3523
diff
changeset
|
1795 |
nrail == TRACK_BIT_LOWER || |
0a5fa1095ff4
(svn r4380) -Codechange: Make use of GetTrackBits where appropriate
celestar
parents:
3523
diff
changeset
|
1796 |
nrail == TRACK_BIT_RIGHT) { |
2839
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1797 |
new_ground = (new_ground == RAIL_GROUND_FENCE_NW) ? |
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1798 |
RAIL_GROUND_FENCE_SENW : RAIL_GROUND_FENCE_SE; |
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1799 |
} |
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1800 |
} |
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1801 |
|
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1802 |
if (rail == (TRACK_BIT_LOWER | TRACK_BIT_LEFT) || ( |
3258
1c079364726d
(svn r3946) Add short hand names for common track combinations
tron
parents:
3254
diff
changeset
|
1803 |
(rail & TRACK_BIT_3WAY_NE) == 0 && |
3102
f9ca4379db9d
(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
|
1804 |
(rail & TRACK_BIT_Y) |
2839
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1805 |
)) { |
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1806 |
TileIndex n = tile + TileDiffXY(-1, 0); |
3524
0a5fa1095ff4
(svn r4380) -Codechange: Make use of GetTrackBits where appropriate
celestar
parents:
3523
diff
changeset
|
1807 |
TrackBits nrail = GetTrackBits(n); |
2839
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1808 |
|
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1809 |
if (!IsTileType(n, MP_RAILWAY) || |
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1810 |
!IsTileOwner(n, owner) || |
3524
0a5fa1095ff4
(svn r4380) -Codechange: Make use of GetTrackBits where appropriate
celestar
parents:
3523
diff
changeset
|
1811 |
nrail == TRACK_BIT_UPPER || |
0a5fa1095ff4
(svn r4380) -Codechange: Make use of GetTrackBits where appropriate
celestar
parents:
3523
diff
changeset
|
1812 |
nrail == TRACK_BIT_RIGHT) { |
2839
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1813 |
new_ground = RAIL_GROUND_FENCE_NE; |
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1814 |
} |
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1815 |
} |
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1816 |
|
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1817 |
if (rail == (TRACK_BIT_UPPER | TRACK_BIT_RIGHT) || ( |
3265 | 1818 |
(rail & TRACK_BIT_3WAY_SW) == 0 && |
3102
f9ca4379db9d
(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
|
1819 |
(rail & TRACK_BIT_Y) |
2839
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1820 |
)) { |
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1821 |
TileIndex n = tile + TileDiffXY(1, 0); |
3524
0a5fa1095ff4
(svn r4380) -Codechange: Make use of GetTrackBits where appropriate
celestar
parents:
3523
diff
changeset
|
1822 |
TrackBits nrail = GetTrackBits(n); |
2839
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1823 |
|
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1824 |
if (!IsTileType(n, MP_RAILWAY) || |
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1825 |
!IsTileOwner(n, owner) || |
3524
0a5fa1095ff4
(svn r4380) -Codechange: Make use of GetTrackBits where appropriate
celestar
parents:
3523
diff
changeset
|
1826 |
nrail == TRACK_BIT_LOWER || |
0a5fa1095ff4
(svn r4380) -Codechange: Make use of GetTrackBits where appropriate
celestar
parents:
3523
diff
changeset
|
1827 |
nrail == TRACK_BIT_LEFT) { |
2839
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1828 |
new_ground = (new_ground == RAIL_GROUND_FENCE_NE) ? |
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1829 |
RAIL_GROUND_FENCE_NESW : RAIL_GROUND_FENCE_SW; |
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1830 |
} |
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1831 |
} |
a466d41923d8
(svn r3387) Restructure the code, which places fences along railroad tracks.
tron
parents:
2821
diff
changeset
|
1832 |
break; |
0 | 1833 |
} |
1834 |
} |
|
1835 |
} |
|
1836 |
||
4482
5010275cab9e
(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
|
1837 |
set_ground: |
2667
f3ffefc784c5
(svn r3209) In TileLoop_Track(), use names based on function rather than their place in the map array.
peter1138
parents:
2645
diff
changeset
|
1838 |
if (old_ground != new_ground) { |
3523
549603ffba5d
(svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents:
3522
diff
changeset
|
1839 |
SetRailGroundType(tile, new_ground); |
0 | 1840 |
MarkTileDirtyByTile(tile); |
1841 |
} |
|
1842 |
} |
|
1843 |
||
1844 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1963
diff
changeset
|
1845 |
static uint32 GetTileTrackStatus_Track(TileIndex tile, TransportType mode) |
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1963
diff
changeset
|
1846 |
{ |
3267
feff95208a9f
(svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents:
3265
diff
changeset
|
1847 |
byte a; |
817
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
679
diff
changeset
|
1848 |
uint16 b; |
0 | 1849 |
|
2639 | 1850 |
if (mode != TRANSPORT_RAIL) return 0; |
0 | 1851 |
|
4182
48dba107ff43
(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
|
1852 |
if (IsPlainRailTile(tile)) { |
3267
feff95208a9f
(svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents:
3265
diff
changeset
|
1853 |
TrackBits rails = GetTrackBits(tile); |
feff95208a9f
(svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents:
3265
diff
changeset
|
1854 |
uint32 ret = rails * 0x101; |
feff95208a9f
(svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents:
3265
diff
changeset
|
1855 |
|
4182
48dba107ff43
(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
|
1856 |
if (HasSignals(tile)) { |
2049
538e73c53f54
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2020
diff
changeset
|
1857 |
a = _m[tile].m3; |
538e73c53f54
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
2020
diff
changeset
|
1858 |
b = _m[tile].m2; |
0 | 1859 |
|
1860 |
b &= a; |
|
1861 |
||
22 | 1862 |
/* When signals are not present (in neither |
1863 |
* direction), we pretend them to be green. (So if |
|
1864 |
* signals are only one way, the other way will |
|
1865 |
* implicitely become `red' */ |
|
2549 | 1866 |
if ((a & 0xC0) == 0) b |= 0xC0; |
1867 |
if ((a & 0x30) == 0) b |= 0x30; |
|
0 | 1868 |
|
2639 | 1869 |
if ((b & 0x80) == 0) ret |= 0x10070000; |
1870 |
if ((b & 0x40) == 0) ret |= 0x07100000; |
|
1871 |
if ((b & 0x20) == 0) ret |= 0x20080000; |
|
1872 |
if ((b & 0x10) == 0) ret |= 0x08200000; |
|
4182
48dba107ff43
(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
|
1873 |
} else { |
48dba107ff43
(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
|
1874 |
if (rails == TRACK_BIT_CROSS) ret |= 0x40; |
0 | 1875 |
} |
3267
feff95208a9f
(svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents:
3265
diff
changeset
|
1876 |
return ret; |
feff95208a9f
(svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents:
3265
diff
changeset
|
1877 |
} else { |
3269
62fb247bf94b
(svn r3981) More work for the rail accessing functions and enums
tron
parents:
3267
diff
changeset
|
1878 |
if (GetRailTileSubtype(tile) == RAIL_SUBTYPE_DEPOT) { |
4158 | 1879 |
return AxisToTrackBits(DiagDirToAxis(GetRailDepotDirection(tile))) * 0x101; |
3269
62fb247bf94b
(svn r3981) More work for the rail accessing functions and enums
tron
parents:
3267
diff
changeset
|
1880 |
} else { |
3267
feff95208a9f
(svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents:
3265
diff
changeset
|
1881 |
return GetRailWaypointBits(tile) * 0x101; |
feff95208a9f
(svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents:
3265
diff
changeset
|
1882 |
} |
feff95208a9f
(svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents:
3265
diff
changeset
|
1883 |
} |
0 | 1884 |
} |
1885 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1963
diff
changeset
|
1886 |
static void ClickTile_Track(TileIndex tile) |
0 | 1887 |
{ |
2548
49c8a096033f
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2544
diff
changeset
|
1888 |
if (IsTileDepotType(tile, TRANSPORT_RAIL)) { |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
4559
diff
changeset
|
1889 |
ShowDepotWindow(tile, VEH_Train); |
2668
c0f1828b89e4
(svn r3210) -Codechange: use IsRailWaypoint where possible (instead of magicnumbers)
truelight
parents:
2667
diff
changeset
|
1890 |
} else if (IsRailWaypoint(tile)) { |
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1536
diff
changeset
|
1891 |
ShowRenameWaypointWindow(GetWaypointByTile(tile)); |
2548
49c8a096033f
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2544
diff
changeset
|
1892 |
} |
0 | 1893 |
} |
1894 |
||
1590
3351993cb1da
(svn r2094) In GetTileDesc_Track(): uint -> TileIndex, use enums, if () cascade -> switch
tron
parents:
1555
diff
changeset
|
1895 |
static void GetTileDesc_Track(TileIndex tile, TileDesc *td) |
0 | 1896 |
{ |
1901
03bf9bf99319
(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
|
1897 |
td->owner = GetTileOwner(tile); |
1942
c5d5cf5b0263
(svn r2448) General cleanup of rail related code, more to follow.
matthijs
parents:
1928
diff
changeset
|
1898 |
switch (GetRailTileType(tile)) { |
3792
67c865c9315c
(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
|
1899 |
case RAIL_TILE_NORMAL: |
0 | 1900 |
td->str = STR_1021_RAILROAD_TRACK; |
1590
3351993cb1da
(svn r2094) In GetTileDesc_Track(): uint -> TileIndex, use enums, if () cascade -> switch
tron
parents:
1555
diff
changeset
|
1901 |
break; |
3351993cb1da
(svn r2094) In GetTileDesc_Track(): uint -> TileIndex, use enums, if () cascade -> switch
tron
parents:
1555
diff
changeset
|
1902 |
|
3792
67c865c9315c
(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
|
1903 |
case RAIL_TILE_SIGNALS: { |
2916
b687477adcba
(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
|
1904 |
const StringID signal_type[] = { |
1590
3351993cb1da
(svn r2094) In GetTileDesc_Track(): uint -> TileIndex, use enums, if () cascade -> switch
tron
parents:
1555
diff
changeset
|
1905 |
STR_RAILROAD_TRACK_WITH_NORMAL_SIGNALS, |
3351993cb1da
(svn r2094) In GetTileDesc_Track(): uint -> TileIndex, use enums, if () cascade -> switch
tron
parents:
1555
diff
changeset
|
1906 |
STR_RAILROAD_TRACK_WITH_PRESIGNALS, |
3351993cb1da
(svn r2094) In GetTileDesc_Track(): uint -> TileIndex, use enums, if () cascade -> switch
tron
parents:
1555
diff
changeset
|
1907 |
STR_RAILROAD_TRACK_WITH_EXITSIGNALS, |
2916
b687477adcba
(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
|
1908 |
STR_RAILROAD_TRACK_WITH_COMBOSIGNALS |
1590
3351993cb1da
(svn r2094) In GetTileDesc_Track(): uint -> TileIndex, use enums, if () cascade -> switch
tron
parents:
1555
diff
changeset
|
1909 |
}; |
3351993cb1da
(svn r2094) In GetTileDesc_Track(): uint -> TileIndex, use enums, if () cascade -> switch
tron
parents:
1555
diff
changeset
|
1910 |
|
3238
9ebec0a611ee
(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
|
1911 |
td->str = signal_type[GetSignalType(tile)]; |
1590
3351993cb1da
(svn r2094) In GetTileDesc_Track(): uint -> TileIndex, use enums, if () cascade -> switch
tron
parents:
1555
diff
changeset
|
1912 |
break; |
0 | 1913 |
} |
1590
3351993cb1da
(svn r2094) In GetTileDesc_Track(): uint -> TileIndex, use enums, if () cascade -> switch
tron
parents:
1555
diff
changeset
|
1914 |
|
3792
67c865c9315c
(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
|
1915 |
case RAIL_TILE_DEPOT_WAYPOINT: |
1590
3351993cb1da
(svn r2094) In GetTileDesc_Track(): uint -> TileIndex, use enums, if () cascade -> switch
tron
parents:
1555
diff
changeset
|
1916 |
default: |
3269
62fb247bf94b
(svn r3981) More work for the rail accessing functions and enums
tron
parents:
3267
diff
changeset
|
1917 |
td->str = (GetRailTileSubtype(tile) == RAIL_SUBTYPE_DEPOT) ? |
1590
3351993cb1da
(svn r2094) In GetTileDesc_Track(): uint -> TileIndex, use enums, if () cascade -> switch
tron
parents:
1555
diff
changeset
|
1918 |
STR_1023_RAILROAD_TRAIN_DEPOT : STR_LANDINFO_WAYPOINT; |
3351993cb1da
(svn r2094) In GetTileDesc_Track(): uint -> TileIndex, use enums, if () cascade -> switch
tron
parents:
1555
diff
changeset
|
1919 |
break; |
0 | 1920 |
} |
1921 |
} |
|
1922 |
||
2436
7d5df545bd5d
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
1923 |
static void ChangeTileOwner_Track(TileIndex tile, PlayerID old_player, PlayerID new_player) |
0 | 1924 |
{ |
1901
03bf9bf99319
(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
|
1925 |
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
|
1926 |
|
4848
45f848b46222
(svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents:
4792
diff
changeset
|
1927 |
if (new_player != PLAYER_SPECTATOR) { |
1902 | 1928 |
SetTileOwner(tile, new_player); |
4434
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4388
diff
changeset
|
1929 |
} else { |
3491
35d747bb5e82
(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
|
1930 |
DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); |
0 | 1931 |
} |
1932 |
} |
|
1933 |
||
1934 |
static const byte _fractcoords_behind[4] = { 0x8F, 0x8, 0x80, 0xF8 }; |
|
1935 |
static const byte _fractcoords_enter[4] = { 0x8A, 0x48, 0x84, 0xA8 }; |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
1936 |
static const signed char _deltacoord_leaveoffset[8] = { |
1922
bda6f85eefaa
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
1937 |
-1, 0, 1, 0, /* x */ |
bda6f85eefaa
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
1938 |
0, 1, 0, -1 /* y */ |
bda6f85eefaa
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
1939 |
}; |
0 | 1940 |
|
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1963
diff
changeset
|
1941 |
static uint32 VehicleEnter_Track(Vehicle *v, TileIndex tile, int x, int y) |
0 | 1942 |
{ |
1943 |
byte fract_coord; |
|
1922
bda6f85eefaa
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
1944 |
byte fract_coord_leave; |
3157
3f35e2d9c8e3
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3154
diff
changeset
|
1945 |
DiagDirection dir; |
1922
bda6f85eefaa
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
1946 |
int length; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1947 |
|
0 | 1948 |
// this routine applies only to trains in depot tiles |
2639 | 1949 |
if (v->type != VEH_Train || !IsTileDepotType(tile, TRANSPORT_RAIL)) return 0; |
0 | 1950 |
|
1951 |
/* depot direction */ |
|
3185 | 1952 |
dir = GetRailDepotDirection(tile); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1953 |
|
1922
bda6f85eefaa
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
1954 |
/* calculate the point where the following wagon should be activated */ |
bda6f85eefaa
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
1955 |
/* this depends on the length of the current vehicle */ |
bda6f85eefaa
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
1956 |
length = v->u.rail.cached_veh_length; |
bda6f85eefaa
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
1957 |
|
bda6f85eefaa
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
1958 |
fract_coord_leave = |
4434
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4388
diff
changeset
|
1959 |
((_fractcoords_enter[dir] & 0x0F) + // x |
1922
bda6f85eefaa
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
1960 |
(length + 1) * _deltacoord_leaveoffset[dir]) + |
4434
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4388
diff
changeset
|
1961 |
(((_fractcoords_enter[dir] >> 4) + // y |
1922
bda6f85eefaa
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
1962 |
((length + 1) * _deltacoord_leaveoffset[dir+4])) << 4); |
bda6f85eefaa
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
1963 |
|
0 | 1964 |
fract_coord = (x & 0xF) + ((y & 0xF) << 4); |
1922
bda6f85eefaa
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
1965 |
|
0 | 1966 |
if (_fractcoords_behind[dir] == fract_coord) { |
1967 |
/* make sure a train is not entering the tile from behind */ |
|
1968 |
return 8; |
|
1969 |
} else if (_fractcoords_enter[dir] == fract_coord) { |
|
3157
3f35e2d9c8e3
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3154
diff
changeset
|
1970 |
if (DiagDirToDir(ReverseDiagDir(dir)) == v->direction) { |
0 | 1971 |
/* enter the depot */ |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
1972 |
v->u.rail.track = TRACK_BIT_SPECIAL, |
0 | 1973 |
v->vehstatus |= VS_HIDDEN; /* hide it */ |
3157
3f35e2d9c8e3
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3154
diff
changeset
|
1974 |
v->direction = ReverseDir(v->direction); |
5198
7046e5b0b5bc
(svn r7313) -Codechange: Calling invalidate data on a window will surely warrant a redraw, so call
Darkvater
parents:
5116
diff
changeset
|
1975 |
if (v->next == NULL) VehicleEnterDepot(v); |
7046e5b0b5bc
(svn r7313) -Codechange: Calling invalidate data on a window will surely warrant a redraw, so call
Darkvater
parents:
5116
diff
changeset
|
1976 |
v->tile = tile; |
7046e5b0b5bc
(svn r7313) -Codechange: Calling invalidate data on a window will surely warrant a redraw, so call
Darkvater
parents:
5116
diff
changeset
|
1977 |
|
4739
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4725
diff
changeset
|
1978 |
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile); |
0 | 1979 |
return 4; |
1980 |
} |
|
1922
bda6f85eefaa
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1903
diff
changeset
|
1981 |
} else if (fract_coord_leave == fract_coord) { |
3157
3f35e2d9c8e3
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3154
diff
changeset
|
1982 |
if (DiagDirToDir(dir) == v->direction) { |
0 | 1983 |
/* leave the depot? */ |
2951 | 1984 |
if ((v = v->next) != NULL) { |
0 | 1985 |
v->vehstatus &= ~VS_HIDDEN; |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
1986 |
v->u.rail.track = (DiagDirToAxis(dir) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y); |
0 | 1987 |
} |
1988 |
} |
|
1989 |
} |
|
1990 |
||
1991 |
return 0; |
|
1992 |
} |
|
1993 |
||
1994 |
||
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
1995 |
extern const TileTypeProcs _tile_type_rail_procs = { |
4344
7e123fec5b0b
(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
|
1996 |
DrawTile_Track, /* draw_tile_proc */ |
7e123fec5b0b
(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
|
1997 |
GetSlopeZ_Track, /* get_slope_z_proc */ |
7e123fec5b0b
(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
|
1998 |
ClearTile_Track, /* clear_tile_proc */ |
7e123fec5b0b
(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
|
1999 |
GetAcceptedCargo_Track, /* get_accepted_cargo_proc */ |
7e123fec5b0b
(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
|
2000 |
GetTileDesc_Track, /* get_tile_desc_proc */ |
7e123fec5b0b
(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
|
2001 |
GetTileTrackStatus_Track, /* get_tile_track_status_proc */ |
7e123fec5b0b
(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
|
2002 |
ClickTile_Track, /* click_tile_proc */ |
7e123fec5b0b
(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
|
2003 |
AnimateTile_Track, /* animate_tile_proc */ |
7e123fec5b0b
(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
|
2004 |
TileLoop_Track, /* tile_loop_clear */ |
7e123fec5b0b
(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
|
2005 |
ChangeTileOwner_Track, /* change_tile_owner_clear */ |
7e123fec5b0b
(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
|
2006 |
NULL, /* get_produced_cargo_proc */ |
7e123fec5b0b
(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
|
2007 |
VehicleEnter_Track, /* vehicle_enter_tile_proc */ |
7e123fec5b0b
(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
|
2008 |
GetSlopeTileh_Track, /* get_slope_tileh_proc */ |
0 | 2009 |
}; |