Mercurial > hg > openttd
annotate src/newgrf_station.cpp @ 12462:4dd085f22d88 draft
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
author | rubidium <rubidium@openttd.org> |
---|---|
date | Tue, 21 Jul 2009 11:11:05 +0000 |
parents | 737f00243322 |
children | 0b5bb0069975 |
rev | line source |
---|---|
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1 /* $Id$ */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2 |
6117
6def6ecb1bf7
(svn r8853) -Cleanup: doxygen changes. Correct forgotten c files to cpp files with the @file tag as well as a few general comments style
belugas <belugas@openttd.org>
parents:
6113
diff
changeset
|
3 /** @file newgrf_station.cpp Functions for dealing with station classes and custom stations. */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
4 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
5 #include "stdafx.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
6 #include "variables.h" |
6343
f75b72d9fc98
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros <maedhros@openttd.org>
parents:
6247
diff
changeset
|
7 #include "landscape.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
8 #include "debug.h" |
12228
240adc64d01a
(svn r16643) -Codechange: replace GetStationByTile() by Station::GetByTile()
smatz <smatz@openttd.org>
parents:
12225
diff
changeset
|
9 #include "station_base.h" |
12430
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
10 #include "waypoint.h" |
12225
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
12016
diff
changeset
|
11 #include "roadstop_base.h" |
6849
cbe1a12e652d
(svn r10089) -Fix (r10040): Use GetTileZ instead of GetClearGround in GetTerrainType as
maedhros <maedhros@openttd.org>
parents:
6683
diff
changeset
|
12 #include "newgrf_commons.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
13 #include "newgrf_station.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
14 #include "newgrf_spritegroup.h" |
9018
9dcf32675eb5
(svn r12817) -Feature: the ability to play NewGRF sounds for industries and stations.
rubidium <rubidium@openttd.org>
parents:
9006
diff
changeset
|
15 #include "newgrf_sound.h" |
9726
06221034cf54
(svn r13851) -Fix (r9393): GetTownByTile() is only valid for houses and roads.
frosch <frosch@openttd.org>
parents:
9714
diff
changeset
|
16 #include "town.h" |
6354
4595b3acd03d
(svn r9393) -Codechange: Use newgrf town resolver as station parent scope handler
peter1138 <peter1138@openttd.org>
parents:
6348
diff
changeset
|
17 #include "newgrf_town.h" |
8123
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
8121
diff
changeset
|
18 #include "gfx_func.h" |
8140
fb8a05d579da
(svn r11702) -Codechange: move all date related stuff to date*.
rubidium <rubidium@openttd.org>
parents:
8130
diff
changeset
|
19 #include "date_func.h" |
10208
39cf8eebfda5
(svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
10207
diff
changeset
|
20 #include "company_func.h" |
9005
5bb8efb6051a
(svn r12800) -Codechange: move the animated tile related functions out of texteff.cpp (it isn't a text effect after all). Also remove a few more functions from functions.
rubidium <rubidium@openttd.org>
parents:
9004
diff
changeset
|
21 #include "animated_tile_func.h" |
9006
9bf1de259ada
(svn r12801) -Codechange: remove the dependency of function.h in town_map.h
rubidium <rubidium@openttd.org>
parents:
9005
diff
changeset
|
22 #include "functions.h" |
9662
cf5657f9e445
(svn r13734) -Fix: NewGRF rail continuation would always mark a tunnel on the same axis as connected, even when the tunnel faces the wrong direction.
rubidium <rubidium@openttd.org>
parents:
9038
diff
changeset
|
23 #include "tunnelbridge_map.h" |
10256
c0307c0a126c
(svn r14487) -Fix: The station picker preview did not draw child sprites.
frosch <frosch@openttd.org>
parents:
10208
diff
changeset
|
24 #include "spritecache.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
25 |
8264
2495310e220f
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents:
8254
diff
changeset
|
26 #include "table/strings.h" |
2495310e220f
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents:
8254
diff
changeset
|
27 |
11091
c4c35a89bad7
(svn r15436) -Codechange: Return index of station spec within station class as a return parameter of GetCustomStationSpecByGrf(), as the index is already known. Saves on an extra loop and an extern...
peter1138 <peter1138@openttd.org>
parents:
11085
diff
changeset
|
28 static StationClass _station_classes[STAT_CLASS_MAX]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
29 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
30 enum { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
31 MAX_SPECLIST = 255, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
32 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
33 |
12462
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
34 enum TriggerArea { |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
35 TA_TILE, |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
36 TA_PLATFORM, |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
37 TA_WHOLE, |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
38 }; |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
39 |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
40 struct ETileArea : TileArea { |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
41 ETileArea(const BaseStation *st, TileIndex tile, TriggerArea ta) |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
42 { |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
43 switch (ta) { |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
44 default: NOT_REACHED(); |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
45 |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
46 case TA_TILE: |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
47 this->tile = tile; |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
48 this->w = 1; |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
49 this->h = 1; |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
50 break; |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
51 |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
52 case TA_PLATFORM: { |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
53 TileIndex start, end; |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
54 Axis axis = GetRailStationAxis(tile); |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
55 TileIndexDiff delta = TileOffsByDiagDir(AxisToDiagDir(axis)); |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
56 |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
57 for (end = tile; IsRailwayStationTile(end + delta) && IsCompatibleTrainStationTile(tile, end + delta); end += delta) { /* Nothing */ } |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
58 for (start = tile; IsRailwayStationTile(start - delta) && IsCompatibleTrainStationTile(tile, start - delta); start -= delta) { /* Nothing */ } |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
59 |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
60 this->tile = start; |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
61 this->w = TileX(end) - TileX(start) + 1; |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
62 this->h = TileY(end) - TileY(start) + 1; |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
63 break; |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
64 } |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
65 |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
66 case TA_WHOLE: |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
67 st->GetTileArea(this, Station::IsExpected(st) ? STATION_RAIL : STATION_WAYPOINT); |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
68 this->w++; |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
69 this->h++; |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
70 break; |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
71 } |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
72 } |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
73 }; |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
74 |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
75 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
76 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
77 * Reset station classes to their default state. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
78 * This includes initialising the Default and Waypoint classes with an empty |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
79 * entry, for standard stations and waypoints. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
80 */ |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6148
diff
changeset
|
81 void ResetStationClasses() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
82 { |
5587
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
83 for (StationClassID i = STAT_CLASS_BEGIN; i < STAT_CLASS_MAX; i++) { |
8316
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
84 _station_classes[i].id = 0; |
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
85 _station_classes[i].name = STR_EMPTY; |
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
86 _station_classes[i].stations = 0; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
87 |
8316
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
88 free(_station_classes[i].spec); |
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
89 _station_classes[i].spec = NULL; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
90 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
91 |
6348
bcf98ba27bbf
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas <belugas@openttd.org>
parents:
6343
diff
changeset
|
92 /* Set up initial data */ |
8316
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
93 _station_classes[0].id = 'DFLT'; |
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
94 _station_classes[0].name = STR_STAT_CLASS_DFLT; |
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
95 _station_classes[0].stations = 1; |
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
96 _station_classes[0].spec = MallocT<StationSpec*>(1); |
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
97 _station_classes[0].spec[0] = NULL; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
98 |
8316
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
99 _station_classes[1].id = 'WAYP'; |
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
100 _station_classes[1].name = STR_STAT_CLASS_WAYP; |
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
101 _station_classes[1].stations = 1; |
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
102 _station_classes[1].spec = MallocT<StationSpec*>(1); |
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
103 _station_classes[1].spec[0] = NULL; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
104 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
105 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
106 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
107 * Allocate a station class for the given class id. |
6481
85a1a79387a2
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents:
6460
diff
changeset
|
108 * @param cls A 32 bit value identifying the class. |
8316
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
109 * @return Index into _station_classes of allocated class. |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
110 */ |
5587
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
111 StationClassID AllocateStationClass(uint32 cls) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
112 { |
5587
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
113 for (StationClassID i = STAT_CLASS_BEGIN; i < STAT_CLASS_MAX; i++) { |
8316
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
114 if (_station_classes[i].id == cls) { |
6348
bcf98ba27bbf
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas <belugas@openttd.org>
parents:
6343
diff
changeset
|
115 /* ClassID is already allocated, so reuse it. */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
116 return i; |
8316
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
117 } else if (_station_classes[i].id == 0) { |
6348
bcf98ba27bbf
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas <belugas@openttd.org>
parents:
6343
diff
changeset
|
118 /* This class is empty, so allocate it to the ClassID. */ |
8316
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
119 _station_classes[i].id = cls; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
120 return i; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
121 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
122 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
123 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
124 grfmsg(2, "StationClassAllocate: already allocated %d classes, using default", STAT_CLASS_MAX); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
125 return STAT_CLASS_DFLT; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
126 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
127 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
128 /** Set the name of a custom station class */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
129 void SetStationClassName(StationClassID sclass, StringID name) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
130 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
131 assert(sclass < STAT_CLASS_MAX); |
8316
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
132 _station_classes[sclass].name = name; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
133 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
134 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
135 /** Retrieve the name of a custom station class */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
136 StringID GetStationClassName(StationClassID sclass) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
137 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
138 assert(sclass < STAT_CLASS_MAX); |
8316
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
139 return _station_classes[sclass].name; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
140 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
141 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
142 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
143 * Get the number of station classes in use. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
144 * @return Number of station classes. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
145 */ |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6148
diff
changeset
|
146 uint GetNumStationClasses() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
147 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
148 uint i; |
8695
9ee0730039f4
(svn r12368) -Codechange: use explicit body for loops and conditions and remove -Wno-empty-body from the configure script
smatz <smatz@openttd.org>
parents:
8616
diff
changeset
|
149 for (i = 0; i < STAT_CLASS_MAX && _station_classes[i].id != 0; i++) {} |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
150 return i; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
151 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
152 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
153 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
154 * Return the number of stations for the given station class. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
155 * @param sclass Index of the station class. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
156 * @return Number of stations in the class. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
157 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
158 uint GetNumCustomStations(StationClassID sclass) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
159 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
160 assert(sclass < STAT_CLASS_MAX); |
8316
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
161 return _station_classes[sclass].stations; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
162 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
163 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
164 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
165 * Tie a station spec to its station class. |
6481
85a1a79387a2
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents:
6460
diff
changeset
|
166 * @param statspec The station spec. |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
167 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
168 void SetCustomStationSpec(StationSpec *statspec) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
169 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
170 StationClass *station_class; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
171 int i; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
172 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
173 /* If the station has already been allocated, don't reallocate it. */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
174 if (statspec->allocated) return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
175 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
176 assert(statspec->sclass < STAT_CLASS_MAX); |
8316
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
177 station_class = &_station_classes[statspec->sclass]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
178 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
179 i = station_class->stations++; |
5609
358c07fb3212
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr <KUDr@openttd.org>
parents:
5587
diff
changeset
|
180 station_class->spec = ReallocT(station_class->spec, station_class->stations); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
181 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
182 station_class->spec[i] = statspec; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
183 statspec->allocated = true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
184 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
185 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
186 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
187 * Retrieve a station spec from a class. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
188 * @param sclass Index of the station class. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
189 * @param station The station index with the class. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
190 * @return The station spec. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
191 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
192 const StationSpec *GetCustomStationSpec(StationClassID sclass, uint station) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
193 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
194 assert(sclass < STAT_CLASS_MAX); |
8316
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
195 if (station < _station_classes[sclass].stations) |
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
196 return _station_classes[sclass].spec[station]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
197 |
6348
bcf98ba27bbf
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas <belugas@openttd.org>
parents:
6343
diff
changeset
|
198 /* If the custom station isn't defined any more, then the GRF file |
bcf98ba27bbf
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas <belugas@openttd.org>
parents:
6343
diff
changeset
|
199 * probably was not loaded. */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
200 return NULL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
201 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
202 |
11091
c4c35a89bad7
(svn r15436) -Codechange: Return index of station spec within station class as a return parameter of GetCustomStationSpecByGrf(), as the index is already known. Saves on an extra loop and an extern...
peter1138 <peter1138@openttd.org>
parents:
11085
diff
changeset
|
203 /** |
c4c35a89bad7
(svn r15436) -Codechange: Return index of station spec within station class as a return parameter of GetCustomStationSpecByGrf(), as the index is already known. Saves on an extra loop and an extern...
peter1138 <peter1138@openttd.org>
parents:
11085
diff
changeset
|
204 * Retrieve a station spec by GRF location. |
c4c35a89bad7
(svn r15436) -Codechange: Return index of station spec within station class as a return parameter of GetCustomStationSpecByGrf(), as the index is already known. Saves on an extra loop and an extern...
peter1138 <peter1138@openttd.org>
parents:
11085
diff
changeset
|
205 * @param grfid GRF ID of station spec. |
c4c35a89bad7
(svn r15436) -Codechange: Return index of station spec within station class as a return parameter of GetCustomStationSpecByGrf(), as the index is already known. Saves on an extra loop and an extern...
peter1138 <peter1138@openttd.org>
parents:
11085
diff
changeset
|
206 * @param localidx Index within GRF file of station spec. |
c4c35a89bad7
(svn r15436) -Codechange: Return index of station spec within station class as a return parameter of GetCustomStationSpecByGrf(), as the index is already known. Saves on an extra loop and an extern...
peter1138 <peter1138@openttd.org>
parents:
11085
diff
changeset
|
207 * @param index Pointer to return the index of the station spec in its station class. If NULL then not used. |
c4c35a89bad7
(svn r15436) -Codechange: Return index of station spec within station class as a return parameter of GetCustomStationSpecByGrf(), as the index is already known. Saves on an extra loop and an extern...
peter1138 <peter1138@openttd.org>
parents:
11085
diff
changeset
|
208 * @return The station spec. |
c4c35a89bad7
(svn r15436) -Codechange: Return index of station spec within station class as a return parameter of GetCustomStationSpecByGrf(), as the index is already known. Saves on an extra loop and an extern...
peter1138 <peter1138@openttd.org>
parents:
11085
diff
changeset
|
209 */ |
c4c35a89bad7
(svn r15436) -Codechange: Return index of station spec within station class as a return parameter of GetCustomStationSpecByGrf(), as the index is already known. Saves on an extra loop and an extern...
peter1138 <peter1138@openttd.org>
parents:
11085
diff
changeset
|
210 const StationSpec *GetCustomStationSpecByGrf(uint32 grfid, byte localidx, int *index) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
211 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
212 uint j; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
213 |
5587
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
214 for (StationClassID i = STAT_CLASS_BEGIN; i < STAT_CLASS_MAX; i++) { |
8316
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
215 for (j = 0; j < _station_classes[i].stations; j++) { |
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
216 const StationSpec *statspec = _station_classes[i].spec[j]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
217 if (statspec == NULL) continue; |
11091
c4c35a89bad7
(svn r15436) -Codechange: Return index of station spec within station class as a return parameter of GetCustomStationSpecByGrf(), as the index is already known. Saves on an extra loop and an extern...
peter1138 <peter1138@openttd.org>
parents:
11085
diff
changeset
|
218 if (statspec->grffile->grfid == grfid && statspec->localidx == localidx) { |
c4c35a89bad7
(svn r15436) -Codechange: Return index of station spec within station class as a return parameter of GetCustomStationSpecByGrf(), as the index is already known. Saves on an extra loop and an extern...
peter1138 <peter1138@openttd.org>
parents:
11085
diff
changeset
|
219 if (index != NULL) *index = j; |
c4c35a89bad7
(svn r15436) -Codechange: Return index of station spec within station class as a return parameter of GetCustomStationSpecByGrf(), as the index is already known. Saves on an extra loop and an extern...
peter1138 <peter1138@openttd.org>
parents:
11085
diff
changeset
|
220 return statspec; |
c4c35a89bad7
(svn r15436) -Codechange: Return index of station spec within station class as a return parameter of GetCustomStationSpecByGrf(), as the index is already known. Saves on an extra loop and an extern...
peter1138 <peter1138@openttd.org>
parents:
11085
diff
changeset
|
221 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
222 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
223 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
224 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
225 return NULL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
226 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
227 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
228 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
229 /* Evaluate a tile's position within a station, and return the result a bitstuffed format. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
230 * if not centred: .TNLcCpP, if centred: .TNL..CP |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
231 * T = Tile layout number (GetStationGfx), N = Number of platforms, L = Length of platforms |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
232 * C = Current platform number from start, c = from end |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
233 * P = Position along platform from start, p = from end |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
234 * if centred, C/P start from the centre and c/p are not available. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
235 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
236 uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, int y, bool centred) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
237 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
238 uint32 retval = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
239 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
240 if (axis == AXIS_X) { |
6106 | 241 Swap(platforms, length); |
242 Swap(x, y); | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
243 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
244 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
245 /* Limit our sizes to 4 bits */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
246 platforms = min(15, platforms); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
247 length = min(15, length); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
248 x = min(15, x); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
249 y = min(15, y); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
250 if (centred) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
251 x -= platforms / 2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
252 y -= length / 2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
253 SB(retval, 0, 4, y & 0xF); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
254 SB(retval, 4, 4, x & 0xF); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
255 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
256 SB(retval, 0, 4, y); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
257 SB(retval, 4, 4, length - y - 1); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
258 SB(retval, 8, 4, x); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
259 SB(retval, 12, 4, platforms - x - 1); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
260 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
261 SB(retval, 16, 4, length); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
262 SB(retval, 20, 4, platforms); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
263 SB(retval, 24, 4, tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
264 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
265 return retval; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
266 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
267 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
268 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
269 /* Find the end of a railway station, from the tile, in the direction of delta. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
270 * If check_type is set, we stop if the custom station type changes. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
271 * If check_axis is set, we stop if the station direction changes. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
272 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
273 static TileIndex FindRailStationEnd(TileIndex tile, TileIndexDiff delta, bool check_type, bool check_axis) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
274 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
275 bool waypoint; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
276 byte orig_type = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
277 Axis orig_axis = AXIS_X; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
278 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
279 waypoint = IsTileType(tile, MP_RAILWAY); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
280 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
281 if (waypoint) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
282 if (check_axis) orig_axis = GetWaypointAxis(tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
283 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
284 if (check_type) orig_type = GetCustomStationSpecIndex(tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
285 if (check_axis) orig_axis = GetRailStationAxis(tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
286 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
287 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
288 while (true) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
289 TileIndex new_tile = TILE_ADD(tile, delta); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
290 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
291 if (waypoint) { |
10099
3bb7e18e8b0a
(svn r14280) -Codechange: use IsRailWaypointTile() instead of IsTileType() and IsRailWaypoint() checks at several places
smatz <smatz@openttd.org>
parents:
9823
diff
changeset
|
292 if (!IsRailWaypointTile(new_tile)) break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
293 if (check_axis && GetWaypointAxis(new_tile) != orig_axis) break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
294 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
295 if (!IsRailwayStationTile(new_tile)) break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
296 if (check_type && GetCustomStationSpecIndex(new_tile) != orig_type) break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
297 if (check_axis && GetRailStationAxis(new_tile) != orig_axis) break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
298 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
299 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
300 tile = new_tile; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
301 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
302 return tile; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
303 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
304 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
305 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
306 static uint32 GetPlatformInfoHelper(TileIndex tile, bool check_type, bool check_axis, bool centred) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
307 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
308 int tx = TileX(tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
309 int ty = TileY(tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
310 int sx = TileX(FindRailStationEnd(tile, TileDiffXY(-1, 0), check_type, check_axis)); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
311 int sy = TileY(FindRailStationEnd(tile, TileDiffXY( 0, -1), check_type, check_axis)); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
312 int ex = TileX(FindRailStationEnd(tile, TileDiffXY( 1, 0), check_type, check_axis)) + 1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
313 int ey = TileY(FindRailStationEnd(tile, TileDiffXY( 0, 1), check_type, check_axis)) + 1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
314 Axis axis = IsTileType(tile, MP_RAILWAY) ? GetWaypointAxis(tile) : GetRailStationAxis(tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
315 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
316 tx -= sx; ex -= sx; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
317 ty -= sy; ey -= sy; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
318 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
319 return GetPlatformInfo(axis, IsTileType(tile, MP_RAILWAY) ? 2 : GetStationGfx(tile), ex, ey, tx, ty, centred); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
320 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
321 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
322 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
323 static uint32 GetRailContinuationInfo(TileIndex tile) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
324 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
325 /* Tile offsets and exit dirs for X axis */ |
7157
7e46225ed50b
(svn r10431) -Codechange: constness on static array
peter1138 <peter1138@openttd.org>
parents:
7010
diff
changeset
|
326 static const Direction x_dir[8] = { DIR_SW, DIR_NE, DIR_SE, DIR_NW, DIR_S, DIR_E, DIR_W, DIR_N }; |
7e46225ed50b
(svn r10431) -Codechange: constness on static array
peter1138 <peter1138@openttd.org>
parents:
7010
diff
changeset
|
327 static const DiagDirection x_exits[8] = { DIAGDIR_SW, DIAGDIR_NE, DIAGDIR_SE, DIAGDIR_NW, DIAGDIR_SW, DIAGDIR_NE, DIAGDIR_SW, DIAGDIR_NE }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
328 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
329 /* Tile offsets and exit dirs for Y axis */ |
7157
7e46225ed50b
(svn r10431) -Codechange: constness on static array
peter1138 <peter1138@openttd.org>
parents:
7010
diff
changeset
|
330 static const Direction y_dir[8] = { DIR_SE, DIR_NW, DIR_SW, DIR_NE, DIR_S, DIR_W, DIR_E, DIR_N }; |
7e46225ed50b
(svn r10431) -Codechange: constness on static array
peter1138 <peter1138@openttd.org>
parents:
7010
diff
changeset
|
331 static const DiagDirection y_exits[8] = { DIAGDIR_SE, DIAGDIR_NW, DIAGDIR_SW, DIAGDIR_NE, DIAGDIR_SE, DIAGDIR_NW, DIAGDIR_SE, DIAGDIR_NW }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
332 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
333 Axis axis = IsTileType(tile, MP_RAILWAY) ? GetWaypointAxis(tile) : GetRailStationAxis(tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
334 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
335 /* Choose appropriate lookup table to use */ |
7157
7e46225ed50b
(svn r10431) -Codechange: constness on static array
peter1138 <peter1138@openttd.org>
parents:
7010
diff
changeset
|
336 const Direction *dir = axis == AXIS_X ? x_dir : y_dir; |
7e46225ed50b
(svn r10431) -Codechange: constness on static array
peter1138 <peter1138@openttd.org>
parents:
7010
diff
changeset
|
337 const DiagDirection *diagdir = axis == AXIS_X ? x_exits : y_exits; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
338 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
339 uint32 res = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
340 uint i; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
341 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
342 for (i = 0; i < lengthof(x_dir); i++, dir++, diagdir++) { |
9662
cf5657f9e445
(svn r13734) -Fix: NewGRF rail continuation would always mark a tunnel on the same axis as connected, even when the tunnel faces the wrong direction.
rubidium <rubidium@openttd.org>
parents:
9038
diff
changeset
|
343 TileIndex neighbour_tile = tile + TileOffsByDir(*dir); |
cf5657f9e445
(svn r13734) -Fix: NewGRF rail continuation would always mark a tunnel on the same axis as connected, even when the tunnel faces the wrong direction.
rubidium <rubidium@openttd.org>
parents:
9038
diff
changeset
|
344 TrackBits trackbits = TrackStatusToTrackBits(GetTileTrackStatus(neighbour_tile, TRANSPORT_RAIL, 0)); |
8616
9e46ac001a8c
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch <frosch@openttd.org>
parents:
8571
diff
changeset
|
345 if (trackbits != TRACK_BIT_NONE) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
346 /* If there is any track on the tile, set the bit in the second byte */ |
7931
44ff7a6d801f
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7928
diff
changeset
|
347 SetBit(res, i + 8); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
348 |
9662
cf5657f9e445
(svn r13734) -Fix: NewGRF rail continuation would always mark a tunnel on the same axis as connected, even when the tunnel faces the wrong direction.
rubidium <rubidium@openttd.org>
parents:
9038
diff
changeset
|
349 /* With tunnels and bridges the tile has tracks, but they are not necessarily connected |
cf5657f9e445
(svn r13734) -Fix: NewGRF rail continuation would always mark a tunnel on the same axis as connected, even when the tunnel faces the wrong direction.
rubidium <rubidium@openttd.org>
parents:
9038
diff
changeset
|
350 * with the next tile because the ramp is not going in the right direction. */ |
cf5657f9e445
(svn r13734) -Fix: NewGRF rail continuation would always mark a tunnel on the same axis as connected, even when the tunnel faces the wrong direction.
rubidium <rubidium@openttd.org>
parents:
9038
diff
changeset
|
351 if (IsTileType(neighbour_tile, MP_TUNNELBRIDGE) && GetTunnelBridgeDirection(neighbour_tile) != *diagdir) { |
cf5657f9e445
(svn r13734) -Fix: NewGRF rail continuation would always mark a tunnel on the same axis as connected, even when the tunnel faces the wrong direction.
rubidium <rubidium@openttd.org>
parents:
9038
diff
changeset
|
352 continue; |
cf5657f9e445
(svn r13734) -Fix: NewGRF rail continuation would always mark a tunnel on the same axis as connected, even when the tunnel faces the wrong direction.
rubidium <rubidium@openttd.org>
parents:
9038
diff
changeset
|
353 } |
cf5657f9e445
(svn r13734) -Fix: NewGRF rail continuation would always mark a tunnel on the same axis as connected, even when the tunnel faces the wrong direction.
rubidium <rubidium@openttd.org>
parents:
9038
diff
changeset
|
354 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
355 /* If any track reaches our exit direction, set the bit in the lower byte */ |
8616
9e46ac001a8c
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch <frosch@openttd.org>
parents:
8571
diff
changeset
|
356 if (trackbits & DiagdirReachesTracks(*diagdir)) SetBit(res, i); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
357 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
358 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
359 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
360 return res; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
361 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
362 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
363 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
364 /* Station Resolver Functions */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
365 static uint32 StationGetRandomBits(const ResolverObject *object) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
366 { |
12425
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
367 const BaseStation *st = object->u.station.st; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
368 const TileIndex tile = object->u.station.tile; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
369 return (st == NULL ? 0 : st->random_bits) | (tile == INVALID_TILE ? 0 : GetStationTileRandomBits(tile) << 16); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
370 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
371 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
372 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
373 static uint32 StationGetTriggers(const ResolverObject *object) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
374 { |
12425
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
375 const BaseStation *st = object->u.station.st; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
376 return st == NULL ? 0 : st->waiting_triggers; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
377 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
378 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
379 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
380 static void StationSetTriggers(const ResolverObject *object, int triggers) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
381 { |
12425
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
382 BaseStation *st = const_cast<BaseStation *>(object->u.station.st); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
383 assert(st != NULL); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
384 st->waiting_triggers = triggers; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
385 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
386 |
7230
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
387 /** |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
388 * Station variable cache |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
389 * This caches 'expensive' station variable lookups which iterate over |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
390 * several tiles that may be called multiple times per Resolve(). |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
391 */ |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
392 static struct { |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
393 uint32 v40; |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
394 uint32 v41; |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
395 uint32 v45; |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
396 uint32 v46; |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
397 uint32 v47; |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
398 uint32 v49; |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
399 uint8 valid; |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
400 } _svc; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
401 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
402 static uint32 StationGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
403 { |
12425
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
404 const BaseStation *st = object->u.station.st; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
405 TileIndex tile = object->u.station.tile; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
406 |
6354
4595b3acd03d
(svn r9393) -Codechange: Use newgrf town resolver as station parent scope handler
peter1138 <peter1138@openttd.org>
parents:
6348
diff
changeset
|
407 if (object->scope == VSG_SCOPE_PARENT) { |
4595b3acd03d
(svn r9393) -Codechange: Use newgrf town resolver as station parent scope handler
peter1138 <peter1138@openttd.org>
parents:
6348
diff
changeset
|
408 /* Pass the request on to the town of the station */ |
9726
06221034cf54
(svn r13851) -Fix (r9393): GetTownByTile() is only valid for houses and roads.
frosch <frosch@openttd.org>
parents:
9714
diff
changeset
|
409 const Town *t; |
6354
4595b3acd03d
(svn r9393) -Codechange: Use newgrf town resolver as station parent scope handler
peter1138 <peter1138@openttd.org>
parents:
6348
diff
changeset
|
410 |
4595b3acd03d
(svn r9393) -Codechange: Use newgrf town resolver as station parent scope handler
peter1138 <peter1138@openttd.org>
parents:
6348
diff
changeset
|
411 if (st != NULL) { |
4595b3acd03d
(svn r9393) -Codechange: Use newgrf town resolver as station parent scope handler
peter1138 <peter1138@openttd.org>
parents:
6348
diff
changeset
|
412 t = st->town; |
4595b3acd03d
(svn r9393) -Codechange: Use newgrf town resolver as station parent scope handler
peter1138 <peter1138@openttd.org>
parents:
6348
diff
changeset
|
413 } else if (tile != INVALID_TILE) { |
9726
06221034cf54
(svn r13851) -Fix (r9393): GetTownByTile() is only valid for houses and roads.
frosch <frosch@openttd.org>
parents:
9714
diff
changeset
|
414 t = ClosestTownFromTile(tile, UINT_MAX); |
6354
4595b3acd03d
(svn r9393) -Codechange: Use newgrf town resolver as station parent scope handler
peter1138 <peter1138@openttd.org>
parents:
6348
diff
changeset
|
415 } else { |
4595b3acd03d
(svn r9393) -Codechange: Use newgrf town resolver as station parent scope handler
peter1138 <peter1138@openttd.org>
parents:
6348
diff
changeset
|
416 *available = false; |
4595b3acd03d
(svn r9393) -Codechange: Use newgrf town resolver as station parent scope handler
peter1138 <peter1138@openttd.org>
parents:
6348
diff
changeset
|
417 return UINT_MAX; |
4595b3acd03d
(svn r9393) -Codechange: Use newgrf town resolver as station parent scope handler
peter1138 <peter1138@openttd.org>
parents:
6348
diff
changeset
|
418 } |
4595b3acd03d
(svn r9393) -Codechange: Use newgrf town resolver as station parent scope handler
peter1138 <peter1138@openttd.org>
parents:
6348
diff
changeset
|
419 |
4595b3acd03d
(svn r9393) -Codechange: Use newgrf town resolver as station parent scope handler
peter1138 <peter1138@openttd.org>
parents:
6348
diff
changeset
|
420 return TownGetVariable(variable, parameter, available, t); |
4595b3acd03d
(svn r9393) -Codechange: Use newgrf town resolver as station parent scope handler
peter1138 <peter1138@openttd.org>
parents:
6348
diff
changeset
|
421 } |
4595b3acd03d
(svn r9393) -Codechange: Use newgrf town resolver as station parent scope handler
peter1138 <peter1138@openttd.org>
parents:
6348
diff
changeset
|
422 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
423 if (st == NULL) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
424 /* Station does not exist, so we're in a purchase list */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
425 switch (variable) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
426 case 0x40: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
427 case 0x41: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
428 case 0x46: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
429 case 0x47: |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10099
diff
changeset
|
430 case 0x49: return 0x2110000; // Platforms, tracks & position |
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10099
diff
changeset
|
431 case 0x42: return 0; // Rail type (XXX Get current type from GUI?) |
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10099
diff
changeset
|
432 case 0x43: return _current_company; // Station owner |
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10099
diff
changeset
|
433 case 0x44: return 2; // PBS status |
7922
ff1975ced735
(svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13 <skidd13@openttd.org>
parents:
7642
diff
changeset
|
434 case 0xFA: return Clamp(_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 65535); // Build date, clamped to a 16 bit value |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
435 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
436 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
437 *available = false; |
5587
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
438 return UINT_MAX; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
439 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
440 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
441 switch (variable) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
442 /* Calculated station variables */ |
7230
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
443 case 0x40: |
7931
44ff7a6d801f
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7928
diff
changeset
|
444 if (!HasBit(_svc.valid, 0)) { _svc.v40 = GetPlatformInfoHelper(tile, false, false, false); SetBit(_svc.valid, 0); } |
7230
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
445 return _svc.v40; |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
446 |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
447 case 0x41: |
7931
44ff7a6d801f
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7928
diff
changeset
|
448 if (!HasBit(_svc.valid, 1)) { _svc.v41 = GetPlatformInfoHelper(tile, true, false, false); SetBit(_svc.valid, 1); } |
7230
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
449 return _svc.v41; |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
450 |
6849
cbe1a12e652d
(svn r10089) -Fix (r10040): Use GetTileZ instead of GetClearGround in GetTerrainType as
maedhros <maedhros@openttd.org>
parents:
6683
diff
changeset
|
451 case 0x42: return GetTerrainType(tile) | (GetRailType(tile) << 8); |
6348
bcf98ba27bbf
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas <belugas@openttd.org>
parents:
6343
diff
changeset
|
452 case 0x43: return st->owner; // Station owner |
9823
7e2bcaec0fc7
(svn r13965) -Add [YAPP]: Implement newgrf var 0x44 for stations (PBS reservation state). (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9750
diff
changeset
|
453 case 0x44: |
10099
3bb7e18e8b0a
(svn r14280) -Codechange: use IsRailWaypointTile() instead of IsTileType() and IsRailWaypoint() checks at several places
smatz <smatz@openttd.org>
parents:
9823
diff
changeset
|
454 if (IsRailWaypointTile(tile)) { |
9823
7e2bcaec0fc7
(svn r13965) -Add [YAPP]: Implement newgrf var 0x44 for stations (PBS reservation state). (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9750
diff
changeset
|
455 return GetDepotWaypointReservation(tile) ? 7 : 4; |
7e2bcaec0fc7
(svn r13965) -Add [YAPP]: Implement newgrf var 0x44 for stations (PBS reservation state). (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9750
diff
changeset
|
456 } else { |
7e2bcaec0fc7
(svn r13965) -Add [YAPP]: Implement newgrf var 0x44 for stations (PBS reservation state). (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9750
diff
changeset
|
457 return GetRailwayStationReservation(tile) ? 7 : 4; // PBS status |
7e2bcaec0fc7
(svn r13965) -Add [YAPP]: Implement newgrf var 0x44 for stations (PBS reservation state). (michi_cc)
rubidium <rubidium@openttd.org>
parents:
9750
diff
changeset
|
458 } |
7230
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
459 case 0x45: |
7931
44ff7a6d801f
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7928
diff
changeset
|
460 if (!HasBit(_svc.valid, 2)) { _svc.v45 = GetRailContinuationInfo(tile); SetBit(_svc.valid, 2); } |
7230
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
461 return _svc.v45; |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
462 |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
463 case 0x46: |
7931
44ff7a6d801f
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7928
diff
changeset
|
464 if (!HasBit(_svc.valid, 3)) { _svc.v46 = GetPlatformInfoHelper(tile, false, false, true); SetBit(_svc.valid, 3); } |
7230
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
465 return _svc.v46; |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
466 |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
467 case 0x47: |
7931
44ff7a6d801f
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7928
diff
changeset
|
468 if (!HasBit(_svc.valid, 4)) { _svc.v47 = GetPlatformInfoHelper(tile, true, false, true); SetBit(_svc.valid, 4); } |
7230
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
469 return _svc.v47; |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
470 |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
471 case 0x49: |
7931
44ff7a6d801f
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7928
diff
changeset
|
472 if (!HasBit(_svc.valid, 5)) { _svc.v49 = GetPlatformInfoHelper(tile, false, true, false); SetBit(_svc.valid, 5); } |
7230
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
473 return _svc.v49; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
474 |
8956
9368ed6c6424
(svn r12747) -Codechange: Add varaction retrieval of station animation frame
peter1138 <peter1138@openttd.org>
parents:
8906
diff
changeset
|
475 case 0x4A: // Animation frame of tile |
9368ed6c6424
(svn r12747) -Codechange: Add varaction retrieval of station animation frame
peter1138 <peter1138@openttd.org>
parents:
8906
diff
changeset
|
476 return GetStationAnimationFrame(tile); |
9368ed6c6424
(svn r12747) -Codechange: Add varaction retrieval of station animation frame
peter1138 <peter1138@openttd.org>
parents:
8906
diff
changeset
|
477 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
478 /* Variables which use the parameter */ |
6460
cebf3bbc9227
(svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
peter1138 <peter1138@openttd.org>
parents:
6451
diff
changeset
|
479 /* Variables 0x60 to 0x65 are handled separately below */ |
8956
9368ed6c6424
(svn r12747) -Codechange: Add varaction retrieval of station animation frame
peter1138 <peter1138@openttd.org>
parents:
8906
diff
changeset
|
480 case 0x66: // Animation frame of nearby tile |
9368ed6c6424
(svn r12747) -Codechange: Add varaction retrieval of station animation frame
peter1138 <peter1138@openttd.org>
parents:
8906
diff
changeset
|
481 if (parameter != 0) tile = GetNearbyTile(parameter, tile); |
9368ed6c6424
(svn r12747) -Codechange: Add varaction retrieval of station animation frame
peter1138 <peter1138@openttd.org>
parents:
8906
diff
changeset
|
482 return st->TileBelongsToRailStation(tile) ? GetStationAnimationFrame(tile) : UINT_MAX; |
9368ed6c6424
(svn r12747) -Codechange: Add varaction retrieval of station animation frame
peter1138 <peter1138@openttd.org>
parents:
8906
diff
changeset
|
483 |
9368ed6c6424
(svn r12747) -Codechange: Add varaction retrieval of station animation frame
peter1138 <peter1138@openttd.org>
parents:
8906
diff
changeset
|
484 case 0x67: { // Land info of nearby tile |
8118
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
485 Axis axis = GetRailStationAxis(tile); |
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
486 |
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
487 if (parameter != 0) tile = GetNearbyTile(parameter, tile); // only perform if it is required |
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
488 |
8458
44b11233507f
(svn r12028) -Codechange: Split common part of station var 0x67, house var 0x62, indtile var 0x60 and industry var 0x62 to 'newgrf_commons.cpp'.
frosch <frosch@openttd.org>
parents:
8316
diff
changeset
|
489 Slope tileh = GetTileSlope(tile, NULL); |
44b11233507f
(svn r12028) -Codechange: Split common part of station var 0x67, house var 0x62, indtile var 0x60 and industry var 0x62 to 'newgrf_commons.cpp'.
frosch <frosch@openttd.org>
parents:
8316
diff
changeset
|
490 bool swap = (axis == AXIS_Y && HasBit(tileh, SLOPE_W) != HasBit(tileh, SLOPE_E)); |
44b11233507f
(svn r12028) -Codechange: Split common part of station var 0x67, house var 0x62, indtile var 0x60 and industry var 0x62 to 'newgrf_commons.cpp'.
frosch <frosch@openttd.org>
parents:
8316
diff
changeset
|
491 |
44b11233507f
(svn r12028) -Codechange: Split common part of station var 0x67, house var 0x62, indtile var 0x60 and industry var 0x62 to 'newgrf_commons.cpp'.
frosch <frosch@openttd.org>
parents:
8316
diff
changeset
|
492 return GetNearbyTileInformation(tile) ^ (swap ? SLOPE_EW : 0); |
8118
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
493 } |
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
494 |
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
495 case 0x68: { // Station info of nearby tiles |
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
496 TileIndex nearby_tile = GetNearbyTile(parameter, tile); |
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
497 |
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
498 if (!IsRailwayStationTile(nearby_tile)) return 0xFFFFFFFF; |
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
499 |
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
500 uint32 grfid = st->speclist[GetCustomStationSpecIndex(tile)].grfid; |
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
501 bool perpendicular = GetRailStationAxis(tile) != GetRailStationAxis(nearby_tile); |
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
502 bool same_station = st->TileBelongsToRailStation(nearby_tile); |
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
503 uint32 res = GB(GetStationGfx(nearby_tile), 1, 2) << 12 | !!perpendicular << 11 | !!same_station << 10; |
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
504 |
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
505 if (IsCustomStationSpecIndex(nearby_tile)) { |
12425
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
506 const StationSpecList ssl = BaseStation::GetByTile(nearby_tile)->speclist[GetCustomStationSpecIndex(nearby_tile)]; |
8118
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
507 res |= 1 << (ssl.grfid != grfid ? 9 : 8) | ssl.localidx; |
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
508 } |
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
509 return res; |
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
510 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
511 |
12430
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
512 /* General station variables */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
513 case 0x82: return 50; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
514 case 0x84: return st->string_id; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
515 case 0x86: return 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
516 case 0xF0: return st->facilities; |
7922
ff1975ced735
(svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13 <skidd13@openttd.org>
parents:
7642
diff
changeset
|
517 case 0xFA: return Clamp(st->build_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 65535); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
518 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
519 |
12425
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
520 return st->GetNewGRFVariable(object, variable, parameter, available); |
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
521 } |
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
522 |
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
523 uint32 Station::GetNewGRFVariable(const ResolverObject *object, byte variable, byte parameter, bool *available) const |
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
524 { |
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
525 switch (variable) { |
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
526 case 0x48: { // Accepted cargo types |
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
527 CargoID cargo_type; |
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
528 uint32 value = 0; |
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
529 |
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
530 for (cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) { |
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
531 if (HasBit(this->goods[cargo_type].acceptance_pickup, GoodsEntry::PICKUP)) SetBit(value, cargo_type); |
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
532 } |
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
533 return value; |
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
534 } |
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
535 |
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
536 case 0x8A: return this->had_vehicle_of_type; |
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
537 case 0xF1: return this->airport_type; |
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
538 case 0xF2: return this->truck_stops->status; |
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
539 case 0xF3: return this->bus_stops->status; |
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
540 case 0xF6: return this->airport_flags; |
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
541 case 0xF7: return GB(this->airport_flags, 8, 8); |
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
542 } |
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
543 |
6460
cebf3bbc9227
(svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
peter1138 <peter1138@openttd.org>
parents:
6451
diff
changeset
|
544 /* Handle cargo variables with parameter, 0x60 to 0x65 */ |
cebf3bbc9227
(svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
peter1138 <peter1138@openttd.org>
parents:
6451
diff
changeset
|
545 if (variable >= 0x60 && variable <= 0x65) { |
cebf3bbc9227
(svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
peter1138 <peter1138@openttd.org>
parents:
6451
diff
changeset
|
546 CargoID c = GetCargoTranslation(parameter, object->u.station.statspec->grffile); |
cebf3bbc9227
(svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
peter1138 <peter1138@openttd.org>
parents:
6451
diff
changeset
|
547 |
cebf3bbc9227
(svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
peter1138 <peter1138@openttd.org>
parents:
6451
diff
changeset
|
548 if (c == CT_INVALID) return 0; |
12425
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
549 const GoodsEntry *ge = &this->goods[c]; |
6460
cebf3bbc9227
(svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
peter1138 <peter1138@openttd.org>
parents:
6451
diff
changeset
|
550 |
cebf3bbc9227
(svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
peter1138 <peter1138@openttd.org>
parents:
6451
diff
changeset
|
551 switch (variable) { |
7010
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6849
diff
changeset
|
552 case 0x60: return min(ge->cargo.Count(), 4095); |
6460
cebf3bbc9227
(svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
peter1138 <peter1138@openttd.org>
parents:
6451
diff
changeset
|
553 case 0x61: return ge->days_since_pickup; |
cebf3bbc9227
(svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
peter1138 <peter1138@openttd.org>
parents:
6451
diff
changeset
|
554 case 0x62: return ge->rating; |
7010
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6849
diff
changeset
|
555 case 0x63: return ge->cargo.DaysInTransit(); |
6460
cebf3bbc9227
(svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
peter1138 <peter1138@openttd.org>
parents:
6451
diff
changeset
|
556 case 0x64: return ge->last_speed | (ge->last_age << 8); |
7474
7b35fd1cc99d
(svn r10981) -Fix [FS#1156] (r10970): stations gave ratings for accepted cargo too.
rubidium <rubidium@openttd.org>
parents:
7327
diff
changeset
|
557 case 0x65: return GB(ge->acceptance_pickup, GoodsEntry::ACCEPTANCE, 1) << 3; |
6460
cebf3bbc9227
(svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
peter1138 <peter1138@openttd.org>
parents:
6451
diff
changeset
|
558 } |
cebf3bbc9227
(svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
peter1138 <peter1138@openttd.org>
parents:
6451
diff
changeset
|
559 } |
cebf3bbc9227
(svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
peter1138 <peter1138@openttd.org>
parents:
6451
diff
changeset
|
560 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
561 /* Handle cargo variables (deprecated) */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
562 if (variable >= 0x8C && variable <= 0xEC) { |
12425
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
563 const GoodsEntry *g = &this->goods[GB(variable - 0x8C, 3, 4)]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
564 switch (GB(variable - 0x8C, 0, 3)) { |
7010
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6849
diff
changeset
|
565 case 0: return g->cargo.Count(); |
7474
7b35fd1cc99d
(svn r10981) -Fix [FS#1156] (r10970): stations gave ratings for accepted cargo too.
rubidium <rubidium@openttd.org>
parents:
7327
diff
changeset
|
566 case 1: return GB(min(g->cargo.Count(), 4095), 0, 4) | (GB(g->acceptance_pickup, GoodsEntry::ACCEPTANCE, 1) << 7); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
567 case 2: return g->days_since_pickup; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
568 case 3: return g->rating; |
7010
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6849
diff
changeset
|
569 case 4: return g->cargo.Source(); |
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6849
diff
changeset
|
570 case 5: return g->cargo.DaysInTransit(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
571 case 6: return g->last_speed; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
572 case 7: return g->last_age; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
573 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
574 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
575 |
12430
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
576 DEBUG(grf, 1, "Unhandled station variable 0x%X", variable); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
577 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
578 *available = false; |
5587
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
579 return UINT_MAX; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
580 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
581 |
12430
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
582 uint32 Waypoint::GetNewGRFVariable(const ResolverObject *object, byte variable, byte parameter, bool *available) const |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
583 { |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
584 switch (variable) { |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
585 case 0x48: return 0; // Accepted cargo types |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
586 case 0x8A: return HVOT_TRAIN; |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
587 case 0xF1: return 0; // airport type |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
588 case 0xF2: return 0; // truck stop status |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
589 case 0xF3: return 0; // bus stop status |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
590 case 0xF6: return 0; // airport flags |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
591 case 0xF7: return 0; // airport flags cont. |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
592 } |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
593 |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
594 /* Handle cargo variables with parameter, 0x60 to 0x65 */ |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
595 if (variable >= 0x60 && variable <= 0x65) { |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
596 return 0; |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
597 } |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
598 |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
599 /* Handle cargo variables (deprecated) */ |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
600 if (variable >= 0x8C && variable <= 0xEC) { |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
601 switch (GB(variable - 0x8C, 0, 3)) { |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
602 case 3: return INITIAL_STATION_RATING; |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
603 case 4: return INVALID_STATION; |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
604 default: return 0; |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
605 } |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
606 } |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
607 |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
608 DEBUG(grf, 1, "Unhandled station variable 0x%X", variable); |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
609 |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
610 *available = false; |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
611 return UINT_MAX; |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
612 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
613 |
11990
db0e49f419d9
(svn r16396) -Codechange: split NewGRF spritegroup into multiple subclasses instead of using a big union
rubidium <rubidium@openttd.org>
parents:
11586
diff
changeset
|
614 static const SpriteGroup *StationResolveReal(const ResolverObject *object, const RealSpriteGroup *group) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
615 { |
12425
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
616 const BaseStation *bst = object->u.station.st; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
617 const StationSpec *statspec = object->u.station.statspec; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
618 uint set; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
619 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
620 uint cargo = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
621 CargoID cargo_type = object->u.station.cargo_type; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
622 |
12425
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
623 if (bst == NULL || statspec->sclass == STAT_CLASS_WAYP) { |
11990
db0e49f419d9
(svn r16396) -Codechange: split NewGRF spritegroup into multiple subclasses instead of using a big union
rubidium <rubidium@openttd.org>
parents:
11586
diff
changeset
|
624 return group->loading[0]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
625 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
626 |
12425
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
627 const Station *st = Station::From(bst); |
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
628 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
629 switch (cargo_type) { |
6148
4b171c8e99ce
(svn r8891) -Codechange: Remove remains of global cargo scheme. All cargo mapping is now dealt with only in NewGRF code, on load where possible.
peter1138 <peter1138@openttd.org>
parents:
6122
diff
changeset
|
630 case CT_INVALID: |
4b171c8e99ce
(svn r8891) -Codechange: Remove remains of global cargo scheme. All cargo mapping is now dealt with only in NewGRF code, on load where possible.
peter1138 <peter1138@openttd.org>
parents:
6122
diff
changeset
|
631 case CT_DEFAULT_NA: |
4b171c8e99ce
(svn r8891) -Codechange: Remove remains of global cargo scheme. All cargo mapping is now dealt with only in NewGRF code, on load where possible.
peter1138 <peter1138@openttd.org>
parents:
6122
diff
changeset
|
632 case CT_PURCHASE: |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
633 cargo = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
634 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
635 |
6148
4b171c8e99ce
(svn r8891) -Codechange: Remove remains of global cargo scheme. All cargo mapping is now dealt with only in NewGRF code, on load where possible.
peter1138 <peter1138@openttd.org>
parents:
6122
diff
changeset
|
636 case CT_DEFAULT: |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
637 for (cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) { |
7010
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6849
diff
changeset
|
638 cargo += st->goods[cargo_type].cargo.Count(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
639 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
640 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
641 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
642 default: |
7010
f0f87c5a431e
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents:
6849
diff
changeset
|
643 cargo = st->goods[cargo_type].cargo.Count(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
644 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
645 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
646 |
11585
a5688eed8d7a
(svn r15956) -Codechange: Enumorize station spec flags.
peter1138 <peter1138@openttd.org>
parents:
11091
diff
changeset
|
647 if (HasBit(statspec->flags, SSF_DIV_BY_STATION_SIZE)) cargo /= (st->trainst_w + st->trainst_h); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
648 cargo = min(0xfff, cargo); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
649 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
650 if (cargo > statspec->cargo_threshold) { |
11990
db0e49f419d9
(svn r16396) -Codechange: split NewGRF spritegroup into multiple subclasses instead of using a big union
rubidium <rubidium@openttd.org>
parents:
11586
diff
changeset
|
651 if (group->num_loading > 0) { |
db0e49f419d9
(svn r16396) -Codechange: split NewGRF spritegroup into multiple subclasses instead of using a big union
rubidium <rubidium@openttd.org>
parents:
11586
diff
changeset
|
652 set = ((cargo - statspec->cargo_threshold) * group->num_loading) / (4096 - statspec->cargo_threshold); |
db0e49f419d9
(svn r16396) -Codechange: split NewGRF spritegroup into multiple subclasses instead of using a big union
rubidium <rubidium@openttd.org>
parents:
11586
diff
changeset
|
653 return group->loading[set]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
654 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
655 } else { |
11990
db0e49f419d9
(svn r16396) -Codechange: split NewGRF spritegroup into multiple subclasses instead of using a big union
rubidium <rubidium@openttd.org>
parents:
11586
diff
changeset
|
656 if (group->num_loaded > 0) { |
db0e49f419d9
(svn r16396) -Codechange: split NewGRF spritegroup into multiple subclasses instead of using a big union
rubidium <rubidium@openttd.org>
parents:
11586
diff
changeset
|
657 set = (cargo * group->num_loaded) / (statspec->cargo_threshold + 1); |
db0e49f419d9
(svn r16396) -Codechange: split NewGRF spritegroup into multiple subclasses instead of using a big union
rubidium <rubidium@openttd.org>
parents:
11586
diff
changeset
|
658 return group->loaded[set]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
659 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
660 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
661 |
11990
db0e49f419d9
(svn r16396) -Codechange: split NewGRF spritegroup into multiple subclasses instead of using a big union
rubidium <rubidium@openttd.org>
parents:
11586
diff
changeset
|
662 return group->loading[0]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
663 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
664 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
665 |
12425
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
666 static void NewStationResolver(ResolverObject *res, const StationSpec *statspec, const BaseStation *st, TileIndex tile) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
667 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
668 res->GetRandomBits = StationGetRandomBits; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
669 res->GetTriggers = StationGetTriggers; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
670 res->SetTriggers = StationSetTriggers; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
671 res->GetVariable = StationGetVariable; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
672 res->ResolveReal = StationResolveReal; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
673 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
674 res->u.station.st = st; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
675 res->u.station.statspec = statspec; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
676 res->u.station.tile = tile; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
677 |
7327
0ab2820a1e52
(svn r10690) -Codechange: use the enum that describes all callback IDs in favor of "just" using an untyped integer.
rubidium <rubidium@openttd.org>
parents:
7272
diff
changeset
|
678 res->callback = CBID_NO_CALLBACK; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
679 res->callback_param1 = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
680 res->callback_param2 = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
681 res->last_value = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
682 res->trigger = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
683 res->reseed = 0; |
8756
ae0ec91bb55e
(svn r12452) -Feature: [NewGRF] Add random action 2 type 84. For vehicles only.
glx <glx@openttd.org>
parents:
8695
diff
changeset
|
684 res->count = 0; |
9750
0654bf387d06
(svn r13885) -Fix [FS#2168]: Var 0x7F is not feature-specific.
frosch <frosch@openttd.org>
parents:
9726
diff
changeset
|
685 res->grffile = (statspec != NULL ? statspec->grffile : NULL); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
686 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
687 |
5849 | 688 static const SpriteGroup *ResolveStation(ResolverObject *object) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
689 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
690 const SpriteGroup *group; |
6148
4b171c8e99ce
(svn r8891) -Codechange: Remove remains of global cargo scheme. All cargo mapping is now dealt with only in NewGRF code, on load where possible.
peter1138 <peter1138@openttd.org>
parents:
6122
diff
changeset
|
691 CargoID ctype = CT_DEFAULT_NA; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
692 |
5849 | 693 if (object->u.station.st == NULL) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
694 /* No station, so we are in a purchase list */ |
6148
4b171c8e99ce
(svn r8891) -Codechange: Remove remains of global cargo scheme. All cargo mapping is now dealt with only in NewGRF code, on load where possible.
peter1138 <peter1138@openttd.org>
parents:
6122
diff
changeset
|
695 ctype = CT_PURCHASE; |
12454
737f00243322
(svn r16888) -Fix (r16864): crash when trying to build (some?) NewGRF waypoints
rubidium <rubidium@openttd.org>
parents:
12430
diff
changeset
|
696 } else if (Station::IsExpected(object->u.station.st)) { |
12425
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
697 const Station *st = Station::From(object->u.station.st); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
698 /* Pick the first cargo that we have waiting */ |
12418
0d8340a4c70e
(svn r16852) -Codechange: use FOR_ALL_CARGOSPECS for iterating over all valid CargoSpecs
smatz <smatz@openttd.org>
parents:
12415
diff
changeset
|
699 const CargoSpec *cs; |
0d8340a4c70e
(svn r16852) -Codechange: use FOR_ALL_CARGOSPECS for iterating over all valid CargoSpecs
smatz <smatz@openttd.org>
parents:
12415
diff
changeset
|
700 FOR_ALL_CARGOSPECS(cs) { |
0d8340a4c70e
(svn r16852) -Codechange: use FOR_ALL_CARGOSPECS for iterating over all valid CargoSpecs
smatz <smatz@openttd.org>
parents:
12415
diff
changeset
|
701 if (object->u.station.statspec->spritegroup[cs->Index()] != NULL && |
12425
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
702 !st->goods[cs->Index()].cargo.Empty()) { |
12418
0d8340a4c70e
(svn r16852) -Codechange: use FOR_ALL_CARGOSPECS for iterating over all valid CargoSpecs
smatz <smatz@openttd.org>
parents:
12415
diff
changeset
|
703 ctype = cs->Index(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
704 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
705 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
706 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
707 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
708 |
5849 | 709 group = object->u.station.statspec->spritegroup[ctype]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
710 if (group == NULL) { |
6148
4b171c8e99ce
(svn r8891) -Codechange: Remove remains of global cargo scheme. All cargo mapping is now dealt with only in NewGRF code, on load where possible.
peter1138 <peter1138@openttd.org>
parents:
6122
diff
changeset
|
711 ctype = CT_DEFAULT; |
5849 | 712 group = object->u.station.statspec->spritegroup[ctype]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
713 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
714 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
715 if (group == NULL) return NULL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
716 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
717 /* Remember the cargo type we've picked */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
718 object->u.station.cargo_type = ctype; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
719 |
7230
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
720 /* Invalidate all cached vars */ |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
721 _svc.valid = 0; |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
722 |
11996
b43cf6c7ea61
(svn r16402) -Codechange: make Resolve a function of SpriteGroup
rubidium <rubidium@openttd.org>
parents:
11990
diff
changeset
|
723 return SpriteGroup::Resolve(group, object); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
724 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
725 |
12425
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
726 SpriteID GetCustomStationRelocation(const StationSpec *statspec, const BaseStation *st, TileIndex tile) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
727 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
728 const SpriteGroup *group; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
729 ResolverObject object; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
730 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
731 NewStationResolver(&object, statspec, st, tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
732 |
5849 | 733 group = ResolveStation(&object); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
734 if (group == NULL || group->type != SGT_RESULT) return 0; |
11990
db0e49f419d9
(svn r16396) -Codechange: split NewGRF spritegroup into multiple subclasses instead of using a big union
rubidium <rubidium@openttd.org>
parents:
11586
diff
changeset
|
735 return group->GetResult() - 0x42D; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
736 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
737 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
738 |
12425
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
739 SpriteID GetCustomStationGroundRelocation(const StationSpec *statspec, const BaseStation *st, TileIndex tile) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
740 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
741 const SpriteGroup *group; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
742 ResolverObject object; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
743 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
744 NewStationResolver(&object, statspec, st, tile); |
11586
97ba565c6123
(svn r15957) -Fix (r4767): Set callback_param1 (var 10) to 1 only when requested.
peter1138 <peter1138@openttd.org>
parents:
11585
diff
changeset
|
745 if (HasBit(statspec->flags, SSF_SEPARATE_GROUND)) { |
97ba565c6123
(svn r15957) -Fix (r4767): Set callback_param1 (var 10) to 1 only when requested.
peter1138 <peter1138@openttd.org>
parents:
11585
diff
changeset
|
746 object.callback_param1 = 1; // Indicate we are resolving the ground sprite |
97ba565c6123
(svn r15957) -Fix (r4767): Set callback_param1 (var 10) to 1 only when requested.
peter1138 <peter1138@openttd.org>
parents:
11585
diff
changeset
|
747 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
748 |
5849 | 749 group = ResolveStation(&object); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
750 if (group == NULL || group->type != SGT_RESULT) return 0; |
11990
db0e49f419d9
(svn r16396) -Codechange: split NewGRF spritegroup into multiple subclasses instead of using a big union
rubidium <rubidium@openttd.org>
parents:
11586
diff
changeset
|
751 return group->GetResult() - 0x42D; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
752 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
753 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
754 |
12425
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
755 uint16 GetStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, const BaseStation *st, TileIndex tile) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
756 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
757 const SpriteGroup *group; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
758 ResolverObject object; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
759 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
760 NewStationResolver(&object, statspec, st, tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
761 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
762 object.callback = callback; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
763 object.callback_param1 = param1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
764 object.callback_param2 = param2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
765 |
5849 | 766 group = ResolveStation(&object); |
11990
db0e49f419d9
(svn r16396) -Codechange: split NewGRF spritegroup into multiple subclasses instead of using a big union
rubidium <rubidium@openttd.org>
parents:
11586
diff
changeset
|
767 if (group == NULL) return CALLBACK_FAILED; |
db0e49f419d9
(svn r16396) -Codechange: split NewGRF spritegroup into multiple subclasses instead of using a big union
rubidium <rubidium@openttd.org>
parents:
11586
diff
changeset
|
768 return group->GetCallbackResult(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
769 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
770 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
771 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
772 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
773 * Allocate a StationSpec to a Station. This is called once per build operation. |
6481
85a1a79387a2
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents:
6460
diff
changeset
|
774 * @param statspec StationSpec to allocate. |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
775 * @param st Station to allocate it to. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
776 * @param exec Whether to actually allocate the spec. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
777 * @return Index within the Station's spec list, or -1 if the allocation failed. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
778 */ |
12462
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
779 int AllocateSpecToStation(const StationSpec *statspec, BaseStation *st, bool exec) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
780 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
781 uint i; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
782 |
9038
6e86ab2cba9f
(svn r12857) -Fix [FS#1948]: remove the last uses of AutoPtr in the station code.
rubidium <rubidium@openttd.org>
parents:
9018
diff
changeset
|
783 if (statspec == NULL || st == NULL) return 0; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
784 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
785 for (i = 1; i < st->num_specs && i < MAX_SPECLIST; i++) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
786 if (st->speclist[i].spec == NULL && st->speclist[i].grfid == 0) break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
787 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
788 |
10654
2ee530966ead
(svn r14956) -Fix [FS#1832]: building new station parts didn't allocate a new station spec effectively breaking variable 41. This was due to the limited number of station specs that we can have per station. This fix makes newly build station parts create a new spec until one cannot allocate new station specs anymore and it'll revert to the old behaviour (sharing station specs).
rubidium <rubidium@openttd.org>
parents:
10647
diff
changeset
|
789 if (i == MAX_SPECLIST) { |
2ee530966ead
(svn r14956) -Fix [FS#1832]: building new station parts didn't allocate a new station spec effectively breaking variable 41. This was due to the limited number of station specs that we can have per station. This fix makes newly build station parts create a new spec until one cannot allocate new station specs anymore and it'll revert to the old behaviour (sharing station specs).
rubidium <rubidium@openttd.org>
parents:
10647
diff
changeset
|
790 /* As final effort when the spec list is already full... |
2ee530966ead
(svn r14956) -Fix [FS#1832]: building new station parts didn't allocate a new station spec effectively breaking variable 41. This was due to the limited number of station specs that we can have per station. This fix makes newly build station parts create a new spec until one cannot allocate new station specs anymore and it'll revert to the old behaviour (sharing station specs).
rubidium <rubidium@openttd.org>
parents:
10647
diff
changeset
|
791 * try to find the same spec and return that one. This might |
2ee530966ead
(svn r14956) -Fix [FS#1832]: building new station parts didn't allocate a new station spec effectively breaking variable 41. This was due to the limited number of station specs that we can have per station. This fix makes newly build station parts create a new spec until one cannot allocate new station specs anymore and it'll revert to the old behaviour (sharing station specs).
rubidium <rubidium@openttd.org>
parents:
10647
diff
changeset
|
792 * result in slighty "wrong" (as per specs) looking stations, |
2ee530966ead
(svn r14956) -Fix [FS#1832]: building new station parts didn't allocate a new station spec effectively breaking variable 41. This was due to the limited number of station specs that we can have per station. This fix makes newly build station parts create a new spec until one cannot allocate new station specs anymore and it'll revert to the old behaviour (sharing station specs).
rubidium <rubidium@openttd.org>
parents:
10647
diff
changeset
|
793 * but it's fairly unlikely that one reaches the limit anyways. |
2ee530966ead
(svn r14956) -Fix [FS#1832]: building new station parts didn't allocate a new station spec effectively breaking variable 41. This was due to the limited number of station specs that we can have per station. This fix makes newly build station parts create a new spec until one cannot allocate new station specs anymore and it'll revert to the old behaviour (sharing station specs).
rubidium <rubidium@openttd.org>
parents:
10647
diff
changeset
|
794 */ |
2ee530966ead
(svn r14956) -Fix [FS#1832]: building new station parts didn't allocate a new station spec effectively breaking variable 41. This was due to the limited number of station specs that we can have per station. This fix makes newly build station parts create a new spec until one cannot allocate new station specs anymore and it'll revert to the old behaviour (sharing station specs).
rubidium <rubidium@openttd.org>
parents:
10647
diff
changeset
|
795 for (i = 1; i < st->num_specs && i < MAX_SPECLIST; i++) { |
2ee530966ead
(svn r14956) -Fix [FS#1832]: building new station parts didn't allocate a new station spec effectively breaking variable 41. This was due to the limited number of station specs that we can have per station. This fix makes newly build station parts create a new spec until one cannot allocate new station specs anymore and it'll revert to the old behaviour (sharing station specs).
rubidium <rubidium@openttd.org>
parents:
10647
diff
changeset
|
796 if (st->speclist[i].spec == statspec) return i; |
2ee530966ead
(svn r14956) -Fix [FS#1832]: building new station parts didn't allocate a new station spec effectively breaking variable 41. This was due to the limited number of station specs that we can have per station. This fix makes newly build station parts create a new spec until one cannot allocate new station specs anymore and it'll revert to the old behaviour (sharing station specs).
rubidium <rubidium@openttd.org>
parents:
10647
diff
changeset
|
797 } |
2ee530966ead
(svn r14956) -Fix [FS#1832]: building new station parts didn't allocate a new station spec effectively breaking variable 41. This was due to the limited number of station specs that we can have per station. This fix makes newly build station parts create a new spec until one cannot allocate new station specs anymore and it'll revert to the old behaviour (sharing station specs).
rubidium <rubidium@openttd.org>
parents:
10647
diff
changeset
|
798 |
2ee530966ead
(svn r14956) -Fix [FS#1832]: building new station parts didn't allocate a new station spec effectively breaking variable 41. This was due to the limited number of station specs that we can have per station. This fix makes newly build station parts create a new spec until one cannot allocate new station specs anymore and it'll revert to the old behaviour (sharing station specs).
rubidium <rubidium@openttd.org>
parents:
10647
diff
changeset
|
799 return -1; |
2ee530966ead
(svn r14956) -Fix [FS#1832]: building new station parts didn't allocate a new station spec effectively breaking variable 41. This was due to the limited number of station specs that we can have per station. This fix makes newly build station parts create a new spec until one cannot allocate new station specs anymore and it'll revert to the old behaviour (sharing station specs).
rubidium <rubidium@openttd.org>
parents:
10647
diff
changeset
|
800 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
801 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
802 if (exec) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
803 if (i >= st->num_specs) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
804 st->num_specs = i + 1; |
5609
358c07fb3212
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr <KUDr@openttd.org>
parents:
5587
diff
changeset
|
805 st->speclist = ReallocT(st->speclist, st->num_specs); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
806 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
807 if (st->num_specs == 2) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
808 /* Initial allocation */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
809 st->speclist[0].spec = NULL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
810 st->speclist[0].grfid = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
811 st->speclist[0].localidx = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
812 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
813 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
814 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
815 st->speclist[i].spec = statspec; |
6451
25c7793c8d9a
(svn r9601) -Codechange: Store grf file reference in station spec, not just GRF ID
peter1138 <peter1138@openttd.org>
parents:
6357
diff
changeset
|
816 st->speclist[i].grfid = statspec->grffile->grfid; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
817 st->speclist[i].localidx = statspec->localidx; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
818 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
819 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
820 return i; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
821 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
822 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
823 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
824 /** Deallocate a StationSpec from a Station. Called when removing a single station tile. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
825 * @param st Station to work with. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
826 * @param specindex Index of the custom station within the Station's spec list. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
827 * @return Indicates whether the StationSpec was deallocated. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
828 */ |
12462
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
829 void DeallocateSpecFromStation(BaseStation *st, byte specindex) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
830 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
831 /* specindex of 0 (default) is never freeable */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
832 if (specindex == 0) return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
833 |
12462
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
834 ETileArea area = ETileArea(st, INVALID_TILE, TA_WHOLE); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
835 /* Check all tiles over the station to check if the specindex is still in use */ |
12462
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
836 for (uint y = 0; y < area.h; y++) { |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
837 for (uint x = 0; x < area.w; x++) { |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
838 if (st->TileBelongsToRailStation(area.tile) && GetCustomStationSpecIndex(area.tile) == specindex) { |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
839 return; |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
840 } |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
841 area.tile += TileDiffXY(1, 0); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
842 } |
12462
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
843 area.tile += TileDiffXY(-area.w, 1); |
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
844 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
845 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
846 /* This specindex is no longer in use, so deallocate it */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
847 st->speclist[specindex].spec = NULL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
848 st->speclist[specindex].grfid = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
849 st->speclist[specindex].localidx = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
850 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
851 /* If this was the highest spec index, reallocate */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
852 if (specindex == st->num_specs - 1) { |
8695
9ee0730039f4
(svn r12368) -Codechange: use explicit body for loops and conditions and remove -Wno-empty-body from the configure script
smatz <smatz@openttd.org>
parents:
8616
diff
changeset
|
853 for (; st->speclist[st->num_specs - 1].grfid == 0 && st->num_specs > 1; st->num_specs--) {} |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
854 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
855 if (st->num_specs > 1) { |
5609
358c07fb3212
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr <KUDr@openttd.org>
parents:
5587
diff
changeset
|
856 st->speclist = ReallocT(st->speclist, st->num_specs); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
857 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
858 free(st->speclist); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
859 st->num_specs = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
860 st->speclist = NULL; |
9003
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
861 st->cached_anim_triggers = 0; |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
862 return; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
863 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
864 } |
9003
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
865 |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
866 StationUpdateAnimTriggers(st); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
867 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
868 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
869 /** Draw representation of a station tile for GUI purposes. |
6481
85a1a79387a2
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents:
6460
diff
changeset
|
870 * @param x Position x of image. |
85a1a79387a2
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents:
6460
diff
changeset
|
871 * @param y Position y of image. |
85a1a79387a2
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents:
6460
diff
changeset
|
872 * @param axis Axis. |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
873 * @param railtype Rail type. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
874 * @param sclass, station Type of station. |
6481
85a1a79387a2
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents:
6460
diff
changeset
|
875 * @param station station ID |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
876 * @return True if the tile was drawn (allows for fallback to default graphic) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
877 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
878 bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
879 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
880 const StationSpec *statspec; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
881 const DrawTileSprites *sprites; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
882 const DrawTileSeqStruct *seq; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
883 const RailtypeInfo *rti = GetRailTypeInfo(railtype); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
884 SpriteID relocation; |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5609
diff
changeset
|
885 SpriteID image; |
11085
8da1855e9f14
(svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents:
10960
diff
changeset
|
886 SpriteID palette = COMPANY_SPRITE_COLOUR(_local_company); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
887 uint tile = 2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
888 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
889 statspec = GetCustomStationSpec(sclass, station); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
890 if (statspec == NULL) return false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
891 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
892 relocation = GetCustomStationRelocation(statspec, NULL, INVALID_TILE); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
893 |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
894 if (HasBit(statspec->callbackmask, CBM_STATION_SPRITE_LAYOUT)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
895 uint16 callback = GetStationCallback(CBID_STATION_SPRITE_LAYOUT, 0x2110000, 0, statspec, NULL, INVALID_TILE); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
896 if (callback != CALLBACK_FAILED) tile = callback; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
897 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
898 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
899 if (statspec->renderdata == NULL) { |
7272
dc7fb38ec443
(svn r10601) -Codechange: store (and use) the type of stations instead of hardcoding station types by graphics IDs.
rubidium <rubidium@openttd.org>
parents:
7230
diff
changeset
|
900 sprites = GetStationTileLayout(STATION_RAIL, tile + axis); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
901 } else { |
5587
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
902 sprites = &statspec->renderdata[(tile < statspec->tiles) ? tile + axis : (uint)axis]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
903 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
904 |
8571
b611278e4fed
(svn r12149) -Codechange: Merge 'ground_sprite' and 'ground_pal' of DrawTileSprites into one PalSpriteID
frosch <frosch@openttd.org>
parents:
8570
diff
changeset
|
905 image = sprites->ground.sprite; |
10355
f8ae3c876003
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch <frosch@openttd.org>
parents:
10256
diff
changeset
|
906 SpriteID pal = sprites->ground.pal; |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
907 if (HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
908 image += GetCustomStationGroundRelocation(statspec, NULL, INVALID_TILE); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
909 image += rti->custom_ground_offset; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
910 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
911 image += rti->total_offset; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
912 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
913 |
10355
f8ae3c876003
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch <frosch@openttd.org>
parents:
10256
diff
changeset
|
914 DrawSprite(image, GroundSpritePaletteTransform(image, pal, palette), x, y); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
915 |
10256
c0307c0a126c
(svn r14487) -Fix: The station picker preview did not draw child sprites.
frosch <frosch@openttd.org>
parents:
10208
diff
changeset
|
916 Point child_offset = {0, 0}; |
c0307c0a126c
(svn r14487) -Fix: The station picker preview did not draw child sprites.
frosch <frosch@openttd.org>
parents:
10208
diff
changeset
|
917 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
918 foreach_draw_tile_seq(seq, sprites->seq) { |
8570
2b1397dd930a
(svn r12148) -Codechange: Merge 'image' and 'pal' of DrawTileSeqStruct into one PalSpriteID
frosch <frosch@openttd.org>
parents:
8458
diff
changeset
|
919 image = seq->image.sprite; |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
920 if (HasBit(image, SPRITE_MODIFIER_USE_OFFSET)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
921 image += rti->total_offset; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
922 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
923 image += relocation; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
924 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
925 |
10355
f8ae3c876003
(svn r14606) -Codechange: Unify usage of PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOR in spritelayout drawing.
frosch <frosch@openttd.org>
parents:
10256
diff
changeset
|
926 pal = SpriteLayoutPaletteTransform(image, seq->image.pal, palette); |
8906
39d12674a79a
(svn r12674) -Fix [FS#1902]: Colour remaps on station sprites only worked for company colours.
peter1138 <peter1138@openttd.org>
parents:
8785
diff
changeset
|
927 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
928 if ((byte)seq->delta_z != 0x80) { |
10256
c0307c0a126c
(svn r14487) -Fix: The station picker preview did not draw child sprites.
frosch <frosch@openttd.org>
parents:
10208
diff
changeset
|
929 Point pt = RemapCoords(seq->delta_x, seq->delta_y, seq->delta_z); |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5609
diff
changeset
|
930 DrawSprite(image, pal, x + pt.x, y + pt.y); |
10256
c0307c0a126c
(svn r14487) -Fix: The station picker preview did not draw child sprites.
frosch <frosch@openttd.org>
parents:
10208
diff
changeset
|
931 |
c0307c0a126c
(svn r14487) -Fix: The station picker preview did not draw child sprites.
frosch <frosch@openttd.org>
parents:
10208
diff
changeset
|
932 const Sprite *spr = GetSprite(image & SPRITE_MASK, ST_NORMAL); |
c0307c0a126c
(svn r14487) -Fix: The station picker preview did not draw child sprites.
frosch <frosch@openttd.org>
parents:
10208
diff
changeset
|
933 child_offset.x = pt.x + spr->x_offs; |
c0307c0a126c
(svn r14487) -Fix: The station picker preview did not draw child sprites.
frosch <frosch@openttd.org>
parents:
10208
diff
changeset
|
934 child_offset.y = pt.y + spr->y_offs; |
c0307c0a126c
(svn r14487) -Fix: The station picker preview did not draw child sprites.
frosch <frosch@openttd.org>
parents:
10208
diff
changeset
|
935 } else { |
c0307c0a126c
(svn r14487) -Fix: The station picker preview did not draw child sprites.
frosch <frosch@openttd.org>
parents:
10208
diff
changeset
|
936 /* For stations and original spritelayouts delta_x and delta_y are signed */ |
c0307c0a126c
(svn r14487) -Fix: The station picker preview did not draw child sprites.
frosch <frosch@openttd.org>
parents:
10208
diff
changeset
|
937 DrawSprite(image, pal, x + child_offset.x + seq->delta_x, y + child_offset.y + seq->delta_y); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
938 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
939 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
940 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
941 return true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
942 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
943 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
944 |
9714
cb9766ae1255
(svn r13830) -Feature: show additional NewGRF info in the Tile Info window for stations, houses and industries
smatz <smatz@openttd.org>
parents:
9662
diff
changeset
|
945 const StationSpec *GetStationSpec(TileIndex t) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
946 { |
12430
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
947 if (IsRailwayStationTile(t)) { |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
948 if (!IsCustomStationSpecIndex(t)) return NULL; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
949 |
12430
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
950 const BaseStation *st = BaseStation::GetByTile(t); |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
951 uint specindex = GetCustomStationSpecIndex(t); |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
952 return specindex < st->num_specs ? st->speclist[specindex].spec : NULL; |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
953 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
954 |
12430
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
955 if (IsRailWaypointTile(t)) { |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
956 const BaseStation *st = BaseStation::GetByTile(t); |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
957 return st->num_specs != 0 ? st->speclist[0].spec : NULL; |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
958 } |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
959 |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
960 return NULL; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
961 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
962 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
963 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
964 /* Check if a rail station tile is traversable. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
965 * XXX This could be cached (during build) in the map array to save on all the dereferencing */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
966 bool IsStationTileBlocked(TileIndex tile) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
967 { |
10647
592ae9307430
(svn r14949) -Cleanup: pointer coding style
rubidium <rubidium@openttd.org>
parents:
10355
diff
changeset
|
968 const StationSpec *statspec = GetStationSpec(tile); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
969 |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
970 return statspec != NULL && HasBit(statspec->blocked, GetStationGfx(tile)); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
971 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
972 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
973 /* Check if a rail station tile is electrifiable. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
974 * XXX This could be cached (during build) in the map array to save on all the dereferencing */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
975 bool IsStationTileElectrifiable(TileIndex tile) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
976 { |
10647
592ae9307430
(svn r14949) -Cleanup: pointer coding style
rubidium <rubidium@openttd.org>
parents:
10355
diff
changeset
|
977 const StationSpec *statspec = GetStationSpec(tile); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
978 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
979 return |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
980 statspec == NULL || |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
981 HasBit(statspec->pylons, GetStationGfx(tile)) || |
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
982 !HasBit(statspec->wires, GetStationGfx(tile)); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
983 } |
9003
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
984 |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
985 void AnimateStationTile(TileIndex tile) |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
986 { |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
987 const StationSpec *ss = GetStationSpec(tile); |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
988 if (ss == NULL) return; |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
989 |
12425
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
990 const BaseStation *st = BaseStation::GetByTile(tile); |
9003
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
991 |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
992 uint8 animation_speed = ss->anim_speed; |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
993 |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
994 if (HasBit(ss->callbackmask, CBM_STATION_ANIMATION_SPEED)) { |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
995 uint16 callback = GetStationCallback(CBID_STATION_ANIMATION_SPEED, 0, 0, ss, st, tile); |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
996 if (callback != CALLBACK_FAILED) animation_speed = Clamp(callback & 0xFF, 0, 16); |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
997 } |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
998 |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
999 if (_tick_counter % (1 << animation_speed) != 0) return; |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1000 |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1001 uint8 frame = GetStationAnimationFrame(tile); |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1002 uint8 num_frames = ss->anim_frames; |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1003 |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1004 bool frame_set_by_callback = false; |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1005 |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1006 if (HasBit(ss->callbackmask, CBM_STATION_ANIMATION_NEXT_FRAME)) { |
11585
a5688eed8d7a
(svn r15956) -Codechange: Enumorize station spec flags.
peter1138 <peter1138@openttd.org>
parents:
11091
diff
changeset
|
1007 uint32 param = HasBit(ss->flags, SSF_CB141_RANDOM_BITS) ? Random() : 0; |
9003
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1008 uint16 callback = GetStationCallback(CBID_STATION_ANIM_NEXT_FRAME, param, 0, ss, st, tile); |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1009 |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1010 if (callback != CALLBACK_FAILED) { |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1011 frame_set_by_callback = true; |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1012 |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1013 switch (callback & 0xFF) { |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1014 case 0xFF: |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1015 DeleteAnimatedTile(tile); |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1016 break; |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1017 |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1018 case 0xFE: |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1019 frame_set_by_callback = false; |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1020 break; |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1021 |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1022 default: |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1023 frame = callback & 0xFF; |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1024 break; |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1025 } |
9018
9dcf32675eb5
(svn r12817) -Feature: the ability to play NewGRF sounds for industries and stations.
rubidium <rubidium@openttd.org>
parents:
9006
diff
changeset
|
1026 |
9dcf32675eb5
(svn r12817) -Feature: the ability to play NewGRF sounds for industries and stations.
rubidium <rubidium@openttd.org>
parents:
9006
diff
changeset
|
1027 /* If the lower 7 bits of the upper byte of the callback |
9dcf32675eb5
(svn r12817) -Feature: the ability to play NewGRF sounds for industries and stations.
rubidium <rubidium@openttd.org>
parents:
9006
diff
changeset
|
1028 * result are not empty, it is a sound effect. */ |
9dcf32675eb5
(svn r12817) -Feature: the ability to play NewGRF sounds for industries and stations.
rubidium <rubidium@openttd.org>
parents:
9006
diff
changeset
|
1029 if (GB(callback, 8, 7) != 0) PlayTileSound(ss->grffile, GB(callback, 8, 7), tile); |
9003
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1030 } |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1031 } |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1032 |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1033 if (!frame_set_by_callback) { |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1034 if (frame < num_frames) { |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1035 frame++; |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1036 } else if (frame == num_frames && HasBit(ss->anim_status, 0)) { |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1037 /* This animation loops, so start again from the beginning */ |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1038 frame = 0; |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1039 } else { |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1040 /* This animation doesn't loop, so stay here */ |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1041 DeleteAnimatedTile(tile); |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1042 } |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1043 } |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1044 |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1045 SetStationAnimationFrame(tile, frame); |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1046 MarkTileDirtyByTile(tile); |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1047 } |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1048 |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1049 |
12425
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
1050 static void ChangeStationAnimationFrame(const StationSpec *ss, const BaseStation *st, TileIndex tile, uint16 random_bits, StatAnimTrigger trigger, CargoID cargo_type) |
9003
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1051 { |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1052 uint16 callback = GetStationCallback(CBID_STATION_ANIM_START_STOP, (random_bits << 16) | Random(), (uint8)trigger | (cargo_type << 8), ss, st, tile); |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1053 if (callback == CALLBACK_FAILED) return; |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1054 |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1055 switch (callback & 0xFF) { |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1056 case 0xFD: /* Do nothing. */ break; |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1057 case 0xFE: AddAnimatedTile(tile); break; |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1058 case 0xFF: DeleteAnimatedTile(tile); break; |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1059 default: |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1060 SetStationAnimationFrame(tile, callback); |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1061 AddAnimatedTile(tile); |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1062 break; |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1063 } |
9018
9dcf32675eb5
(svn r12817) -Feature: the ability to play NewGRF sounds for industries and stations.
rubidium <rubidium@openttd.org>
parents:
9006
diff
changeset
|
1064 |
9dcf32675eb5
(svn r12817) -Feature: the ability to play NewGRF sounds for industries and stations.
rubidium <rubidium@openttd.org>
parents:
9006
diff
changeset
|
1065 /* If the lower 7 bits of the upper byte of the callback |
9dcf32675eb5
(svn r12817) -Feature: the ability to play NewGRF sounds for industries and stations.
rubidium <rubidium@openttd.org>
parents:
9006
diff
changeset
|
1066 * result are not empty, it is a sound effect. */ |
9dcf32675eb5
(svn r12817) -Feature: the ability to play NewGRF sounds for industries and stations.
rubidium <rubidium@openttd.org>
parents:
9006
diff
changeset
|
1067 if (GB(callback, 8, 7) != 0) PlayTileSound(ss->grffile, GB(callback, 8, 7), tile); |
9003
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1068 } |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1069 |
12425
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
1070 void StationAnimationTrigger(const BaseStation *st, TileIndex tile, StatAnimTrigger trigger, CargoID cargo_type) |
9003
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1071 { |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1072 /* List of coverage areas for each animation trigger */ |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1073 static const TriggerArea tas[] = { |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1074 TA_TILE, TA_WHOLE, TA_WHOLE, TA_PLATFORM, TA_PLATFORM, TA_PLATFORM, TA_WHOLE |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1075 }; |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1076 |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1077 /* Get Station if it wasn't supplied */ |
12425
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
1078 if (st == NULL) st = BaseStation::GetByTile(tile); |
9003
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1079 |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1080 /* Check the cached animation trigger bitmask to see if we need |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1081 * to bother with any further processing. */ |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1082 if (!HasBit(st->cached_anim_triggers, trigger)) return; |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1083 |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1084 uint16 random_bits = Random(); |
12462
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
1085 ETileArea area = ETileArea(st, tile, tas[trigger]); |
9003
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1086 |
12462
4dd085f22d88
(svn r16896) -Codechange: make station spec allocation and station animation functions work for both stations and waypoints
rubidium <rubidium@openttd.org>
parents:
12454
diff
changeset
|
1087 /* Check all tiles over the station to check if the specindex is still in use */ |
9003
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1088 for (uint y = 0; y < area.h; y++) { |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1089 for (uint x = 0; x < area.w; x++) { |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1090 if (st->TileBelongsToRailStation(area.tile)) { |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1091 const StationSpec *ss = GetStationSpec(area.tile); |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1092 if (ss != NULL && HasBit(ss->anim_triggers, trigger)) { |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1093 CargoID cargo; |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1094 if (cargo_type == CT_INVALID) { |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1095 cargo = CT_INVALID; |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1096 } else { |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1097 cargo = GetReverseCargoTranslation(cargo_type, ss->grffile); |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1098 } |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1099 ChangeStationAnimationFrame(ss, st, area.tile, random_bits, trigger, cargo); |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1100 } |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1101 } |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1102 area.tile += TileDiffXY(1, 0); |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1103 } |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1104 area.tile += TileDiffXY(-area.w, 1); |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1105 } |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1106 } |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1107 |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1108 /** |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1109 * Update the cached animation trigger bitmask for a station. |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1110 * @param st Station to update. |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1111 */ |
12425
d9e9b7477507
(svn r16859) -Codechange: split the Station struct into two so parts of it can be reused for Waypoints.
rubidium <rubidium@openttd.org>
parents:
12418
diff
changeset
|
1112 void StationUpdateAnimTriggers(BaseStation *st) |
9003
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1113 { |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1114 st->cached_anim_triggers = 0; |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1115 |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1116 /* Combine animation trigger bitmask for all station specs |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1117 * of this station. */ |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1118 for (uint i = 0; i < st->num_specs; i++) { |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1119 const StationSpec *ss = st->speclist[i].spec; |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1120 if (ss != NULL) st->cached_anim_triggers |= ss->anim_triggers; |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1121 } |
ac23e012c9d7
(svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138 <peter1138@openttd.org>
parents:
8956
diff
changeset
|
1122 } |