station.h
author tron
Wed, 13 Jul 2005 18:04:01 +0000
changeset 2049 ad0d49c916d4
parent 1977 4392ae3d8e31
child 2154 63a6b880b4c0
permissions -rw-r--r--
(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.
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
1272
d3e09adb7736 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
     4
#include "pool.h"
405
6830ae7a0d5d (svn r602) -newgrf: Move DrawTileSeqStruct & co and struct SpriteGroup to sprite.h (pasky)
darkvater
parents: 403
diff changeset
     5
#include "sprite.h"
1247
01711347f9ac (svn r1751) - Feature: New PathFinder (NPF).
matthijs
parents: 1217
diff changeset
     6
#include "tile.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
#include "vehicle.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     8
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     9
typedef struct GoodsEntry {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    10
	uint16 waiting_acceptance;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    11
	byte days_since_pickup;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
	byte rating;
1266
9dc5638fe8cc (svn r1770) -Fix: Hopefully last pieces of code that are containing a station-id
truelight
parents: 1247
diff changeset
    13
	uint16 enroute_from;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
	byte enroute_time;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
	byte last_speed;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
	byte last_age;
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1802
diff changeset
    17
	int32 feeder_profit;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    18
} GoodsEntry;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    19
1217
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    20
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
    21
	RS_BUS,
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    22
	RS_TRUCK
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    23
} RoadStopType;
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    24
1266
9dc5638fe8cc (svn r1770) -Fix: Hopefully last pieces of code that are containing a station-id
truelight
parents: 1247
diff changeset
    25
enum {
9dc5638fe8cc (svn r1770) -Fix: Hopefully last pieces of code that are containing a station-id
truelight
parents: 1247
diff changeset
    26
	INVALID_STATION = 0xFFFF,
9dc5638fe8cc (svn r1770) -Fix: Hopefully last pieces of code that are containing a station-id
truelight
parents: 1247
diff changeset
    27
	INVALID_SLOT = 0xFFFF,
9dc5638fe8cc (svn r1770) -Fix: Hopefully last pieces of code that are containing a station-id
truelight
parents: 1247
diff changeset
    28
	NUM_SLOTS = 2,
9dc5638fe8cc (svn r1770) -Fix: Hopefully last pieces of code that are containing a station-id
truelight
parents: 1247
diff changeset
    29
	ROAD_STOP_LIMIT = 8,
9dc5638fe8cc (svn r1770) -Fix: Hopefully last pieces of code that are containing a station-id
truelight
parents: 1247
diff changeset
    30
};
1217
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    31
1551
eb05e6a90e67 (svn r2055) -CodeChange: Begun introducting StationID
celestar
parents: 1550
diff changeset
    32
typedef uint16 StationID;
eb05e6a90e67 (svn r2055) -CodeChange: Begun introducting StationID
celestar
parents: 1550
diff changeset
    33
1217
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    34
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
    35
	TileIndex xy;
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    36
	bool used;
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    37
	byte status;
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    38
	uint32 index;
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    39
	uint16 slot[NUM_SLOTS];
1551
eb05e6a90e67 (svn r2055) -CodeChange: Begun introducting StationID
celestar
parents: 1550
diff changeset
    40
	StationID station;
