newgrf_station.h
author celestar
Wed, 05 Apr 2006 19:08:09 +0000
changeset 3455 fc1fb215e35b
parent 2967 77b04531d7a0
child 3505 091f0285df7d
permissions -rw-r--r--
(svn r4290) -Fix: fixed power computation for mixed consists on level crossings (michi_cc)
2625
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
     1
/* $Id$ */
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
     2
2963
f28ce0549513 (svn r3525) - Rename station_newgrf.[ch] to newgrf_station.[ch], and update project files.
peter1138
parents: 2625
diff changeset
     3
/** @file newgrf_station.h Header file for NewGRF stations */
2625
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
     4
2963
f28ce0549513 (svn r3525) - Rename station_newgrf.[ch] to newgrf_station.[ch], and update project files.
peter1138
parents: 2625
diff changeset
     5
#ifndef NEWGRF_STATION_H
f28ce0549513 (svn r3525) - Rename station_newgrf.[ch] to newgrf_station.[ch], and update project files.
peter1138
parents: 2625
diff changeset
     6
#define NEWGRF_STATION_H
2625
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
     7
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
     8
#include "engine.h"
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
     9
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    10
typedef enum {
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    11
	STAT_CLASS_DFLT,     ///< Default station class.
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    12
	STAT_CLASS_WAYP,     ///< Waypoint class.
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    13
	STAT_CLASS_MAX = 16, ///< Maximum number of classes.
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    14
} StationClassID;
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    15
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    16
/* Station layout for given dimensions - it is a two-dimensional array
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    17
 * where index is computed as (x * platforms) + platform. */
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    18
typedef byte *StationLayout;
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    19
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    20
typedef struct stationspec {
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    21
	uint32 grfid; ///< ID of GRF file station belongs to.
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    22
	int localidx; ///< Index within GRF file of station.
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    23
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    24
	StationClassID sclass; ///< The class to which this spec belongs.
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    25
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    26
	/**
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    27
	 * Bitmask of number of platforms available for the station.
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    28
	 * 0..6 correpsond to 1..7, while bit 7 corresponds to >7 platforms.
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    29
	 */
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    30
	byte allowed_platforms;
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    31
	/**
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    32
	 * Bitmask of platform lengths available for the station.
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    33
	 * 0..6 correpsond to 1..7, while bit 7 corresponds to >7 tiles long.
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    34
	 */
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    35
	byte allowed_lengths;
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    36
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    37
	/** Number of tile layouts.
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    38
	 * A minimum of 8 is required is required for stations.
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    39
	 * 0-1 = plain platform
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    40
	 * 2-3 = platform with building
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    41
	 * 4-5 = platform with roof, left side
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    42
	 * 6-7 = platform with roof, right side
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    43
	 */
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    44
	int tiles;
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    45
	DrawTileSprites *renderdata; ///< Array of tile layouts.
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    46
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    47
	byte lengths;
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    48
	byte *platforms;
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    49
	StationLayout **layouts;
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    50
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    51
	/**
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    52
	 * NUM_GLOBAL_CID sprite groups.
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    53
	 * Used for obtaining the sprite offset of custom sprites, and for
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    54
	 * evaluating callbacks.
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    55
	 */
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    56
	SpriteGroup *spritegroup[NUM_GLOBAL_CID];
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    57
} StationSpec;
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    58
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    59
/**
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    60
 * Struct containing information relating to station classes.
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    61
 */
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    62
typedef struct stationclass {
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    63
	uint32 id;          ///< ID of this class, e.g. 'DFLT', 'WAYP', etc.
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    64
	char *name;         ///< Name of this class.
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    65
	uint stations;      ///< Number of stations in this class.
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    66
	StationSpec **spec; ///< Array of station specifications.
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    67
} StationClass;
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    68
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    69
void ResetStationClasses(void);
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    70
StationClassID AllocateStationClass(uint32 class);
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    71
void SetStationClassName(StationClassID sclass, const char *name);
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    72
uint GetNumCustomStations(StationClassID sclass);
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    73
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    74
void SetCustomStation(StationSpec *spec);
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    75
const StationSpec *GetCustomStation(StationClassID sclass, uint station);
19bf7f695537 (svn r3167) - NewGRF: Start moving custom station code to separate files.
peter1138
parents:
diff changeset
    76
2967
77b04531d7a0 (svn r3530) - NewGRF: Move station resolver to newgrf_station
peter1138
parents: 2963
diff changeset
    77
/* Get sprite offset for a given custom station and station structure (may be
77b04531d7a0 (svn r3530) - NewGRF: Move station resolver to newgrf_station
peter1138
parents: 2963
diff changeset
    78
 * NULL if ctype is set - that means we are in a build dialog). The station
77b04531d7a0 (svn r3530) - NewGRF: Move station resolver to newgrf_station
peter1138
parents: 2963
diff changeset
    79
 * structure is used for variational sprite groups. */
77b04531d7a0 (svn r3530) - NewGRF: Move station resolver to newgrf_station
peter1138
parents: 2963
diff changeset
    80
uint32 GetCustomStationRelocation(const StationSpec *spec, const Station *st, byte ctype);
77b04531d7a0 (svn r3530) - NewGRF: Move station resolver to newgrf_station
peter1138
parents: 2963
diff changeset
    81
2963
f28ce0549513 (svn r3525) - Rename station_newgrf.[ch] to newgrf_station.[ch], and update project files.
peter1138
parents: 2625
diff changeset
    82
#endif /* NEWGRF_STATION_H */