author | darkvater |
Fri, 25 Mar 2005 15:30:51 +0000 | |
changeset 1558 | 62eeea72497d |
parent 1551 | b1c7df6daa63 |
child 1680 | 2d69b69f7b17 |
permissions | -rw-r--r-- |
0 | 1 |
#ifndef STATION_H |
2 |
#define STATION_H |
|
3 |
||
1272
9aa073c64fc7
(svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents:
1266
diff
changeset
|
4 |
#include "pool.h" |
405
415546028e8d
(svn r602) -newgrf: Move DrawTileSeqStruct & co and struct SpriteGroup to sprite.h (pasky)
darkvater
parents:
403
diff
changeset
|
5 |
#include "sprite.h" |
1247 | 6 |
#include "tile.h" |
0 | 7 |
#include "vehicle.h" |
8 |
||
9 |
typedef struct GoodsEntry { |
|
10 |
uint16 waiting_acceptance; |
|
11 |
byte days_since_pickup; |
|
12 |
byte rating; |
|
1266
eccd576e322f
(svn r1770) -Fix: Hopefully last pieces of code that are containing a station-id
truelight
parents:
1247
diff
changeset
|
13 |
uint16 enroute_from; |
0 | 14 |
byte enroute_time; |
15 |
byte last_speed; |
|
16 |
byte last_age; |
|
17 |
} GoodsEntry; |
|
18 |
||
1217
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
19 |
typedef enum RoadStopType { |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
20 |
RS_BUS, |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
21 |
RS_TRUCK |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
22 |
} RoadStopType; |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
23 |
|
1266
eccd576e322f
(svn r1770) -Fix: Hopefully last pieces of code that are containing a station-id
truelight
parents:
1247
diff
changeset
|
24 |
enum { |
eccd576e322f
(svn r1770) -Fix: Hopefully last pieces of code that are containing a station-id
truelight
parents:
1247
diff
changeset
|
25 |
INVALID_STATION = 0xFFFF, |
eccd576e322f
(svn r1770) -Fix: Hopefully last pieces of code that are containing a station-id
truelight
parents:
1247
diff
changeset
|
26 |
INVALID_SLOT = 0xFFFF, |
eccd576e322f
(svn r1770) -Fix: Hopefully last pieces of code that are containing a station-id
truelight
parents:
1247
diff
changeset
|
27 |
NUM_SLOTS = 2, |
eccd576e322f
(svn r1770) -Fix: Hopefully last pieces of code that are containing a station-id
truelight
parents:
1247
diff
changeset
|
28 |
ROAD_STOP_LIMIT = 8, |
eccd576e322f
(svn r1770) -Fix: Hopefully last pieces of code that are containing a station-id
truelight
parents:
1247
diff
changeset
|
29 |
}; |
1217
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
30 |
|
1551
b1c7df6daa63
(svn r2055) -CodeChange: Begun introducting StationID
celestar
parents:
1550
diff
changeset
|
31 |
typedef uint16 StationID; |
b1c7df6daa63
(svn r2055) -CodeChange: Begun introducting StationID
celestar
parents:
1550
diff
changeset
|
32 |
|
1217
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
33 |
typedef struct RoadStop { |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
34 |
TileIndex xy; |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
35 |
bool used; |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
36 |
byte status; |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
37 |
uint32 index; |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
38 |
uint16 slot[NUM_SLOTS]; |
1551
b1c7df6daa63
(svn r2055) -CodeChange: Begun introducting StationID
celestar
parents:
1550
diff
changeset
|
39 |
StationID station; |
1217
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
40 |
uint8 type; |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
41 |
struct RoadStop *next; |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
42 |
struct RoadStop *prev; |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
43 |
} RoadStop; |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
44 |
|
0 | 45 |
struct Station { |
46 |
TileIndex xy; |
|
1217
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
47 |
RoadStop *bus_stops; |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
48 |
RoadStop *truck_stops; |
0 | 49 |
TileIndex train_tile; |
50 |
TileIndex airport_tile; |
|
51 |
TileIndex dock_tile; |
|
52 |
Town *town; |
|
53 |
// alpha_order is obsolete since savegame format 4 |
|
54 |
byte alpha_order_obsolete; |
|
55 |
uint16 string_id; |
|
56 |
||
57 |
ViewportSign sign; |
|
58 |
||
59 |
uint16 had_vehicle_of_type; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
123
diff
changeset
|
60 |
|
0 | 61 |
byte time_since_load; |
62 |
byte time_since_unload; |
|
63 |
byte delete_ctr; |
|
64 |
byte owner; |
|
65 |
byte facilities; |
|
66 |
byte airport_type; |
|
67 |
||
68 |
// trainstation width/height |
|
69 |
byte trainst_w, trainst_h; |
|
70 |
||
393
e1128b94f3fb
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
71 |
byte class_id; // custom graphics station class |
e1128b94f3fb
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
72 |
byte stat_id; // custom graphics station id in the @class_id class |
0 | 73 |
uint16 build_date; |
74 |
||
75 |
//uint16 airport_flags; |
|
393
e1128b94f3fb
(svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents:
389
diff
changeset
|
76 |
uint32 airport_flags; |
1551
b1c7df6daa63
(svn r2055) -CodeChange: Begun introducting StationID
celestar
parents:
1550
diff
changeset
|
77 |
StationID index; |
0 | 78 |
|
79 |
VehicleID last_vehicle; |
|
80 |
GoodsEntry goods[NUM_CARGO]; |
|
1217
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
81 |
|
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
82 |
/* Stuff that is no longer used, but needed for conversion */ |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
83 |
TileIndex bus_tile_obsolete; |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
84 |
TileIndex lorry_tile_obsolete; |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
85 |
|
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
86 |
byte truck_stop_status_obsolete; |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
87 |
byte bus_stop_status_obsolete; |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
88 |
byte blocked_months_obsolete; |
0 | 89 |
}; |
90 |
||
91 |
enum { |
|
92 |
FACIL_TRAIN = 1, |
|
93 |
FACIL_TRUCK_STOP = 2, |
|
94 |
FACIL_BUS_STOP = 4, |
|
95 |
FACIL_AIRPORT = 8, |
|
96 |
FACIL_DOCK = 0x10, |
|
97 |
}; |
|
98 |
||
99 |
enum { |
|
100 |
// HVOT_PENDING_DELETE = 1<<0, // not needed anymore |
|
101 |
HVOT_TRAIN = 1<<1, |
|
102 |
HVOT_BUS = 1 << 2, |
|
103 |
HVOT_TRUCK = 1 << 3, |
|
1217
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
104 |
HVOT_AIRCRAFT = 1 << 4, |
0 | 105 |
HVOT_SHIP = 1 << 5, |
106 |
HVOT_BUOY = 1 << 6 |
|
107 |
}; |
|
108 |
||
568
b0d0df062880
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
449
diff
changeset
|
109 |
enum { |
b0d0df062880
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
449
diff
changeset
|
110 |
CA_BUS = 3, |
b0d0df062880
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
449
diff
changeset
|
111 |
CA_TRUCK = 3, |
b0d0df062880
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
449
diff
changeset
|
112 |
CA_AIR_OILPAD = 3, |
b0d0df062880
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
449
diff
changeset
|
113 |
CA_TRAIN = 4, |
b0d0df062880
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
449
diff
changeset
|
114 |
CA_AIR_HELIPORT = 4, |
b0d0df062880
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
449
diff
changeset
|
115 |
CA_AIR_SMALL = 4, |
b0d0df062880
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
449
diff
changeset
|
116 |
CA_AIR_LARGE = 5, |
b0d0df062880
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
449
diff
changeset
|
117 |
CA_DOCK = 5, |
915 | 118 |
CA_AIR_METRO = 6, |
568
b0d0df062880
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
449
diff
changeset
|
119 |
CA_AIR_INTER = 8, |
915 | 120 |
}; |
568
b0d0df062880
(svn r979) Allow more realistically sized catchment areas
Celestar
parents:
449
diff
changeset
|
121 |
|
0 | 122 |
void ModifyStationRatingAround(TileIndex tile, byte owner, int amount, uint radius); |
123 |
||
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
919
diff
changeset
|
124 |
TileIndex GetStationTileForVehicle(const Vehicle *v, const Station *st); |
55
73fae6c6568e
(svn r56) Improved order checker + patch setting for it (celestar)
dominik
parents:
0
diff
changeset
|
125 |
|
0 | 126 |
void ShowStationViewWindow(int station); |
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
127 |
void UpdateAllStationVirtCoord(void); |
0 | 128 |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
129 |
VARDEF SortStruct *_station_sort; |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
130 |
|
1272
9aa073c64fc7
(svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents:
1266
diff
changeset
|
131 |
extern MemoryPool _station_pool; |
9aa073c64fc7
(svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents:
1266
diff
changeset
|
132 |
|
9aa073c64fc7
(svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents:
1266
diff
changeset
|
133 |
/** |
9aa073c64fc7
(svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents:
1266
diff
changeset
|
134 |
* Get the pointer to the station with index 'index' |
9aa073c64fc7
(svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents:
1266
diff
changeset
|
135 |
*/ |
1551
b1c7df6daa63
(svn r2055) -CodeChange: Begun introducting StationID
celestar
parents:
1550
diff
changeset
|
136 |
static inline Station *GetStation(StationID index) |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
137 |
{ |
1272
9aa073c64fc7
(svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents:
1266
diff
changeset
|
138 |
return (Station*)GetItemFromPool(&_station_pool, index); |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
139 |
} |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
140 |
|
1272
9aa073c64fc7
(svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents:
1266
diff
changeset
|
141 |
/** |
9aa073c64fc7
(svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents:
1266
diff
changeset
|
142 |
* Get the current size of the StationPool |
9aa073c64fc7
(svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents:
1266
diff
changeset
|
143 |
*/ |
9aa073c64fc7
(svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents:
1266
diff
changeset
|
144 |
static inline uint16 GetStationPoolSize(void) |
9aa073c64fc7
(svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents:
1266
diff
changeset
|
145 |
{ |
9aa073c64fc7
(svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents:
1266
diff
changeset
|
146 |
return _station_pool.total_items; |
9aa073c64fc7
(svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents:
1266
diff
changeset
|
147 |
} |
9aa073c64fc7
(svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents:
1266
diff
changeset
|
148 |
|
9aa073c64fc7
(svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents:
1266
diff
changeset
|
149 |
#define FOR_ALL_STATIONS_FROM(st, start) for (st = GetStation(start); st != NULL; st = (st->index + 1 < GetStationPoolSize()) ? GetStation(st->index + 1) : NULL) |
9aa073c64fc7
(svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents:
1266
diff
changeset
|
150 |
#define FOR_ALL_STATIONS(st) FOR_ALL_STATIONS_FROM(st, 0) |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
151 |
|
1284
e1969eb0227b
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
152 |
|
e1969eb0227b
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
153 |
/* Stuff for ROADSTOPS */ |
e1969eb0227b
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
154 |
|
e1969eb0227b
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
155 |
extern MemoryPool _roadstop_pool; |
e1969eb0227b
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
156 |
|
e1969eb0227b
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
157 |
/** |
e1969eb0227b
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
158 |
* Get the pointer to the roadstop with index 'index' |
e1969eb0227b
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
159 |
*/ |
e1969eb0227b
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
160 |
static inline RoadStop *GetRoadStop(uint index) |
e1969eb0227b
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
161 |
{ |
e1969eb0227b
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
162 |
return (RoadStop*)GetItemFromPool(&_roadstop_pool, index); |
e1969eb0227b
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
163 |
} |
e1969eb0227b
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
164 |
|
e1969eb0227b
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
165 |
/** |
e1969eb0227b
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
166 |
* Get the current size of the RoadStoptPool |
e1969eb0227b
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
167 |
*/ |
e1969eb0227b
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
168 |
static inline uint16 GetRoadStopPoolSize(void) |
e1969eb0227b
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
169 |
{ |
e1969eb0227b
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
170 |
return _roadstop_pool.total_items; |
e1969eb0227b
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
171 |
} |
e1969eb0227b
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
172 |
|
e1969eb0227b
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
173 |
#define FOR_ALL_ROADSTOPS_FROM(rs, start) for (rs = GetRoadStop(start); rs != NULL; rs = (rs->index + 1 < GetRoadStopPoolSize()) ? GetRoadStop(rs->index + 1) : NULL) |
e1969eb0227b
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
174 |
#define FOR_ALL_ROADSTOPS(rs) FOR_ALL_ROADSTOPS_FROM(rs, 0) |
e1969eb0227b
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
175 |
|
e1969eb0227b
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
176 |
/* End of stuff for ROADSTOPS */ |
e1969eb0227b
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
177 |
|
e1969eb0227b
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
178 |
|
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
179 |
VARDEF bool _station_sort_dirty[MAX_PLAYERS]; |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
180 |
VARDEF bool _global_station_sort_dirty; |
0 | 181 |
|
1424
38b76de179c9
(svn r1928) Miscellaneous cleanups (data types, whitespace, const correctness)
tron
parents:
1368
diff
changeset
|
182 |
void GetProductionAroundTiles(AcceptedCargo produced, TileIndex tile, int w, int h, int rad); |
38b76de179c9
(svn r1928) Miscellaneous cleanups (data types, whitespace, const correctness)
tron
parents:
1368
diff
changeset
|
183 |
void GetAcceptanceAroundTiles(AcceptedCargo accepts, TileIndex tile, int w, int h, int rad); |
0 | 184 |
uint GetStationPlatforms(Station *st, uint tile); |
384
809833b4068d
(svn r576) -newgrf: Cleanup horrible table/(station|unmovable)_land.h DrawTileSeqStruct hacks needed for custom station supports (pasky)
darkvater
parents:
243
diff
changeset
|
185 |
|
809833b4068d
(svn r576) -newgrf: Cleanup horrible table/(station|unmovable)_land.h DrawTileSeqStruct hacks needed for custom station supports (pasky)
darkvater
parents:
243
diff
changeset
|
186 |
|
449
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
187 |
/* Station layout for given dimensions - it is a two-dimensional array |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
188 |
* where index is computed as (x * platforms) + platform. */ |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
189 |
typedef byte *StationLayout; |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
190 |
|
1477 | 191 |
typedef enum StationClass { |
192 |
STAT_CLASS_NONE, // unused station slot or so |
|
193 |
STAT_CLASS_DFLT, // default station class |
|
194 |
STAT_CLASS_WAYP, // waypoints |
|
195 |
||
196 |
/* TODO: When we actually support custom classes, they are |
|
197 |
* going to be allocated dynamically (with some classid->sclass |
|
198 |
* mapping, there's a TTDPatch limit on 16 custom classes in |
|
199 |
* the whole game at the same time) with base at |
|
200 |
* STAT_CLASS_CUSTOM. --pasky */ |
|
201 |
STAT_CLASS_CUSTOM, // some custom class |
|
202 |
} StationClass; |
|
203 |
||
204 |
typedef struct StationSpec { |
|
400
ad545734c8de
(svn r592) -newgrf: Dynamically allocate global custom station IDs (pasky).
darkvater
parents:
399
diff
changeset
|
205 |
uint32 grfid; |
ad545734c8de
(svn r592) -newgrf: Dynamically allocate global custom station IDs (pasky).
darkvater
parents:
399
diff
changeset
|
206 |
int localidx; // per-GRFFile station index + 1; SetCustomStation() takes care of this |
ad545734c8de
(svn r592) -newgrf: Dynamically allocate global custom station IDs (pasky).
darkvater
parents:
399
diff
changeset
|
207 |
|
1477 | 208 |
StationClass sclass; |
400
ad545734c8de
(svn r592) -newgrf: Dynamically allocate global custom station IDs (pasky).
darkvater
parents:
399
diff
changeset
|
209 |
|
449
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
210 |
/* Bitmask of platform numbers/lengths available for the station. Bits |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
211 |
* 0..6 correspond to 1..7, while bit 7 corresponds to >7 platforms or |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
212 |
* lenght. */ |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
213 |
byte allowed_platforms; |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
214 |
byte allowed_lengths; |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
215 |
|
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
216 |
/* Custom sprites */ |
399
b156fa8bcd63
(svn r591) -newgrf: Store whole struct StationSpec in SetCustomStation(), not just the rendering data. This will be needed for variational stationspecs (pasky).
darkvater
parents:
393
diff
changeset
|
217 |
byte tiles; |
449
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
218 |
/* 00 = plain platform |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
219 |
* 02 = platform with building |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
220 |
* 04 = platform with roof, left side |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
221 |
* 06 = platform with roof, right side |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
222 |
* |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
223 |
* These numbers are used for stations in NE-SW direction, or these |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
224 |
* numbers plus one for stations in the NW-SE direction. */ |
399
b156fa8bcd63
(svn r591) -newgrf: Store whole struct StationSpec in SetCustomStation(), not just the rendering data. This will be needed for variational stationspecs (pasky).
darkvater
parents:
393
diff
changeset
|
225 |
DrawTileSprites renderdata[8]; |
403
dc7aef17c13e
(svn r600) -newgrf: Relocation offset for custom station sprites is now stored separately, making it possible to show different sprites in waypoint selection dialog (pasky).
darkvater
parents:
400
diff
changeset
|
226 |
|
449
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
227 |
/* Custom layouts */ |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
228 |
/* The layout array is organized like [lenghts][platforms], both being |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
229 |
* dynamic arrays, the field itself is length*platforms array containing |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
230 |
* indexes to @renderdata (only even numbers allowed) for the given |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
231 |
* station tile. */ |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
232 |
/* @lengths is length of the @platforms and @layouts arrays, that is |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
233 |
* number of maximal length for which the layout is defined (since |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
234 |
* arrays are indexed from 0, the length itself is at [length - 1]). */ |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
235 |
byte lengths; |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
236 |
/* @platforms is array of number of platforms defined for each length. |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
237 |
* Zero means no platforms defined. */ |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
238 |
byte *platforms; |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
239 |
/* @layout is @layouts-sized array of @platforms-sized arrays, |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
240 |
* containing pointers to length*platforms-sized arrays or NULL if |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
241 |
* default OTTD station layout should be used for stations of these |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
242 |
* dimensions. */ |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
243 |
StationLayout **layouts; |
2856e9ce0754
(svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents:
438
diff
changeset
|
244 |
|
408
48da21eb9ff2
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
245 |
/* Sprite offsets for renderdata->seq->image. spritegroup[0] is default |
48da21eb9ff2
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
246 |
* whilst spritegroup[1] is "CID_PURCHASE". */ |
1477 | 247 |
SpriteGroup spritegroup[2]; |
248 |
} StationSpec; |
|
399
b156fa8bcd63
(svn r591) -newgrf: Store whole struct StationSpec in SetCustomStation(), not just the rendering data. This will be needed for variational stationspecs (pasky).
darkvater
parents:
393
diff
changeset
|
249 |
|
400
ad545734c8de
(svn r592) -newgrf: Dynamically allocate global custom station IDs (pasky).
darkvater
parents:
399
diff
changeset
|
250 |
/* Here, @stid is local per-GRFFile station index. If spec->localidx is not yet |
ad545734c8de
(svn r592) -newgrf: Dynamically allocate global custom station IDs (pasky).
darkvater
parents:
399
diff
changeset
|
251 |
* set, it gets new dynamically allocated global index and spec->localidx is |
ad545734c8de
(svn r592) -newgrf: Dynamically allocate global custom station IDs (pasky).
darkvater
parents:
399
diff
changeset
|
252 |
* set to @stid, otherwise we take it as that we are replacing it and try to |
ad545734c8de
(svn r592) -newgrf: Dynamically allocate global custom station IDs (pasky).
darkvater
parents:
399
diff
changeset
|
253 |
* search for it first (that isn't much fast but we do it only very seldom). */ |
1477 | 254 |
void SetCustomStation(byte stid, StationSpec *spec); |
400
ad545734c8de
(svn r592) -newgrf: Dynamically allocate global custom station IDs (pasky).
darkvater
parents:
399
diff
changeset
|
255 |
/* Here, @stid is global station index (in continous range 0..GetCustomStationsCount()) |
ad545734c8de
(svn r592) -newgrf: Dynamically allocate global custom station IDs (pasky).
darkvater
parents:
399
diff
changeset
|
256 |
* (lookup is therefore very fast as we do this very frequently). */ |
1477 | 257 |
StationSpec *GetCustomStation(StationClass sclass, byte stid); |
408
48da21eb9ff2
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
258 |
/* Get sprite offset for a given custom station and station structure (may be |
48da21eb9ff2
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
259 |
* NULL if ctype is set - that means we are in a build dialog). The station |
48da21eb9ff2
(svn r605) -newgrf: Framework for supporting variational spritegroups . Deterministic only at the moment, but random ones support shouldn't be that difficult now It doesn't do anything, but makes these actions actually possible (pasky).
darkvater
parents:
405
diff
changeset
|
260 |
* structure is used for variational sprite groups. */ |
1477 | 261 |
uint32 GetCustomStationRelocation(StationSpec *spec, Station *stat, byte ctype); |
262 |
int GetCustomStationsCount(StationClass sclass); |
|
389
16ee9854091e
(svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents:
384
diff
changeset
|
263 |
|
1217
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
264 |
RoadStop * GetRoadStopByTile(TileIndex tile, RoadStopType type); |
1368
9eeb0c02a0ee
(svn r1872) -Fix: Fixed an inline problem which caused MSVC6 to not compile :/
celestar
parents:
1330
diff
changeset
|
265 |
static inline int GetRoadStopType(TileIndex tile) |
9eeb0c02a0ee
(svn r1872) -Fix: Fixed an inline problem which caused MSVC6 to not compile :/
celestar
parents:
1330
diff
changeset
|
266 |
{ |
9eeb0c02a0ee
(svn r1872) -Fix: Fixed an inline problem which caused MSVC6 to not compile :/
celestar
parents:
1330
diff
changeset
|
267 |
return (_map5[tile] < 0x47) ? RS_TRUCK : RS_BUS; |
9eeb0c02a0ee
(svn r1872) -Fix: Fixed an inline problem which caused MSVC6 to not compile :/
celestar
parents:
1330
diff
changeset
|
268 |
} |
9eeb0c02a0ee
(svn r1872) -Fix: Fixed an inline problem which caused MSVC6 to not compile :/
celestar
parents:
1330
diff
changeset
|
269 |
|
1217
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
270 |
uint GetNumRoadStops(const Station *st, RoadStopType type); |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
271 |
RoadStop * GetPrimaryRoadStop(const Station *st, RoadStopType type); |
1284
e1969eb0227b
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents:
1272
diff
changeset
|
272 |
RoadStop * AllocateRoadStop( void ); |
1217
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1093
diff
changeset
|
273 |
|
1247 | 274 |
static inline bool IsTrainStationTile(uint tile) { |
275 |
return IsTileType(tile, MP_STATION) && IS_BYTE_INSIDE(_map5[tile], 0, 8); |
|
276 |
} |
|
277 |
||
278 |
static inline bool IsRoadStationTile(uint tile) { |
|
279 |
return IsTileType(tile, MP_STATION) && IS_BYTE_INSIDE(_map5[tile], 0x43, 0x4B); |
|
280 |
} |
|
281 |
||
1330
5d76a0522a11
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1284
diff
changeset
|
282 |
/** |
5d76a0522a11
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1284
diff
changeset
|
283 |
* Check if a station really exists. |
5d76a0522a11
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1284
diff
changeset
|
284 |
*/ |
5d76a0522a11
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1284
diff
changeset
|
285 |
static inline bool IsValidStation(Station* station) |
5d76a0522a11
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1284
diff
changeset
|
286 |
{ |
5d76a0522a11
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1284
diff
changeset
|
287 |
return station->xy != 0; /* XXX: Replace by INVALID_TILE someday */ |
5d76a0522a11
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1284
diff
changeset
|
288 |
} |
5d76a0522a11
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1284
diff
changeset
|
289 |
|
1247 | 290 |
/* Get's the direction the station exit points towards. Ie, returns 0 for a |
291 |
* station with the exit NE. */ |
|
292 |
static inline byte GetRoadStationDir(uint tile) { |
|
293 |
assert(IsRoadStationTile(tile)); |
|
294 |
return (_map5[tile] - 0x43) & 3; |
|
295 |
} |
|
296 |
||
0 | 297 |
#endif /* STATION_H */ |