station.h
author truelight
Fri, 06 Jan 2006 17:25:39 +0000
changeset 2823 d4be8420b41c
parent 2817 cdf488223c23
child 2963 f28ce0549513
permissions -rw-r--r--
(svn r3371) -Fix: don't allow road-vehicles to perform an out-of-bound operation while overtaking in a curve (tnx to guru3, Tron and peter1138)
-Codechange: while at that, removed a local variable (more pretty :))
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2154
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2154
diff changeset
     2
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     3
#ifndef STATION_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     4
#define STATION_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
2154
f86c59e73a16 (svn r2664) Remove depedency on player.h from variables.h
tron
parents: 2049
diff changeset
     6
#include "player.h"
1272
9aa073c64fc7 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
     7
#include "pool.h"
405
415546028e8d (svn r602) -newgrf: Move DrawTileSeqStruct & co and struct SpriteGroup to sprite.h (pasky)
darkvater
parents: 403
diff changeset
     8
#include "sprite.h"
1247
3851739bfd09 (svn r1751) - Feature: New PathFinder (NPF).
matthijs
parents: 1217
diff changeset
     9
#include "tile.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    10
#include "vehicle.h"
2625
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents: 2617
diff changeset
    11
#include "station_newgrf.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    13
typedef struct GoodsEntry {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
	uint16 waiting_acceptance;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
	byte days_since_pickup;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
	byte rating;
1266
eccd576e322f (svn r1770) -Fix: Hopefully last pieces of code that are containing a station-id
truelight
parents: 1247
diff changeset
    17
	uint16 enroute_from;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    18
	byte enroute_time;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    19
	byte last_speed;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    20
	byte last_age;
1935
164d58b9137c (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1802
diff changeset
    21
	int32 feeder_profit;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    22
} GoodsEntry;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    23
1217
59c024cfaf54 (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    24
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
    25
	RS_BUS,
59c024cfaf54 (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    26
	RS_TRUCK
59c024cfaf54 (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    27
} RoadStopType;
59c024cfaf54 (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    28
1266
eccd576e322f (svn r1770) -Fix: Hopefully last pieces of code that are containing a station-id
truelight
parents: 1247
diff changeset
    29
enum {
eccd576e322f (svn r1770) -Fix: Hopefully last pieces of code that are containing a station-id
truelight
parents: 1247
diff changeset
    30
	INVALID_STATION = 0xFFFF,
eccd576e322f (svn r1770) -Fix: Hopefully last pieces of code that are containing a station-id
truelight
parents: 1247
diff changeset
    31
	INVALID_SLOT = 0xFFFF,
eccd576e322f (svn r1770) -Fix: Hopefully last pieces of code that are containing a station-id
truelight
parents: 1247
diff changeset
    32
	NUM_SLOTS = 2,
eccd576e322f (svn r1770) -Fix: Hopefully last pieces of code that are containing a station-id
truelight
parents: 1247
diff changeset
    33
	ROAD_STOP_LIMIT = 8,
eccd576e322f (svn r1770) -Fix: Hopefully last pieces of code that are containing a station-id
truelight
parents: 1247
diff changeset
    34
};
1217
59c024cfaf54 (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    35
1551
b1c7df6daa63 (svn r2055) -CodeChange: Begun introducting StationID
celestar
parents: 1550
diff changeset
    36
typedef uint16 StationID;
b1c7df6daa63 (svn r2055) -CodeChange: Begun introducting StationID
celestar
parents: 1550
diff changeset
    37
1217
59c024cfaf54 (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    38
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
    39
	TileIndex xy;
59c024cfaf54 (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    40
	bool used;
59c024cfaf54 (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    41
	byte status;
59c024cfaf54 (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    42
	uint32 index;
59c024cfaf54 (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    43
	uint16 slot[NUM_SLOTS];
1551
b1c7df6daa63 (svn r2055) -CodeChange: Begun introducting StationID
celestar
parents: 1550
diff changeset
    44
	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
    45
	uint8 type;
59c024cfaf54 (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    46
	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
    47
	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
    48
} RoadStop;
59c024cfaf54 (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    49
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
struct Station {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    51
	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
    52
	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
    53
	RoadStop *truck_stops;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    54
	TileIndex train_tile;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
	TileIndex airport_tile;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
	TileIndex dock_tile;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
	Town *town;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
	uint16 string_id;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    59
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
	ViewportSign sign;
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
	uint16 had_vehicle_of_type;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 123
diff changeset
    63
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    64
	byte time_since_load;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
	byte time_since_unload;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
	byte delete_ctr;
2475
efdcc705cb61 (svn r3001) s/Player*/const Player*/
tron
parents: 2436
diff changeset
    67
	PlayerID owner;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
	byte facilities;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
	byte airport_type;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
	// trainstation width/height
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    72
	byte trainst_w, trainst_h;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    73
393
e1128b94f3fb (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents: 389
diff changeset
    74
	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
    75
	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
    76
	uint16 build_date;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    77
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    78
	//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
    79
	uint32 airport_flags;
1551
b1c7df6daa63 (svn r2055) -CodeChange: Begun introducting StationID
celestar
parents: 1550
diff changeset
    80
	StationID index;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    81
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
	VehicleID last_vehicle;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    83
	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
    84
59c024cfaf54 (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    85
	/* 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
    86
	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
    87
	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
    88
59c024cfaf54 (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    89
	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
    90
	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
    91
	byte blocked_months_obsolete;
0
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
enum {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
	FACIL_TRAIN = 1,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
	FACIL_TRUCK_STOP = 2,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
	FACIL_BUS_STOP = 4,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    98
	FACIL_AIRPORT = 8,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
	FACIL_DOCK = 0x10,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
};
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
enum {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   103
//	HVOT_PENDING_DELETE = 1<<0, // not needed anymore
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   104
	HVOT_TRAIN = 1<<1,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
	HVOT_BUS = 1 << 2,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   106
	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
   107
	HVOT_AIRCRAFT = 1 << 4,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   108
	HVOT_SHIP = 1 << 5,
1751
009a240d035a (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   109
	/* This bit is used to mark stations. No, it does not belong here, but what
009a240d035a (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   110
	 * can we do? ;-) */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
	HVOT_BUOY = 1 << 6
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   112
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
568
b0d0df062880 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   114
enum {
b0d0df062880 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   115
	CA_BUS = 3,
b0d0df062880 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   116
	CA_TRUCK = 3,
b0d0df062880 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   117
	CA_AIR_OILPAD = 3,
b0d0df062880 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   118
	CA_TRAIN = 4,
b0d0df062880 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   119
	CA_AIR_HELIPORT = 4,
b0d0df062880 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   120
	CA_AIR_SMALL = 4,
b0d0df062880 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   121
	CA_AIR_LARGE = 5,
b0d0df062880 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   122
	CA_DOCK = 5,
915
d845fe7cf6f2 (svn r1402) Trim trailing whitespace
tron
parents: 568
diff changeset
   123
	CA_AIR_METRO = 6,
568
b0d0df062880 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   124
	CA_AIR_INTER = 8,
915
d845fe7cf6f2 (svn r1402) Trim trailing whitespace
tron
parents: 568
diff changeset
   125
};
568
b0d0df062880 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   126
2498
3ed05caa4449 (svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents: 2488
diff changeset
   127
void ModifyStationRatingAround(TileIndex tile, PlayerID owner, int amount, uint radius);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   128
1024
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 919
diff changeset
   129
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
   130
2498
3ed05caa4449 (svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents: 2488
diff changeset
   131
void ShowStationViewWindow(StationID 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
   132
void UpdateAllStationVirtCoord(void);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   133
919
544f374ee392 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 915
diff changeset
   134
VARDEF SortStruct *_station_sort;
544f374ee392 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 915
diff changeset
   135
1272
9aa073c64fc7 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   136
extern MemoryPool _station_pool;
9aa073c64fc7 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   137
9aa073c64fc7 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   138
/**
9aa073c64fc7 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   139
 * 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
   140
 */
1551
b1c7df6daa63 (svn r2055) -CodeChange: Begun introducting StationID
celestar
parents: 1550
diff changeset
   141
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
   142
{
1272
9aa073c64fc7 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   143
	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
   144
}
544f374ee392 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 915
diff changeset
   145
1272
9aa073c64fc7 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   146
/**
9aa073c64fc7 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   147
 * 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
   148
 */
9aa073c64fc7 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   149
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
   150
{
9aa073c64fc7 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   151
	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
   152
}
9aa073c64fc7 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   153
1718
96d76767ea93 (svn r2222) Check the parameters of Cmd{Insert,Delete,Modify,Skip}Order() and CmdRestoreOrderIndex():
tron
parents: 1685
diff changeset
   154
static inline bool IsStationIndex(uint index)
96d76767ea93 (svn r2222) Check the parameters of Cmd{Insert,Delete,Modify,Skip}Order() and CmdRestoreOrderIndex():
tron
parents: 1685
diff changeset
   155
{
96d76767ea93 (svn r2222) Check the parameters of Cmd{Insert,Delete,Modify,Skip}Order() and CmdRestoreOrderIndex():
tron
parents: 1685
diff changeset
   156
	return index < GetStationPoolSize();
96d76767ea93 (svn r2222) Check the parameters of Cmd{Insert,Delete,Modify,Skip}Order() and CmdRestoreOrderIndex():
tron
parents: 1685
diff changeset
   157
}
96d76767ea93 (svn r2222) Check the parameters of Cmd{Insert,Delete,Modify,Skip}Order() and CmdRestoreOrderIndex():
tron
parents: 1685
diff changeset
   158
1272
9aa073c64fc7 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   159
#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
   160
#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
   161
1284
e1969eb0227b (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   162
e1969eb0227b (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   163
/* Stuff for ROADSTOPS */
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
extern MemoryPool _roadstop_pool;
e1969eb0227b (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   166
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
 * 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
   169
 */
e1969eb0227b (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   170
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
   171
{
e1969eb0227b (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   172
	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
   173
}
e1969eb0227b (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   174
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
 * 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
   177
 */
e1969eb0227b (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   178
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
   179
{
e1969eb0227b (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   180
	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
   181
}
e1969eb0227b (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   182
e1969eb0227b (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   183
#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
   184
#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
   185
e1969eb0227b (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   186
/* 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
   187
e1969eb0227b (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   188
243
9a40daa560ae (svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents: 193
diff changeset
   189
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
   190
VARDEF bool _global_station_sort_dirty;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   191
1424
38b76de179c9 (svn r1928) Miscellaneous cleanups (data types, whitespace, const correctness)
tron
parents: 1368
diff changeset
   192
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
   193
void GetAcceptanceAroundTiles(AcceptedCargo accepts, TileIndex tile, int w, int h, int rad);
2436
7d5df545bd5d (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2186
diff changeset
   194
uint GetStationPlatforms(const Station *st, TileIndex 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
   195
809833b4068d (svn r576) -newgrf: Cleanup horrible table/(station|unmovable)_land.h DrawTileSeqStruct hacks needed for custom station supports (pasky)
darkvater
parents: 243
diff changeset
   196
2520
8a52362c4ada (svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents: 2498
diff changeset
   197
void StationPickerDrawSprite(int x, int y, RailType railtype, int image);
8a52362c4ada (svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents: 2498
diff changeset
   198
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
   199
/* 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
   200
 * 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
   201
 * structure is used for variational sprite groups. */
2436
7d5df545bd5d (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2186
diff changeset
   202
uint32 GetCustomStationRelocation(const StationSpec *spec, const Station *st, byte ctype);
389
16ee9854091e (svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents: 384
diff changeset
   203
1217
59c024cfaf54 (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
   204
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
   205
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
   206
{
2049
538e73c53f54 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1977
diff changeset
   207
	return (_m[tile].m5 < 0x47) ? RS_TRUCK : RS_BUS;
1368
9eeb0c02a0ee (svn r1872) -Fix: Fixed an inline problem which caused MSVC6 to not compile :/
celestar
parents: 1330
diff changeset
   208
}
9eeb0c02a0ee (svn r1872) -Fix: Fixed an inline problem which caused MSVC6 to not compile :/
celestar
parents: 1330
diff changeset
   209
1217
59c024cfaf54 (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
   210
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
   211
RoadStop * AllocateRoadStop( void );
1680
2d69b69f7b17 (svn r2184) - CodeChange: remove the copy of ClearSlot(), which is now also called for CmdSkipOrder(). This also fixes the involuntary crash introduced 2 revisions ago
Darkvater
parents: 1551
diff changeset
   212
void ClearSlot(Vehicle *v, RoadStop *rs);
1217
59c024cfaf54 (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
   213
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1935
diff changeset
   214
static inline bool IsTrainStationTile(TileIndex tile)
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1935
diff changeset
   215
{
2049
538e73c53f54 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1977
diff changeset
   216
	return IsTileType(tile, MP_STATION) && IS_BYTE_INSIDE(_m[tile].m5, 0, 8);
1247
3851739bfd09 (svn r1751) - Feature: New PathFinder (NPF).
matthijs
parents: 1217
diff changeset
   217
}
3851739bfd09 (svn r1751) - Feature: New PathFinder (NPF).
matthijs
parents: 1217
diff changeset
   218
1685
46783dea9b44 (svn r2189) Introduce and use IsCompatibleTrainStationTile()
tron
parents: 1680
diff changeset
   219
static inline bool IsCompatibleTrainStationTile(TileIndex tile, TileIndex ref)
46783dea9b44 (svn r2189) Introduce and use IsCompatibleTrainStationTile()
tron
parents: 1680
diff changeset
   220
{
46783dea9b44 (svn r2189) Introduce and use IsCompatibleTrainStationTile()
tron
parents: 1680
diff changeset
   221
	assert(IsTrainStationTile(ref));
46783dea9b44 (svn r2189) Introduce and use IsCompatibleTrainStationTile()
tron
parents: 1680
diff changeset
   222
	return
46783dea9b44 (svn r2189) Introduce and use IsCompatibleTrainStationTile()
tron
parents: 1680
diff changeset
   223
		IsTrainStationTile(tile) &&
2635
7ed07303448d (svn r3177) GB, CLRBIT, HASBIT, TOGGLEBIT
tron
parents: 2625
diff changeset
   224
		GB(_m[tile].m3, 0, 4) == GB(_m[ref].m3, 0, 4) && // same rail type?
7ed07303448d (svn r3177) GB, CLRBIT, HASBIT, TOGGLEBIT
tron
parents: 2625
diff changeset
   225
		GB(_m[tile].m5, 0, 1) == GB(_m[ref].m5, 0, 1);   // same direction?
1685
46783dea9b44 (svn r2189) Introduce and use IsCompatibleTrainStationTile()
tron
parents: 1680
diff changeset
   226
}
46783dea9b44 (svn r2189) Introduce and use IsCompatibleTrainStationTile()
tron
parents: 1680
diff changeset
   227
1751
009a240d035a (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   228
static inline bool IsRoadStationTile(TileIndex tile) {
2049
538e73c53f54 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1977
diff changeset
   229
	return IsTileType(tile, MP_STATION) && IS_BYTE_INSIDE(_m[tile].m5, 0x43, 0x4B);
1247
3851739bfd09 (svn r1751) - Feature: New PathFinder (NPF).
matthijs
parents: 1217
diff changeset
   230
}
3851739bfd09 (svn r1751) - Feature: New PathFinder (NPF).
matthijs
parents: 1217
diff changeset
   231
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
   232
/**
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
   233
 * 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
   234
 */
1742
21b08bbfba34 (svn r2246) - CodeChange: Station is 'st' not 'station' - random commit of the day
Darkvater
parents: 1718
diff changeset
   235
static inline bool IsValidStation(const Station *st)
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
   236
{
1742
21b08bbfba34 (svn r2246) - CodeChange: Station is 'st' not 'station' - random commit of the day
Darkvater
parents: 1718
diff changeset
   237
	return st->xy != 0; /* XXX: Replace by INVALID_TILE someday */
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
   238
}
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
   239
1751
009a240d035a (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   240
static inline bool IsBuoy(const Station* st)
009a240d035a (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   241
{
009a240d035a (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   242
	return st->had_vehicle_of_type & HVOT_BUOY; /* XXX: We should really ditch this ugly coding and switch to something sane... */
009a240d035a (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   243
}
009a240d035a (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   244
2548
49c8a096033f (svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents: 2520
diff changeset
   245
static inline bool IsBuoyTile(TileIndex tile)
49c8a096033f (svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents: 2520
diff changeset
   246
{
2049
538e73c53f54 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1977
diff changeset
   247
	return IsTileType(tile, MP_STATION) && _m[tile].m5 == 0x52;
1751
009a240d035a (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   248
}
009a240d035a (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   249
1247
3851739bfd09 (svn r1751) - Feature: New PathFinder (NPF).
matthijs
parents: 1217
diff changeset
   250
/* Get's the direction the station exit points towards. Ie, returns 0 for a
3851739bfd09 (svn r1751) - Feature: New PathFinder (NPF).
matthijs
parents: 1217
diff changeset
   251
 * station with the exit NE. */
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1935
diff changeset
   252
static inline byte GetRoadStationDir(TileIndex tile)
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1935
diff changeset
   253
{
1247
3851739bfd09 (svn r1751) - Feature: New PathFinder (NPF).
matthijs
parents: 1217
diff changeset
   254
	assert(IsRoadStationTile(tile));
2049
538e73c53f54 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1977
diff changeset
   255
	return (_m[tile].m5 - 0x43) & 3;
1247
3851739bfd09 (svn r1751) - Feature: New PathFinder (NPF).
matthijs
parents: 1217
diff changeset
   256
}
3851739bfd09 (svn r1751) - Feature: New PathFinder (NPF).
matthijs
parents: 1217
diff changeset
   257
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   258
#endif /* STATION_H */