Mercurial > hg > openttd
annotate src/newgrf_station.cpp @ 12778:bc7926153e19 draft
(svn r17248) -Fix: add GPL license notice where appropriate
author | rubidium <rubidium@openttd.org> |
---|---|
date | Fri, 21 Aug 2009 20:21:05 +0000 |
parents | e41943276802 |
children | 8e2a0e8fa275 |
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 |
12778
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12632
diff
changeset
|
3 /* |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12632
diff
changeset
|
4 * This file is part of OpenTTD. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12632
diff
changeset
|
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12632
diff
changeset
|
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12632
diff
changeset
|
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12632
diff
changeset
|
8 */ |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12632
diff
changeset
|
9 |
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
|
10 /** @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
|
11 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
12 #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
|
13 #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
|
14 #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
|
15 #include "debug.h" |
12228
240adc64d01a
(svn r16643) -Codechange: replace GetStationByTile() by Station::GetByTile()
smatz <smatz@openttd.org>
parents:
12225
diff
changeset
|
16 #include "station_base.h" |
12475
c133b51890f4
(svn r16912) -Codechange: split waypoint.h in waypoint_base.h and waypoint_func.h
rubidium <rubidium@openttd.org>
parents:
12472
diff
changeset
|
17 #include "waypoint_base.h" |
12225
4f649aa97318
(svn r16640) -Codechange: move roadstop stuff to separate files
smatz <smatz@openttd.org>
parents:
12016
diff
changeset
|
18 #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
|
19 #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
|
20 #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
|
21 #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
|
22 #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
|
23 #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
|
24 #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
|
25 #include "gfx_func.h" |
8140
fb8a05d579da
(svn r11702) -Codechange: move all date related stuff to date*.
rubidium <rubidium@openttd.org>
parents:
8130
diff
changeset
|
26 #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
|
27 #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
|
28 #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
|
29 #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
|
30 #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
|
31 #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
|
32 |
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
|
33 #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
|
34 |
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
|
35 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
|
36 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
37 enum { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
38 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
|
39 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
40 |
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
|
41 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
|
42 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
|
43 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
|
44 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
|
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 |
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 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
|
48 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
|
49 { |
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 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
|
51 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
|
52 |
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 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
|
54 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
|
55 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
|
56 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
|
57 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
|
58 |
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 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
|
60 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
|
61 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
|
62 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
|
63 |
12502
9472b49c61a1
(svn r16939) -Codechange: s/RailwayStation/RailStation/ to unify the way it's written.
rubidium <rubidium@openttd.org>
parents:
12501
diff
changeset
|
64 for (end = tile; IsRailStationTile(end + delta) && IsCompatibleTrainStationTile(tile, end + delta); end += delta) { /* Nothing */ } |
9472b49c61a1
(svn r16939) -Codechange: s/RailwayStation/RailStation/ to unify the way it's written.
rubidium <rubidium@openttd.org>
parents:
12501
diff
changeset
|
65 for (start = tile; IsRailStationTile(start - delta) && IsCompatibleTrainStationTile(tile, start - delta); start -= delta) { /* Nothing */ } |
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
|
66 |
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 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
|
68 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
|
69 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
|
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 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
|
74 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
|
75 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
|
76 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
|
77 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
|
78 } |
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
|
79 } |
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
|
80 }; |
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
|
81 |
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
|
82 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
83 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
84 * 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
|
85 * 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
|
86 * 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
|
87 */ |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6148
diff
changeset
|
88 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
|
89 { |
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
|
90 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
|
91 _station_classes[i].id = 0; |
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
92 _station_classes[i].name = STR_EMPTY; |
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
93 _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
|
94 |
8316
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
95 free(_station_classes[i].spec); |
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
96 _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
|
97 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
98 |
6348
bcf98ba27bbf
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas <belugas@openttd.org>
parents:
6343
diff
changeset
|
99 /* Set up initial data */ |
8316
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
100 _station_classes[0].id = 'DFLT'; |
12632
e41943276802
(svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents:
12607
diff
changeset
|
101 _station_classes[0].name = STR_STATION_CLASS_DFLT; |
8316
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
102 _station_classes[0].stations = 1; |
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
103 _station_classes[0].spec = MallocT<StationSpec*>(1); |
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
104 _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
|
105 |
8316
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
106 _station_classes[1].id = 'WAYP'; |
12632
e41943276802
(svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents:
12607
diff
changeset
|
107 _station_classes[1].name = STR_STATION_CLASS_WAYP; |
8316
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
108 _station_classes[1].stations = 1; |
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
109 _station_classes[1].spec = MallocT<StationSpec*>(1); |
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
110 _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
|
111 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
112 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
113 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
114 * 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
|
115 * @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
|
116 * @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
|
117 */ |
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
|
118 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
|
119 { |
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
|
120 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
|
121 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
|
122 /* 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
|
123 return i; |
8316
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
124 } 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
|
125 /* 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
|
126 _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
|
127 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
|
128 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
129 } |
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 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
|
132 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
|
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 /** 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
|
136 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
|
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 _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
|
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 /** 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
|
143 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
|
144 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
145 assert(sclass < STAT_CLASS_MAX); |
8316
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
146 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
|
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 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
149 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
150 * 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
|
151 * @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
|
152 */ |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6148
diff
changeset
|
153 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
|
154 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
155 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
|
156 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
|
157 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
|
158 } |
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 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
161 * 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
|
162 * @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
|
163 * @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
|
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 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
|
166 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
167 assert(sclass < STAT_CLASS_MAX); |
8316
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
168 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
|
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 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
171 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
172 * 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
|
173 * @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
|
174 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
175 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
|
176 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
177 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
|
178 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
|
179 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
180 /* 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
|
181 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
|
182 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
183 assert(statspec->sclass < STAT_CLASS_MAX); |
8316
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
184 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
|
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 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
|
187 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
|
188 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
189 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
|
190 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
|
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 |
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 * 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
|
195 * @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
|
196 * @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
|
197 * @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
|
198 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
199 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
|
200 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
201 assert(sclass < STAT_CLASS_MAX); |
8316
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
202 if (station < _station_classes[sclass].stations) |
a3f30e43d561
(svn r11881) -Cleanup: Code style for global variables.
peter1138 <peter1138@openttd.org>
parents:
8295
diff
changeset
|
203 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
|
204 |
6348
bcf98ba27bbf
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas <belugas@openttd.org>
parents:
6343
diff
changeset
|
205 /* 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
|
206 * 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
|
207 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
|
208 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
209 |
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
|
210 /** |
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
|
211 * 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
|
212 * @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
|
213 * @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
|
214 * @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
|
215 * @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
|
216 */ |
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
|
217 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
|
218 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
219 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
|
220 |
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
|
221 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
|
222 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
|
223 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
|
224 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
|
225 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
|
226 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
|
227 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
|
228 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
229 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
230 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
231 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
232 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
|
233 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
234 |
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 /* 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
|
237 * 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
|
238 * 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
|
239 * 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
|
240 * 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
|
241 * 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
|
242 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
243 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
|
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 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
|
246 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
247 if (axis == AXIS_X) { |
6106 | 248 Swap(platforms, length); |
249 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
|
250 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
251 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
252 /* 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
|
253 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
|
254 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
|
255 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
|
256 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
|
257 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
|
258 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
|
259 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
|
260 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
|
261 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
|
262 } else { |
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, 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
|
264 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
|
265 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
|
266 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
|
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 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
|
269 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
|
270 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
|
271 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
272 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
|
273 } |
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 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
276 /* 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
|
277 * 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
|
278 * 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
|
279 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
280 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
|
281 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
282 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
|
283 Axis orig_axis = AXIS_X; |
12472
604a2cfc77ab
(svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents:
12471
diff
changeset
|
284 StationID sid = GetStationIndex(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
|
285 |
12472
604a2cfc77ab
(svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents:
12471
diff
changeset
|
286 if (check_type) orig_type = GetCustomStationSpecIndex(tile); |
604a2cfc77ab
(svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents:
12471
diff
changeset
|
287 if (check_axis) orig_axis = GetRailStationAxis(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
|
288 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
289 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
|
290 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
|
291 |
12472
604a2cfc77ab
(svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents:
12471
diff
changeset
|
292 if (!IsTileType(new_tile, MP_STATION) || GetStationIndex(new_tile) != sid) break; |
12501
44606771f552
(svn r16938) -Codechange: introduce helper function to tell whether a tile is either a rail station or rail waypoint tile
rubidium <rubidium@openttd.org>
parents:
12475
diff
changeset
|
293 if (!HasStationRail(new_tile)) break; |
12472
604a2cfc77ab
(svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents:
12471
diff
changeset
|
294 if (check_type && GetCustomStationSpecIndex(new_tile) != orig_type) break; |
604a2cfc77ab
(svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents:
12471
diff
changeset
|
295 if (check_axis && GetRailStationAxis(new_tile) != orig_axis) 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
|
296 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
297 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
|
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 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
|
300 } |
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 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
303 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
|
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 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
|
306 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
|
307 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
|
308 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
|
309 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
|
310 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
|
311 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
312 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
|
313 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
|
314 |
12472
604a2cfc77ab
(svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents:
12471
diff
changeset
|
315 return GetPlatformInfo(GetRailStationAxis(tile), GetStationGfx(tile), ex, ey, tx, ty, centred); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
316 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
317 |
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 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
|
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 /* 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
|
322 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
|
323 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
|
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 Y axis */ |
7157
7e46225ed50b
(svn r10431) -Codechange: constness on static array
peter1138 <peter1138@openttd.org>
parents:
7010
diff
changeset
|
326 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
|
327 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
|
328 |
12472
604a2cfc77ab
(svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents:
12471
diff
changeset
|
329 Axis axis = GetRailStationAxis(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
|
330 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
331 /* Choose appropriate lookup table to use */ |
7157
7e46225ed50b
(svn r10431) -Codechange: constness on static array
peter1138 <peter1138@openttd.org>
parents:
7010
diff
changeset
|
332 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
|
333 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
|
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 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
|
336 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
|
337 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
338 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
|
339 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
|
340 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
|
341 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
|
342 /* 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
|
343 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
|
344 |
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
|
345 /* 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
|
346 * 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
|
347 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
|
348 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
|
349 } |
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 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
351 /* 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
|
352 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
|
353 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
354 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
355 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
356 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
|
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 /* 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
|
361 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
|
362 { |
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
|
363 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
|
364 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
|
365 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
|
366 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
367 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
368 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
369 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
|
370 { |
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
|
371 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
|
372 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
|
373 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
374 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
375 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
376 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
|
377 { |
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
|
378 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
|
379 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
|
380 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
|
381 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
382 |
7230
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
383 /** |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
384 * Station variable cache |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
385 * 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
|
386 * 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
|
387 */ |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
388 static struct { |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
389 uint32 v40; |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
390 uint32 v41; |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
391 uint32 v45; |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
392 uint32 v46; |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
393 uint32 v47; |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
394 uint32 v49; |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
395 uint8 valid; |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
396 } _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
|
397 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
398 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
|
399 { |
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
|
400 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
|
401 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
|
402 |
6354
4595b3acd03d
(svn r9393) -Codechange: Use newgrf town resolver as station parent scope handler
peter1138 <peter1138@openttd.org>
parents:
6348
diff
changeset
|
403 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
|
404 /* 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
|
405 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
|
406 |
4595b3acd03d
(svn r9393) -Codechange: Use newgrf town resolver as station parent scope handler
peter1138 <peter1138@openttd.org>
parents:
6348
diff
changeset
|
407 if (st != NULL) { |
4595b3acd03d
(svn r9393) -Codechange: Use newgrf town resolver as station parent scope handler
peter1138 <peter1138@openttd.org>
parents:
6348
diff
changeset
|
408 t = st->town; |
4595b3acd03d
(svn r9393) -Codechange: Use newgrf town resolver as station parent scope handler
peter1138 <peter1138@openttd.org>
parents:
6348
diff
changeset
|
409 } 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
|
410 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
|
411 } else { |
4595b3acd03d
(svn r9393) -Codechange: Use newgrf town resolver as station parent scope handler
peter1138 <peter1138@openttd.org>
parents:
6348
diff
changeset
|
412 *available = false; |
4595b3acd03d
(svn r9393) -Codechange: Use newgrf town resolver as station parent scope handler
peter1138 <peter1138@openttd.org>
parents:
6348
diff
changeset
|
413 return UINT_MAX; |
4595b3acd03d
(svn r9393) -Codechange: Use newgrf town resolver as station parent scope handler
peter1138 <peter1138@openttd.org>
parents:
6348
diff
changeset
|
414 } |
4595b3acd03d
(svn r9393) -Codechange: Use newgrf town resolver as station parent scope handler
peter1138 <peter1138@openttd.org>
parents:
6348
diff
changeset
|
415 |
4595b3acd03d
(svn r9393) -Codechange: Use newgrf town resolver as station parent scope handler
peter1138 <peter1138@openttd.org>
parents:
6348
diff
changeset
|
416 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
|
417 } |
4595b3acd03d
(svn r9393) -Codechange: Use newgrf town resolver as station parent scope handler
peter1138 <peter1138@openttd.org>
parents:
6348
diff
changeset
|
418 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
419 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
|
420 /* 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
|
421 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
|
422 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
|
423 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
|
424 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
|
425 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
|
426 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
|
427 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
|
428 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
|
429 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
|
430 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
|
431 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
432 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
433 *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
|
434 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
|
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 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
|
438 /* Calculated station variables */ |
7230
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
439 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
|
440 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
|
441 return _svc.v40; |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
442 |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
443 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
|
444 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
|
445 return _svc.v41; |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
446 |
6849
cbe1a12e652d
(svn r10089) -Fix (r10040): Use GetTileZ instead of GetClearGround in GetTerrainType as
maedhros <maedhros@openttd.org>
parents:
6683
diff
changeset
|
447 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
|
448 case 0x43: return st->owner; // Station owner |
12472
604a2cfc77ab
(svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents:
12471
diff
changeset
|
449 case 0x44: return HasStationReservation(tile) ? 7 : 4; // PBS status |
7230
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
450 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
|
451 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
|
452 return _svc.v45; |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
453 |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
454 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
|
455 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
|
456 return _svc.v46; |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
457 |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
458 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
|
459 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
|
460 return _svc.v47; |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
461 |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
462 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
|
463 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
|
464 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
|
465 |
8956
9368ed6c6424
(svn r12747) -Codechange: Add varaction retrieval of station animation frame
peter1138 <peter1138@openttd.org>
parents:
8906
diff
changeset
|
466 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
|
467 return GetStationAnimationFrame(tile); |
9368ed6c6424
(svn r12747) -Codechange: Add varaction retrieval of station animation frame
peter1138 <peter1138@openttd.org>
parents:
8906
diff
changeset
|
468 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
469 /* 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
|
470 /* 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
|
471 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
|
472 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
|
473 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
|
474 |
9368ed6c6424
(svn r12747) -Codechange: Add varaction retrieval of station animation frame
peter1138 <peter1138@openttd.org>
parents:
8906
diff
changeset
|
475 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
|
476 Axis axis = GetRailStationAxis(tile); |
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
477 |
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
478 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
|
479 |
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
|
480 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
|
481 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
|
482 |
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
|
483 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
|
484 } |
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
485 |
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
486 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
|
487 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
|
488 |
12501
44606771f552
(svn r16938) -Codechange: introduce helper function to tell whether a tile is either a rail station or rail waypoint tile
rubidium <rubidium@openttd.org>
parents:
12475
diff
changeset
|
489 if (!HasStationTileRail(nearby_tile)) return 0xFFFFFFFF; |
8118
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
490 |
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
491 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
|
492 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
|
493 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
|
494 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
|
495 |
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
496 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
|
497 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
|
498 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
|
499 } |
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
500 return res; |
854a73832899
(svn r11679) -Add: [newgrf] support for station vars 67 and 68
glx <glx@openttd.org>
parents:
7931
diff
changeset
|
501 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
502 |
12430
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
503 /* 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
|
504 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
|
505 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
|
506 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
|
507 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
|
508 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
|
509 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
510 |
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
|
511 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
|
512 } |
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
|
513 |
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
|
514 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
|
515 { |
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
|
516 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
|
517 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
|
518 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
|
519 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
|
520 |
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 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
|
522 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
|
523 } |
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 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
|
525 } |
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 |
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 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
|
528 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
|
529 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
|
530 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
|
531 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
|
532 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
|
533 } |
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 |
6460
cebf3bbc9227
(svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
peter1138 <peter1138@openttd.org>
parents:
6451
diff
changeset
|
535 /* 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
|
536 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
|
537 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
|
538 |
cebf3bbc9227
(svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
peter1138 <peter1138@openttd.org>
parents:
6451
diff
changeset
|
539 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
|
540 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
|
541 |
cebf3bbc9227
(svn r9620) -Codechange: apply cargo translation table to newstation variables 0x60..0x65
peter1138 <peter1138@openttd.org>
parents:
6451
diff
changeset
|
542 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
|
543 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
|
544 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
|
545 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
|
546 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
|
547 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
|
548 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
|
549 } |
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 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
552 /* 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
|
553 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
|
554 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
|
555 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
|
556 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
|
557 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
|
558 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
|
559 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
|
560 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
|
561 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
|
562 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
|
563 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
|
564 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
565 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
566 |
12430
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
567 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
|
568 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
569 *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
|
570 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
|
571 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
572 |
12430
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
573 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
|
574 { |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
575 switch (variable) { |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
576 case 0x48: return 0; // Accepted cargo types |
12472
604a2cfc77ab
(svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents:
12471
diff
changeset
|
577 case 0x8A: return HVOT_WAYPOINT; |
12430
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
578 case 0xF1: return 0; // airport type |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
579 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
|
580 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
|
581 case 0xF6: return 0; // airport flags |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
582 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
|
583 } |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
584 |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
585 /* 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
|
586 if (variable >= 0x60 && variable <= 0x65) { |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
587 return 0; |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
588 } |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
589 |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
590 /* Handle cargo variables (deprecated) */ |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
591 if (variable >= 0x8C && variable <= 0xEC) { |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
592 switch (GB(variable - 0x8C, 0, 3)) { |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
593 case 3: return INITIAL_STATION_RATING; |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
594 case 4: return INVALID_STATION; |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
595 default: return 0; |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
596 } |
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 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
|
600 |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
601 *available = false; |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
602 return UINT_MAX; |
5e6b5186ef8a
(svn r16864) -Codechange: make Waypoints a subclass of BaseStation.
rubidium <rubidium@openttd.org>
parents:
12425
diff
changeset
|
603 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
604 |
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
|
605 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
|
606 { |
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
|
607 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
|
608 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
|
609 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
|
610 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
611 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
|
612 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
|
613 |
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
|
614 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
|
615 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
|
616 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
617 |
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
|
618 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
|
619 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
620 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
|
621 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
|
622 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
|
623 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
|
624 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
|
625 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
626 |
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
|
627 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
|
628 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
|
629 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
|
630 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
631 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
632 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
633 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
|
634 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
|
635 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
636 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
637 |
12510
3e976121ced2
(svn r16947) -Codechange: use TileArea instead of train_tile, trainst_w and trainst_h.
rubidium <rubidium@openttd.org>
parents:
12502
diff
changeset
|
638 if (HasBit(statspec->flags, SSF_DIV_BY_STATION_SIZE)) cargo /= (st->train_station.w + st->train_station.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
|
639 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
|
640 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
641 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
|
642 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
|
643 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
|
644 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
|
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 } 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
|
647 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
|
648 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
|
649 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
|
650 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
651 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
652 |
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
|
653 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
|
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 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
656 |
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
|
657 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
|
658 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
659 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
|
660 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
|
661 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
|
662 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
|
663 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
|
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 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
|
666 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
|
667 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
|
668 |
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
|
669 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
|
670 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
|
671 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
|
672 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
|
673 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
|
674 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
|
675 res->count = 0; |
9750
0654bf387d06
(svn r13885) -Fix [FS#2168]: Var 0x7F is not feature-specific.
frosch <frosch@openttd.org>
parents:
9726
diff
changeset
|
676 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
|
677 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
678 |
5849 | 679 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
|
680 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
681 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
|
682 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
|
683 |
5849 | 684 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
|
685 /* 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
|
686 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
|
687 } 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
|
688 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
|
689 /* 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
|
690 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
|
691 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
|
692 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
|
693 !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
|
694 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
|
695 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
696 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
697 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
698 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
699 |
5849 | 700 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
|
701 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
|
702 ctype = CT_DEFAULT; |
5849 | 703 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
|
704 } |
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 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
|
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 /* 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
|
709 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
|
710 |
7230
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
711 /* Invalidate all cached vars */ |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
712 _svc.valid = 0; |
9b7fbae562c3
(svn r10509) -Codechange: cache expensive newgrf station variables during
peter1138 <peter1138@openttd.org>
parents:
7192
diff
changeset
|
713 |
11996
b43cf6c7ea61
(svn r16402) -Codechange: make Resolve a function of SpriteGroup
rubidium <rubidium@openttd.org>
parents:
11990
diff
changeset
|
714 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
|
715 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
716 |
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
|
717 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
|
718 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
719 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
|
720 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
|
721 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
722 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
|
723 |
5849 | 724 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
|
725 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
|
726 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
|
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 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
729 |
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
|
730 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
|
731 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
732 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
|
733 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
|
734 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
735 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
|
736 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
|
737 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
|
738 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
739 |
5849 | 740 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
|
741 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
|
742 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
|
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 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
745 |
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
|
746 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
|
747 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
748 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
|
749 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
|
750 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
751 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
|
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 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
|
754 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
|
755 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
|
756 |
5849 | 757 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
|
758 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
|
759 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
|
760 } |
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 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
763 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
764 * 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
|
765 * @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
|
766 * @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
|
767 * @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
|
768 * @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
|
769 */ |
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
|
770 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
|
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 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
|
773 |
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
|
774 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
|
775 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
776 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
|
777 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
|
778 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
779 |
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
|
780 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
|
781 /* 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
|
782 * 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
|
783 * 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
|
784 * 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
|
785 */ |
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
|
786 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
|
787 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
|
788 } |
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 |
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 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
|
791 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
792 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
793 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
|
794 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
|
795 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
|
796 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
|
797 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
798 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
|
799 /* 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
|
800 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
|
801 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
|
802 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
|
803 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
804 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
805 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
806 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
|
807 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
|
808 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
|
809 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
810 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
811 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
|
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 /** 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
|
816 * @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
|
817 * @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
|
818 * @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
|
819 */ |
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
|
820 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
|
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 /* 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
|
823 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
|
824 |
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
|
825 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
|
826 /* Check all tiles over the station to check if the specindex is still in use */ |
12607
58a2a1840d79
(svn r17050) -Codechange: replace custom implementation of TILE_LOOP with TILE_LOOP.
rubidium <rubidium@openttd.org>
parents:
12510
diff
changeset
|
827 TILE_LOOP(tile, area.w, area.h, area.tile) { |
58a2a1840d79
(svn r17050) -Codechange: replace custom implementation of TILE_LOOP with TILE_LOOP.
rubidium <rubidium@openttd.org>
parents:
12510
diff
changeset
|
828 if (st->TileBelongsToRailStation(tile) && GetCustomStationSpecIndex(tile) == specindex) { |
58a2a1840d79
(svn r17050) -Codechange: replace custom implementation of TILE_LOOP with TILE_LOOP.
rubidium <rubidium@openttd.org>
parents:
12510
diff
changeset
|
829 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
|
830 } |
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
|
831 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
832 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
833 /* 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
|
834 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
|
835 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
|
836 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
|
837 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
838 /* 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
|
839 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
|
840 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
|
841 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
842 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
|
843 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
|
844 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
845 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
|
846 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
|
847 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
|
848 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
|
849 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
|
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 } |
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
|
852 |
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
|
853 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
|
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 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
856 /** 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
|
857 * @param x Position x of image. |
85a1a79387a2
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents:
6460
diff
changeset
|
858 * @param y Position y of image. |
85a1a79387a2
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents:
6460
diff
changeset
|
859 * @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
|
860 * @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
|
861 * @param sclass, station Type of station. |
6481
85a1a79387a2
(svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas <belugas@openttd.org>
parents:
6460
diff
changeset
|
862 * @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
|
863 * @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
|
864 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
865 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
|
866 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
867 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
|
868 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
|
869 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
|
870 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
|
871 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
|
872 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
|
873 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
|
874 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
|
875 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
876 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
|
877 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
|
878 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
879 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
|
880 |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
881 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
|
882 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
|
883 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
|
884 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
885 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
886 if (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
|
887 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
|
888 } 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
|
889 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
|
890 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
891 |
8571
b611278e4fed
(svn r12149) -Codechange: Merge 'ground_sprite' and 'ground_pal' of DrawTileSprites into one PalSpriteID
frosch <frosch@openttd.org>
parents:
8570
diff
changeset
|
892 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
|
893 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
|
894 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
|
895 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
|
896 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
|
897 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
898 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
|
899 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
900 |
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
|
901 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
|
902 |
10256
c0307c0a126c
(svn r14487) -Fix: The station picker preview did not draw child sprites.
frosch <frosch@openttd.org>
parents:
10208
diff
changeset
|
903 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
|
904 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
905 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
|
906 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
|
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 += 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
|
909 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
910 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
|
911 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
912 |
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
|
913 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
|
914 |
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 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
|
916 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
|
917 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
|
918 |
c0307c0a126c
(svn r14487) -Fix: The station picker preview did not draw child sprites.
frosch <frosch@openttd.org>
parents:
10208
diff
changeset
|
919 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
|
920 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
|
921 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
|
922 } else { |
c0307c0a126c
(svn r14487) -Fix: The station picker preview did not draw child sprites.
frosch <frosch@openttd.org>
parents:
10208
diff
changeset
|
923 /* 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
|
924 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
|
925 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
926 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
927 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
928 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
|
929 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
930 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
931 |
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
|
932 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
|
933 { |
12472
604a2cfc77ab
(svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents:
12471
diff
changeset
|
934 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
|
935 |
12472
604a2cfc77ab
(svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents:
12471
diff
changeset
|
936 const BaseStation *st = BaseStation::GetByTile(t); |
604a2cfc77ab
(svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents:
12471
diff
changeset
|
937 uint specindex = GetCustomStationSpecIndex(t); |
604a2cfc77ab
(svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents:
12471
diff
changeset
|
938 return specindex < st->num_specs ? st->speclist[specindex].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
|
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 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
942 /* 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
|
943 * 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
|
944 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
|
945 { |
10647
592ae9307430
(svn r14949) -Cleanup: pointer coding style
rubidium <rubidium@openttd.org>
parents:
10355
diff
changeset
|
946 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
|
947 |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
948 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
|
949 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
950 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
951 /* 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
|
952 * 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
|
953 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
|
954 { |
10647
592ae9307430
(svn r14949) -Cleanup: pointer coding style
rubidium <rubidium@openttd.org>
parents:
10355
diff
changeset
|
955 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
|
956 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
957 return |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
958 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
|
959 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
|
960 !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
|
961 } |
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
|
962 |
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
|
963 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
|
964 { |
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
|
965 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
|
966 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
|
967 |
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
|
968 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
|
969 |
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
|
970 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
|
971 |
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
|
972 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
|
973 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
|
974 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
|
975 } |
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
|
976 |
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
|
977 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
|
978 |
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
|
979 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
|
980 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
|
981 |
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
|
982 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
|
983 |
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 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
|
985 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
|
986 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
|
987 |
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 (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
|
989 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
|
990 |
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 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
|
992 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
|
993 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
|
994 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
|
995 |
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 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
|
997 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
|
998 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
|
999 |
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 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
|
1001 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
|
1002 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
|
1003 } |
9018
9dcf32675eb5
(svn r12817) -Feature: the ability to play NewGRF sounds for industries and stations.
rubidium <rubidium@openttd.org>
parents:
9006
diff
changeset
|
1004 |
9dcf32675eb5
(svn r12817) -Feature: the ability to play NewGRF sounds for industries and stations.
rubidium <rubidium@openttd.org>
parents:
9006
diff
changeset
|
1005 /* 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
|
1006 * 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
|
1007 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
|
1008 } |
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 |
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 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
|
1012 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
|
1013 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
|
1014 } 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
|
1015 /* 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
|
1016 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
|
1017 } 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
|
1018 /* 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
|
1019 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
|
1020 } |
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 |
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 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
|
1024 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
|
1025 } |
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
|
1026 |
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
|
1027 |
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
|
1028 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
|
1029 { |
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 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
|
1031 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
|
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 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
|
1034 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
|
1035 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
|
1036 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
|
1037 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
|
1038 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
|
1039 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
|
1040 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
|
1041 } |
9018
9dcf32675eb5
(svn r12817) -Feature: the ability to play NewGRF sounds for industries and stations.
rubidium <rubidium@openttd.org>
parents:
9006
diff
changeset
|
1042 |
9dcf32675eb5
(svn r12817) -Feature: the ability to play NewGRF sounds for industries and stations.
rubidium <rubidium@openttd.org>
parents:
9006
diff
changeset
|
1043 /* 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
|
1044 * 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
|
1045 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
|
1046 } |
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 |
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
|
1048 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
|
1049 { |
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
|
1050 /* 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
|
1051 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
|
1052 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
|
1053 }; |
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 /* 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
|
1056 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
|
1057 |
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 /* 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
|
1059 * 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
|
1060 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
|
1061 |
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 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
|
1063 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
|
1064 |
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
|
1065 /* 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
|
1066 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
|
1067 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
|
1068 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
|
1069 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
|
1070 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
|
1071 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
|
1072 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
|
1073 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
|
1074 } 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
|
1075 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
|
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 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
|
1078 } |
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 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
|
1081 } |
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 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
|
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 } |
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
|
1085 |
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 /** |
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
|
1087 * 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
|
1088 * @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
|
1089 */ |
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
|
1090 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
|
1091 { |
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 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
|
1093 |
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 /* 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
|
1095 * 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
|
1096 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
|
1097 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
|
1098 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
|
1099 } |
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 } |