station.h
author celestar
Sat, 29 Jan 2005 19:41:44 +0000
changeset 1217 ab9f02a224ab
parent 1093 e8d26c7dc42f
child 1247 01711347f9ac
permissions -rw-r--r--
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
a single station.
Thanks to: Truelight for the saveload code, Darkvater and Hackykid for
network testing and Tron for proof-reading 1500 lines of diff.
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     1
#ifndef STATION_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     2
#define STATION_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     3
405
6830ae7a0d5d (svn r602) -newgrf: Move DrawTileSeqStruct & co and struct SpriteGroup to sprite.h (pasky)
darkvater
parents: 403
diff changeset
     4
#include "sprite.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "vehicle.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     6
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
typedef struct GoodsEntry {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     8
	uint16 waiting_acceptance;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     9
	byte days_since_pickup;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    10
	byte rating;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    11
	byte enroute_from;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
	byte enroute_time;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    13
	byte last_speed;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
	byte last_age;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
} GoodsEntry;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
1217
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    17
typedef enum RoadStopType {
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    18
	RS_BUS,
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    19
	RS_TRUCK
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    20
} RoadStopType;
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    21
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    22
enum { NUM_ROAD_STOPS = 250 };
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    23
enum { ROAD_STOP_LIMIT = 8 };
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    24
enum { NUM_SLOTS = 2 };
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    25
enum { INVALID_SLOT = 0xFFFF };
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    26
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    27
typedef struct RoadStop {
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    28
	TileIndex xy;
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    29
	bool used;
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    30
	byte status;
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    31
	uint32 index;
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    32
	uint16 slot[NUM_SLOTS];
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    33
	uint16 station;		//XXX should be StationIndex
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    34
	uint8 type;
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    35
	struct RoadStop *next;
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    36
	struct RoadStop *prev;
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    37
} RoadStop;
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    38
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    39
struct Station {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    40
	TileIndex xy;
1217
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    41
	RoadStop *bus_stops;
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    42
	RoadStop *truck_stops;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    43
	TileIndex train_tile;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    44
	TileIndex airport_tile;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    45
	TileIndex dock_tile;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    46
	Town *town;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    47
	// alpha_order is obsolete since savegame format 4
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    48
	byte alpha_order_obsolete;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
	uint16 string_id;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    51
	ViewportSign sign;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    52
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
	uint16 had_vehicle_of_type;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 123
diff changeset
    54
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
	byte time_since_load;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
	byte time_since_unload;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
	byte delete_ctr;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
	byte owner;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    59
	byte facilities;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
	byte airport_type;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    61
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
	// trainstation width/height
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    63
	byte trainst_w, trainst_h;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    64
393
82c2bf635cd9 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents: 389
diff changeset
    65
	byte class_id; // custom graphics station class
82c2bf635cd9 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents: 389
diff changeset
    66
	byte stat_id; // custom graphics station id in the @class_id class
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
	uint16 build_date;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
	//uint16 airport_flags;
393
82c2bf635cd9 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents: 389
diff changeset
    70
	uint32 airport_flags;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
	uint16 index;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    72
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    73
	VehicleID last_vehicle;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
	GoodsEntry goods[NUM_CARGO];
1217
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    75
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    76
	/* Stuff that is no longer used, but needed for conversion */
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    77
	TileIndex bus_tile_obsolete;
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    78
	TileIndex lorry_tile_obsolete;
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    79
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    80
	byte truck_stop_status_obsolete;
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    81
	byte bus_stop_status_obsolete;
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    82
	byte blocked_months_obsolete;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    83
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    85
enum {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    86
	FACIL_TRAIN = 1,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
	FACIL_TRUCK_STOP = 2,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
	FACIL_BUS_STOP = 4,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
	FACIL_AIRPORT = 8,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
	FACIL_DOCK = 0x10,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
enum {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
//	HVOT_PENDING_DELETE = 1<<0, // not needed anymore
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
	HVOT_TRAIN = 1<<1,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
	HVOT_BUS = 1 << 2,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
	HVOT_TRUCK = 1 << 3,
1217
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    98
	HVOT_AIRCRAFT = 1 << 4,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
	HVOT_SHIP = 1 << 5,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
	HVOT_BUOY = 1 << 6
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   101
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
568
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   103
enum {
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   104
	CA_BUS = 3,
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   105
	CA_TRUCK = 3,
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   106
	CA_AIR_OILPAD = 3,
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   107
	CA_TRAIN = 4,
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   108
	CA_AIR_HELIPORT = 4,
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   109
	CA_AIR_SMALL = 4,
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   110
	CA_AIR_LARGE = 5,
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   111
	CA_DOCK = 5,
915
013cb2d74800 (svn r1402) Trim trailing whitespace
tron
parents: 568
diff changeset
   112
	CA_AIR_METRO = 6,
568
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   113
	CA_AIR_INTER = 8,
915
013cb2d74800 (svn r1402) Trim trailing whitespace
tron
parents: 568
diff changeset
   114
};
568
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   115
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   116
void ModifyStationRatingAround(TileIndex tile, byte owner, int amount, uint radius);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   117
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 919
diff changeset
   118
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
   119
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
void ShowStationViewWindow(int station);
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1024
diff changeset
   121
void UpdateAllStationVirtCoord(void);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   122
1217
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
   123
VARDEF RoadStop _roadstops[NUM_ROAD_STOPS * 2];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   124
VARDEF Station _stations[250];
1217
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
   125
VARDEF uint _roadstops_size;
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 915
diff changeset
   126
VARDEF uint _stations_size;
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 915
diff changeset
   127
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 915
diff changeset
   128
VARDEF SortStruct *_station_sort;
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 915
diff changeset
   129
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 915
diff changeset
   130
static inline Station *GetStation(uint index)
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 915
diff changeset
   131
{
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 915
diff changeset
   132
	assert(index < _stations_size);
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 915
diff changeset
   133
	return &_stations[index];
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 915
diff changeset
   134
}
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 915
diff changeset
   135
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 915
diff changeset
   136
#define FOR_ALL_STATIONS(st) for(st = _stations; st != &_stations[_stations_size]; st++)
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 915
diff changeset
   137
243
9a40daa560ae (svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents: 193
diff changeset
   138
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
   139
VARDEF bool _global_station_sort_dirty;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   140
568
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   141
void GetProductionAroundTiles(uint *produced, uint tile, int w, int h, int rad);
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   142
void GetAcceptanceAroundTiles(uint *accepts, uint tile, int w, int h, int rad);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
uint GetStationPlatforms(Station *st, uint tile);
384
bf1303e754ff (svn r576) -newgrf: Cleanup horrible table/(station|unmovable)_land.h DrawTileSeqStruct hacks needed for custom station supports (pasky)
darkvater
parents: 243
diff changeset
   144
bf1303e754ff (svn r576) -newgrf: Cleanup horrible table/(station|unmovable)_land.h DrawTileSeqStruct hacks needed for custom station supports (pasky)
darkvater
parents: 243
diff changeset
   145
449
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   146
/* Station layout for given dimensions - it is a two-dimensional array
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   147
 * where index is computed as (x * platforms) + platform. */
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   148
typedef byte *StationLayout;
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   149
399
ad3dcbfd2d48 (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
   150
struct StationSpec {
400
d0608455bb77 (svn r592) -newgrf: Dynamically allocate global custom station IDs (pasky).
darkvater
parents: 399
diff changeset
   151
	uint32 grfid;
d0608455bb77 (svn r592) -newgrf: Dynamically allocate global custom station IDs (pasky).
darkvater
parents: 399
diff changeset
   152
	int localidx; // per-GRFFile station index + 1; SetCustomStation() takes care of this
d0608455bb77 (svn r592) -newgrf: Dynamically allocate global custom station IDs (pasky).
darkvater
parents: 399
diff changeset
   153
438
79b5df3f394a (svn r647) Cleanup custom station classes handling. (pasky)
miham
parents: 408
diff changeset
   154
	enum StationClass {
79b5df3f394a (svn r647) Cleanup custom station classes handling. (pasky)
miham
parents: 408
diff changeset
   155
		STAT_CLASS_NONE, // unused station slot or so
79b5df3f394a (svn r647) Cleanup custom station classes handling. (pasky)
miham
parents: 408
diff changeset
   156
		STAT_CLASS_DFLT, // default station class
79b5df3f394a (svn r647) Cleanup custom station classes handling. (pasky)
miham
parents: 408
diff changeset
   157
		STAT_CLASS_WAYP, // waypoints
79b5df3f394a (svn r647) Cleanup custom station classes handling. (pasky)
miham
parents: 408
diff changeset
   158
79b5df3f394a (svn r647) Cleanup custom station classes handling. (pasky)
miham
parents: 408
diff changeset
   159
		/* TODO: When we actually support custom classes, they are
79b5df3f394a (svn r647) Cleanup custom station classes handling. (pasky)
miham
parents: 408
diff changeset
   160
		 * going to be allocated dynamically (with some classid->sclass
79b5df3f394a (svn r647) Cleanup custom station classes handling. (pasky)
miham
parents: 408
diff changeset
   161
		 * mapping, there's a TTDPatch limit on 16 custom classes in
79b5df3f394a (svn r647) Cleanup custom station classes handling. (pasky)
miham
parents: 408
diff changeset
   162
		 * the whole game at the same time) with base at
79b5df3f394a (svn r647) Cleanup custom station classes handling. (pasky)
miham
parents: 408
diff changeset
   163
		 * STAT_CLASS_CUSTOM. --pasky */
79b5df3f394a (svn r647) Cleanup custom station classes handling. (pasky)
miham
parents: 408
diff changeset
   164
		STAT_CLASS_CUSTOM, // some custom class
79b5df3f394a (svn r647) Cleanup custom station classes handling. (pasky)
miham
parents: 408
diff changeset
   165
	} sclass;
400
d0608455bb77 (svn r592) -newgrf: Dynamically allocate global custom station IDs (pasky).
darkvater
parents: 399
diff changeset
   166
449
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   167
	/* Bitmask of platform numbers/lengths available for the station.  Bits
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   168
	 * 0..6 correspond to 1..7, while bit 7 corresponds to >7 platforms or
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   169
	 * lenght. */
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   170
	byte allowed_platforms;
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   171
	byte allowed_lengths;
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   172
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   173
	/* Custom sprites */
399
ad3dcbfd2d48 (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
   174
	byte tiles;
449
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   175
	/* 00 = plain platform
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   176
	 * 02 = platform with building
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   177
	 * 04 = platform with roof, left side
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   178
	 * 06 = platform with roof, right side
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   179
	 *
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   180
	 * These numbers are used for stations in NE-SW direction, or these
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   181
	 * numbers plus one for stations in the NW-SE direction.  */
399
ad3dcbfd2d48 (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
   182
	DrawTileSprites renderdata[8];
403
bfb365c74e80 (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
   183
449
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   184
	/* Custom layouts */
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   185
	/* The layout array is organized like [lenghts][platforms], both being
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   186
	 * dynamic arrays, the field itself is length*platforms array containing
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   187
	 * indexes to @renderdata (only even numbers allowed) for the given
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   188
	 * station tile. */
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   189
	/* @lengths is length of the @platforms and @layouts arrays, that is
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   190
	 * number of maximal length for which the layout is defined (since
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   191
	 * arrays are indexed from 0, the length itself is at [length - 1]). */
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   192
	byte lengths;
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   193
	/* @platforms is array of number of platforms defined for each length.
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   194
	 * Zero means no platforms defined. */
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   195
	byte *platforms;
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   196
	/* @layout is @layouts-sized array of @platforms-sized arrays,
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   197
	 * containing pointers to length*platforms-sized arrays or NULL if
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   198
	 * default OTTD station layout should be used for stations of these
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   199
	 * dimensions. */
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   200
	StationLayout **layouts;
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   201
408
63a8c0505aab (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
   202
	/* Sprite offsets for renderdata->seq->image. spritegroup[0] is default
63a8c0505aab (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
   203
	 * whilst spritegroup[1] is "CID_PURCHASE". */
63a8c0505aab (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
   204
	struct SpriteGroup spritegroup[2];
399
ad3dcbfd2d48 (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
   205
};
ad3dcbfd2d48 (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
   206
400
d0608455bb77 (svn r592) -newgrf: Dynamically allocate global custom station IDs (pasky).
darkvater
parents: 399
diff changeset
   207
/* Here, @stid is local per-GRFFile station index. If spec->localidx is not yet
d0608455bb77 (svn r592) -newgrf: Dynamically allocate global custom station IDs (pasky).
darkvater
parents: 399
diff changeset
   208
 * set, it gets new dynamically allocated global index and spec->localidx is
d0608455bb77 (svn r592) -newgrf: Dynamically allocate global custom station IDs (pasky).
darkvater
parents: 399
diff changeset
   209
 * set to @stid, otherwise we take it as that we are replacing it and try to
d0608455bb77 (svn r592) -newgrf: Dynamically allocate global custom station IDs (pasky).
darkvater
parents: 399
diff changeset
   210
 * search for it first (that isn't much fast but we do it only very seldom). */
399
ad3dcbfd2d48 (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
   211
void SetCustomStation(byte stid, struct StationSpec *spec);
400
d0608455bb77 (svn r592) -newgrf: Dynamically allocate global custom station IDs (pasky).
darkvater
parents: 399
diff changeset
   212
/* Here, @stid is global station index (in continous range 0..GetCustomStationsCount())
d0608455bb77 (svn r592) -newgrf: Dynamically allocate global custom station IDs (pasky).
darkvater
parents: 399
diff changeset
   213
 * (lookup is therefore very fast as we do this very frequently). */
438
79b5df3f394a (svn r647) Cleanup custom station classes handling. (pasky)
miham
parents: 408
diff changeset
   214
struct StationSpec *GetCustomStation(enum StationClass sclass, byte stid);
408
63a8c0505aab (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
   215
/* Get sprite offset for a given custom station and station structure (may be
63a8c0505aab (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
   216
 * NULL if ctype is set - that means we are in a build dialog). The station
63a8c0505aab (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
   217
 * structure is used for variational sprite groups. */
63a8c0505aab (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
   218
uint32 GetCustomStationRelocation(struct StationSpec *spec, struct Station *stat, byte ctype);
438
79b5df3f394a (svn r647) Cleanup custom station classes handling. (pasky)
miham
parents: 408
diff changeset
   219
int GetCustomStationsCount(enum StationClass sclass);
389
2d394eeba5e5 (svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents: 384
diff changeset
   220
1217
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
   221
RoadStop * GetRoadStopByTile(TileIndex tile, RoadStopType type);
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
   222
inline int GetRoadStopType(TileIndex tile);
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
   223
uint GetNumRoadStops(const Station *st, RoadStopType type);
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
   224
RoadStop * GetPrimaryRoadStop(const Station *st, RoadStopType type);
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
   225
RoadStop * GetFirstFreeRoadStop( void );
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
   226
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   227
#endif /* STATION_H */