1217
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    41
	uint8 type;
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    42
	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
    43
	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
    44
} RoadStop;
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    45
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    46
struct Station {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    47
	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
    48
	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
    49
	RoadStop *truck_stops;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
	TileIndex train_tile;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    51
	TileIndex airport_tile;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    52
	TileIndex dock_tile;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
	Town *town;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    54
	uint16 string_id;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
	ViewportSign sign;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
	uint16 had_vehicle_of_type;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 123
diff changeset
    59
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
	byte time_since_load;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    61
	byte time_since_unload;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
	byte delete_ctr;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    63
	byte owner;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    64
	byte facilities;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
	byte airport_type;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
	// trainstation width/height
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
	byte trainst_w, trainst_h;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
393
82c2bf635cd9 (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents: 389
diff changeset
    70
	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
    71
	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
    72
	uint16 build_date;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    73
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
	//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
    75
	uint32 airport_flags;
1551
eb05e6a90e67 (svn r2055) -CodeChange: Begun introducting StationID
celestar
parents: 1550
diff changeset
    76
	StationID index;
0
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
	VehicleID last_vehicle;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    79
	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
    80
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    81
	/* 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
    82
	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
    83
	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
    84
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    85
	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
    86
	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
    87
	byte blocked_months_obsolete;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
enum {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
	FACIL_TRAIN = 1,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
	FACIL_TRUCK_STOP = 2,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
	FACIL_BUS_STOP = 4,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
	FACIL_AIRPORT = 8,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
	FACIL_DOCK = 0x10,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    98
enum {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
//	HVOT_PENDING_DELETE = 1<<0, // not needed anymore
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
	HVOT_TRAIN = 1<<1,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   101
	HVOT_BUS = 1 << 2,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
	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
   103
	HVOT_AIRCRAFT = 1 << 4,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   104
	HVOT_SHIP = 1 << 5,
1751
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   105
	/* This bit is used to mark stations. No, it does not belong here, but what
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   106
	 * can we do? ;-) */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
	HVOT_BUOY = 1 << 6
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   108
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   109
568
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   110
enum {
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   111
	CA_BUS = 3,
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   112
	CA_TRUCK = 3,
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   113
	CA_AIR_OILPAD = 3,
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   114
	CA_TRAIN = 4,
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   115
	CA_AIR_HELIPORT = 4,
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   116
	CA_AIR_SMALL = 4,
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   117
	CA_AIR_LARGE = 5,
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   118
	CA_DOCK = 5,
915
013cb2d74800 (svn r1402) Trim trailing whitespace
tron
parents: 568
diff changeset
   119
	CA_AIR_METRO = 6,
568
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   120
	CA_AIR_INTER = 8,
915
013cb2d74800 (svn r1402) Trim trailing whitespace
tron
parents: 568
diff changeset
   121
};
568
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   122
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   123
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
   124
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 919
diff changeset
   125
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
   126
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   127
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
   128
void UpdateAllStationVirtCoord(void);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   129
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 915
diff changeset
   130
VARDEF SortStruct *_station_sort;
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 915
diff changeset
   131
1272
d3e09adb7736 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   132
extern MemoryPool _station_pool;
d3e09adb7736 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   133
d3e09adb7736 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   134
/**
d3e09adb7736 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   135
 * Get the pointer to the station with index 'index'
d3e09adb7736 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   136
 */
1551
eb05e6a90e67 (svn r2055) -CodeChange: Begun introducting StationID
celestar
parents: 1550
diff changeset
   137
static inline Station *GetStation(StationID index)
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 915
diff changeset
   138
{
1272
d3e09adb7736 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   139
	return (Station*)GetItemFromPool(&_station_pool, index);
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 915
diff changeset
   140
}
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 915
diff changeset
   141
1272
d3e09adb7736 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   142
/**
d3e09adb7736 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   143
 * Get the current size of the StationPool
d3e09adb7736 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   144
 */
d3e09adb7736 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   145
static inline uint16 GetStationPoolSize(void)
d3e09adb7736 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   146
{
d3e09adb7736 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   147
	return _station_pool.total_items;
d3e09adb7736 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   148
}
d3e09adb7736 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   149
1718
cef0773365eb (svn r2222) Check the parameters of Cmd{Insert,Delete,Modify,Skip}Order() and CmdRestoreOrderIndex():
tron
parents: 1685
diff changeset
   150
static inline bool IsStationIndex(uint index)
cef0773365eb (svn r2222) Check the parameters of Cmd{Insert,Delete,Modify,Skip}Order() and CmdRestoreOrderIndex():
tron
parents: 1685
diff changeset
   151
{
cef0773365eb (svn r2222) Check the parameters of Cmd{Insert,Delete,Modify,Skip}Order() and CmdRestoreOrderIndex():
tron
parents: 1685
diff changeset
   152
	return index < GetStationPoolSize();
cef0773365eb (svn r2222) Check the parameters of Cmd{Insert,Delete,Modify,Skip}Order() and CmdRestoreOrderIndex():
tron
parents: 1685
diff changeset
   153
}
cef0773365eb (svn r2222) Check the parameters of Cmd{Insert,Delete,Modify,Skip}Order() and CmdRestoreOrderIndex():
tron
parents: 1685
diff changeset
   154
1272
d3e09adb7736 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   155
#define FOR_ALL_STATIONS_FROM(st, start) for (st = GetStation(start); st != NULL; st = (st->index + 1 < GetStationPoolSize()) ? GetStation(st->index + 1) : NULL)
d3e09adb7736 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   156
#define FOR_ALL_STATIONS(st) FOR_ALL_STATIONS_FROM(st, 0)
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 915
diff changeset
   157
1284
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   158
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   159
/* Stuff for ROADSTOPS */
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   160
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   161
extern MemoryPool _roadstop_pool;
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   162
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   163
/**
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   164
 * Get the pointer to the roadstop with index 'index'
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   165
 */
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   166
static inline RoadStop *GetRoadStop(uint index)
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   167
{
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   168
	return (RoadStop*)GetItemFromPool(&_roadstop_pool, index);
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   169
}
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   170
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   171
/**
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   172
 * Get the current size of the RoadStoptPool
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   173
 */
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   174
static inline uint16 GetRoadStopPoolSize(void)
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   175
{
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   176
	return _roadstop_pool.total_items;
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   177
}
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   178
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   179
#define FOR_ALL_ROADSTOPS_FROM(rs, start) for (rs = GetRoadStop(start); rs != NULL; rs = (rs->index + 1 < GetRoadStopPoolSize()) ? GetRoadStop(rs->index + 1) : NULL)
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   180
#define FOR_ALL_ROADSTOPS(rs) FOR_ALL_ROADSTOPS_FROM(rs, 0)
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   181
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   182
/* End of stuff for ROADSTOPS */
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   183
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   184
243
9a40daa560ae (svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents: 193
diff changeset
   185
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
   186
VARDEF bool _global_station_sort_dirty;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   187
1424
c6d120592e98 (svn r1928) Miscellaneous cleanups (data types, whitespace, const correctness)
tron
parents: 1368
diff changeset
   188
void GetProductionAroundTiles(AcceptedCargo produced, TileIndex tile, int w, int h, int rad);
c6d120592e98 (svn r1928) Miscellaneous cleanups (data types, whitespace, const correctness)
tron
parents: 1368
diff changeset
   189
void GetAcceptanceAroundTiles(AcceptedCargo accepts, TileIndex tile, int w, int h, int rad);
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1935
diff changeset
   190
uint GetStationPlatforms(Station *st, TileIndex 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
   191
bf1303e754ff (svn r576) -newgrf: Cleanup horrible table/(station|unmovable)_land.h DrawTileSeqStruct hacks needed for custom station supports (pasky)
darkvater
parents: 243
diff changeset
   192
449
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   193
/* 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
   194
 * 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
   195
typedef byte *StationLayout;
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   196
1477
2174a73b11c9 (svn r1981) Typedef some structs and enums
tron
parents: 1424
diff changeset
   197
typedef enum StationClass {
2174a73b11c9 (svn r1981) Typedef some structs and enums
tron
parents: 1424
diff changeset
   198
	STAT_CLASS_NONE, // unused station slot or so
2174a73b11c9 (svn r1981) Typedef some structs and enums
tron
parents: 1424
diff changeset
   199
	STAT_CLASS_DFLT, // default station class
2174a73b11c9 (svn r1981) Typedef some structs and enums
tron
parents: 1424
diff changeset
   200
	STAT_CLASS_WAYP, // waypoints
2174a73b11c9 (svn r1981) Typedef some structs and enums
tron
parents: 1424
diff changeset
   201
2174a73b11c9 (svn r1981) Typedef some structs and enums
tron
parents: 1424
diff changeset
   202
	/* TODO: When we actually support custom classes, they are
2174a73b11c9 (svn r1981) Typedef some structs and enums
tron
parents: 1424
diff changeset
   203
	 * going to be allocated dynamically (with some classid->sclass
2174a73b11c9 (svn r1981) Typedef some structs and enums
tron
parents: 1424
diff changeset
   204
	 * mapping, there's a TTDPatch limit on 16 custom classes in
2174a73b11c9 (svn r1981) Typedef some structs and enums
tron
parents: 1424
diff changeset
   205
	 * the whole game at the same time) with base at
2174a73b11c9 (svn r1981) Typedef some structs and enums
tron
parents: 1424
diff changeset
   206
	 * STAT_CLASS_CUSTOM. --pasky */
2174a73b11c9 (svn r1981) Typedef some structs and enums
tron
parents: 1424
diff changeset
   207
	STAT_CLASS_CUSTOM, // some custom class
2174a73b11c9 (svn r1981) Typedef some structs and enums
tron
parents: 1424
diff changeset
   208
} StationClass;
2174a73b11c9 (svn r1981) Typedef some structs and enums
tron
parents: 1424
diff changeset
   209
2174a73b11c9 (svn r1981) Typedef some structs and enums
tron
parents: 1424
diff changeset
   210
typedef struct StationSpec {
400
d0608455bb77 (svn r592) -newgrf: Dynamically allocate global custom station IDs (pasky).
darkvater
parents: 399
diff changeset
   211
	uint32 grfid;
d0608455bb77 (svn r592) -newgrf: Dynamically allocate global custom station IDs (pasky).
darkvater
parents: 399
diff changeset
   212
	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
   213
1477
2174a73b11c9 (svn r1981) Typedef some structs and enums
tron
parents: 1424
diff changeset
   214
	StationClass sclass;
400
d0608455bb77 (svn r592) -newgrf: Dynamically allocate global custom station IDs (pasky).
darkvater
parents: 399
diff changeset
   215
449
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   216
	/* 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
   217
	 * 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
   218
	 * lenght. */
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   219
	byte allowed_platforms;
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   220
	byte allowed_lengths;
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   221
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   222
	/* 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
   223
	byte tiles;
449
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   224
	/* 00 = plain platform
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   225
	 * 02 = platform with building
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   226
	 * 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
   227
	 * 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
   228
	 *
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   229
	 * 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
   230
	 * 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
   231
	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
   232
449
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   233
	/* Custom layouts */
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   234
	/* 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
   235
	 * 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
   236
	 * 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
   237
	 * station tile. */
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   238
	/* @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
   239
	 * 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
   240
	 * 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
   241
	byte lengths;
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   242
	/* @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
   243
	 * 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
   244
	byte *platforms;
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   245
	/* @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
   246
	 * 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
   247
	 * 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
   248
	 * dimensions. */
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   249
	StationLayout **layouts;
d9325d9f24bb (svn r659) Support for cutomized TTDPatch-style new stations (no selector GUI yet) (pasky)
tron
parents: 438
diff changeset
   250
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
   251
	/* Sprite offsets for renderdata->seq->image. spritegroup[0] is default
1802
448f187042d3 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1768
diff changeset
   252
	 * whilst spritegroup[1] is "GC_PURCHASE". */
1477
2174a73b11c9 (svn r1981) Typedef some structs and enums
tron
parents: 1424
diff changeset
   253
	SpriteGroup spritegroup[2];
2174a73b11c9 (svn r1981) Typedef some structs and enums
tron
parents: 1424
diff changeset
   254
} StationSpec;
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
   255
400
d0608455bb77 (svn r592) -newgrf: Dynamically allocate global custom station IDs (pasky).
darkvater
parents: 399
diff changeset
   256
/* 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
   257
 * 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
   258
 * 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
   259
 * search for it first (that isn't much fast but we do it only very seldom). */
1477
2174a73b11c9 (svn r1981) Typedef some structs and enums
tron
parents: 1424
diff changeset
   260
void SetCustomStation(byte stid, StationSpec *spec);
400
d0608455bb77 (svn r592) -newgrf: Dynamically allocate global custom station IDs (pasky).
darkvater
parents: 399
diff changeset
   261
/* 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
   262
 * (lookup is therefore very fast as we do this very frequently). */
1477
2174a73b11c9 (svn r1981) Typedef some structs and enums
tron
parents: 1424
diff changeset
   263
StationSpec *GetCustomStation(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
   264
/* 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
   265
 * 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
   266
 * structure is used for variational sprite groups. */
1477
2174a73b11c9 (svn r1981) Typedef some structs and enums
tron
parents: 1424
diff changeset
   267
uint32 GetCustomStationRelocation(StationSpec *spec, Station *stat, byte ctype);
2174a73b11c9 (svn r1981) Typedef some structs and enums
tron
parents: 1424
diff changeset
   268
int GetCustomStationsCount(StationClass sclass);
389
2d394eeba5e5 (svn r581) -newgrf: Basic support for new stations - only waypoints supported now and only
celestar
parents: 384
diff changeset
   269
1217
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
   270
RoadStop * GetRoadStopByTile(TileIndex tile, RoadStopType type);
1368
228a2fc009e8 (svn r1872) -Fix: Fixed an inline problem which caused MSVC6 to not compile :/
celestar
parents: 1330
diff changeset
   271
static inline int GetRoadStopType(TileIndex tile)
228a2fc009e8 (svn r1872) -Fix: Fixed an inline problem which caused MSVC6 to not compile :/
celestar
parents: 1330
diff changeset
   272
{
2049
ad0d49c916d4 (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
   273
	return (_m[tile].m5 < 0x47) ? RS_TRUCK : RS_BUS;
1368
228a2fc009e8 (svn r1872) -Fix: Fixed an inline problem which caused MSVC6 to not compile :/
celestar
parents: 1330
diff changeset
   274
}
228a2fc009e8 (svn r1872) -Fix: Fixed an inline problem which caused MSVC6 to not compile :/
celestar
parents: 1330
diff changeset
   275
1217
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
   276
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
   277
RoadStop * GetPrimaryRoadStop(const Station *st, RoadStopType type);
1284
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   278
RoadStop * AllocateRoadStop( void );
1680
0ca4f679c154 (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
   279
void ClearSlot(Vehicle *v, RoadStop *rs);
1217
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
   280
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1935
diff changeset
   281
static inline bool IsTrainStationTile(TileIndex tile)
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1935
diff changeset
   282
{
2049
ad0d49c916d4 (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
   283
	return IsTileType(tile, MP_STATION) && IS_BYTE_INSIDE(_m[tile].m5, 0, 8);
1247
01711347f9ac (svn r1751) - Feature: New PathFinder (NPF).
matthijs
parents: 1217
diff changeset
   284
}
01711347f9ac (svn r1751) - Feature: New PathFinder (NPF).
matthijs
parents: 1217
diff changeset
   285
1685
b9cfe79393c0 (svn r2189) Introduce and use IsCompatibleTrainStationTile()
tron
parents: 1680
diff changeset
   286
static inline bool IsCompatibleTrainStationTile(TileIndex tile, TileIndex ref)
b9cfe79393c0 (svn r2189) Introduce and use IsCompatibleTrainStationTile()
tron
parents: 1680
diff changeset
   287
{
b9cfe79393c0 (svn r2189) Introduce and use IsCompatibleTrainStationTile()
tron
parents: 1680
diff changeset
   288
	assert(IsTrainStationTile(ref));
b9cfe79393c0 (svn r2189) Introduce and use IsCompatibleTrainStationTile()
tron
parents: 1680
diff changeset
   289
	return
b9cfe79393c0 (svn r2189) Introduce and use IsCompatibleTrainStationTile()
tron
parents: 1680
diff changeset
   290
		IsTrainStationTile(tile) &&
2049
ad0d49c916d4 (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
   291
		(_m[tile].m3 & 0x0F) == (_m[ref].m3 & 0x0F) && // same rail type?
ad0d49c916d4 (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
   292
		(_m[tile].m5 & 0x01) == (_m[ref].m5 & 0x01); // same direction?
1685
b9cfe79393c0 (svn r2189) Introduce and use IsCompatibleTrainStationTile()
tron
parents: 1680
diff changeset
   293
}
b9cfe79393c0 (svn r2189) Introduce and use IsCompatibleTrainStationTile()
tron
parents: 1680
diff changeset
   294
1751
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   295
static inline bool IsRoadStationTile(TileIndex tile) {
2049
ad0d49c916d4 (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
   296
	return IsTileType(tile, MP_STATION) && IS_BYTE_INSIDE(_m[tile].m5, 0x43, 0x4B);
1247
01711347f9ac (svn r1751) - Feature: New PathFinder (NPF).
matthijs
parents: 1217
diff changeset
   297
}
01711347f9ac (svn r1751) - Feature: New PathFinder (NPF).
matthijs
parents: 1217
diff changeset
   298
1330
8a67d04016ce (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
   299
/**
8a67d04016ce (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
   300
 * Check if a station really exists.
8a67d04016ce (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
   301
 */
1742
ac65066ebfeb (svn r2246) - CodeChange: Station is 'st' not 'station' - random commit of the day
Darkvater
parents: 1718
diff changeset
   302
static inline bool IsValidStation(const Station *st)
1330
8a67d04016ce (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
   303
{
1742
ac65066ebfeb (svn r2246) - CodeChange: Station is 'st' not 'station' - random commit of the day
Darkvater
parents: 1718
diff changeset
   304
	return st->xy != 0; /* XXX: Replace by INVALID_TILE someday */
1330
8a67d04016ce (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
   305
}
8a67d04016ce (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
   306
1751
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   307
static inline bool IsBuoy(const Station* st)
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   308
{
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   309
	return st->had_vehicle_of_type & HVOT_BUOY; /* XXX: We should really ditch this ugly coding and switch to something sane... */
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   310
}
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   311
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   312
static inline bool IsBuoyTile(TileIndex tile) {
2049
ad0d49c916d4 (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
   313
	return IsTileType(tile, MP_STATION) && _m[tile].m5 == 0x52;
1751
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   314
}
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   315
1247
01711347f9ac (svn r1751) - Feature: New PathFinder (NPF).
matthijs
parents: 1217
diff changeset
   316
/* Get's the direction the station exit points towards. Ie, returns 0 for a
01711347f9ac (svn r1751) - Feature: New PathFinder (NPF).
matthijs
parents: 1217
diff changeset
   317
 * station with the exit NE. */
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1935
diff changeset
   318
static inline byte GetRoadStationDir(TileIndex tile)
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1935
diff changeset
   319
{
1247
01711347f9ac (svn r1751) - Feature: New PathFinder (NPF).
matthijs
parents: 1217
diff changeset
   320
	assert(IsRoadStationTile(tile));
2049
ad0d49c916d4 (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
   321
	return (_m[tile].m5 - 0x43) & 3;
1247
01711347f9ac (svn r1751) - Feature: New PathFinder (NPF).
matthijs
parents: 1217
diff changeset
   322
}
01711347f9ac (svn r1751) - Feature: New PathFinder (NPF).
matthijs
parents: 1217
diff changeset
   323
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   324
#endif /* STATION_H */