2005-11-12 00:19:34 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2006-02-03 15:51:00 +00:00
|
|
|
/** @file newgrf_station.h Header file for NewGRF stations */
|
2005-11-12 00:19:34 +00:00
|
|
|
|
2006-02-03 15:51:00 +00:00
|
|
|
#ifndef NEWGRF_STATION_H
|
|
|
|
#define NEWGRF_STATION_H
|
2005-11-12 00:19:34 +00:00
|
|
|
|
|
|
|
#include "engine.h"
|
2007-07-25 19:06:29 +00:00
|
|
|
#include "newgrf_callbacks.h"
|
2006-05-18 02:43:23 +00:00
|
|
|
#include "newgrf_cargo.h"
|
2008-01-09 21:27:39 +00:00
|
|
|
#include "tile_type.h"
|
2008-01-13 01:21:35 +00:00
|
|
|
#include "strings_type.h"
|
2005-11-12 00:19:34 +00:00
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
enum StationClassID {
|
2007-01-10 18:56:51 +00:00
|
|
|
STAT_CLASS_BEGIN = 0, ///< the lowest valid value
|
|
|
|
STAT_CLASS_DFLT = 0, ///< Default station class.
|
|
|
|
STAT_CLASS_WAYP, ///< Waypoint class.
|
|
|
|
STAT_CLASS_MAX = 32, ///< Maximum number of classes.
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2005-11-12 00:19:34 +00:00
|
|
|
|
2007-01-10 18:56:51 +00:00
|
|
|
/** Define basic enum properties */
|
|
|
|
template <> struct EnumPropsT<StationClassID> : MakeEnumPropsT<StationClassID, byte, STAT_CLASS_BEGIN, STAT_CLASS_MAX, STAT_CLASS_MAX> {};
|
|
|
|
typedef TinyEnumT<StationClassID> StationClassIDByte;
|
|
|
|
|
|
|
|
/** Allow incrementing of StationClassID variables */
|
|
|
|
DECLARE_POSTFIX_INCREMENT(StationClassID);
|
|
|
|
|
2005-11-12 00:19:34 +00:00
|
|
|
/* Station layout for given dimensions - it is a two-dimensional array
|
|
|
|
* where index is computed as (x * platforms) + platform. */
|
|
|
|
typedef byte *StationLayout;
|
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
struct StationSpec {
|
2007-04-11 21:04:03 +00:00
|
|
|
const struct GRFFile *grffile; ///< ID of GRF file station belongs to.
|
2005-11-12 00:19:34 +00:00
|
|
|
int localidx; ///< Index within GRF file of station.
|
|
|
|
|
2006-05-07 12:58:45 +00:00
|
|
|
bool allocated; ///< Flag whether this station has been added to a station class list
|
|
|
|
|
2005-11-12 00:19:34 +00:00
|
|
|
StationClassID sclass; ///< The class to which this spec belongs.
|
2006-04-20 17:04:08 +00:00
|
|
|
StringID name; ///< Name of this station.
|
2005-11-12 00:19:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Bitmask of number of platforms available for the station.
|
|
|
|
* 0..6 correpsond to 1..7, while bit 7 corresponds to >7 platforms.
|
|
|
|
*/
|
2006-04-11 13:00:06 +00:00
|
|
|
byte disallowed_platforms;
|
2005-11-12 00:19:34 +00:00
|
|
|
/**
|
|
|
|
* Bitmask of platform lengths available for the station.
|
|
|
|
* 0..6 correpsond to 1..7, while bit 7 corresponds to >7 tiles long.
|
|
|
|
*/
|
2006-04-11 13:00:06 +00:00
|
|
|
byte disallowed_lengths;
|
2005-11-12 00:19:34 +00:00
|
|
|
|
|
|
|
/** Number of tile layouts.
|
|
|
|
* A minimum of 8 is required is required for stations.
|
|
|
|
* 0-1 = plain platform
|
|
|
|
* 2-3 = platform with building
|
|
|
|
* 4-5 = platform with roof, left side
|
|
|
|
* 6-7 = platform with roof, right side
|
|
|
|
*/
|
2006-04-16 18:57:07 +00:00
|
|
|
uint tiles;
|
2005-11-12 00:19:34 +00:00
|
|
|
DrawTileSprites *renderdata; ///< Array of tile layouts.
|
2006-05-03 21:07:44 +00:00
|
|
|
bool copied_renderdata;
|
2005-11-12 00:19:34 +00:00
|
|
|
|
2006-04-11 13:00:06 +00:00
|
|
|
/** Cargo threshold for choosing between little and lots of cargo
|
|
|
|
* @note little/lots are equivalent to the moving/loading states for vehicles
|
|
|
|
*/
|
|
|
|
uint16 cargo_threshold;
|
|
|
|
|
|
|
|
uint32 cargo_triggers; ///< Bitmask of cargo types which cause trigger re-randomizing
|
|
|
|
|
|
|
|
byte callbackmask; ///< Bitmask of callbacks to use, @see newgrf_callbacks.h
|
|
|
|
|
|
|
|
byte flags; ///< Bitmask of flags, bit 0: use different sprite set; bit 1: divide cargo about by station size
|
|
|
|
|
|
|
|
byte pylons; ///< Bitmask of base tiles (0 - 7) which should contain elrail pylons
|
|
|
|
byte wires; ///< Bitmask of base tiles (0 - 7) which should contain elrail wires
|
|
|
|
byte blocked; ///< Bitmask of base tiles (0 - 7) which are blocked to trains
|
|
|
|
|
2005-11-12 00:19:34 +00:00
|
|
|
byte lengths;
|
|
|
|
byte *platforms;
|
|
|
|
StationLayout **layouts;
|
2006-11-08 12:17:14 +00:00
|
|
|
bool copied_layouts;
|
2005-11-12 00:19:34 +00:00
|
|
|
|
|
|
|
/**
|
2007-02-24 23:36:40 +00:00
|
|
|
* NUM_CARGO real cargo plus three pseudo cargo sprite groups.
|
2005-11-12 00:19:34 +00:00
|
|
|
* Used for obtaining the sprite offset of custom sprites, and for
|
|
|
|
* evaluating callbacks.
|
|
|
|
*/
|
2007-02-24 23:36:40 +00:00
|
|
|
const struct SpriteGroup *spritegroup[NUM_CARGO + 3];
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2005-11-12 00:19:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Struct containing information relating to station classes.
|
|
|
|
*/
|
2007-03-07 12:11:48 +00:00
|
|
|
struct StationClass {
|
2005-11-12 00:19:34 +00:00
|
|
|
uint32 id; ///< ID of this class, e.g. 'DFLT', 'WAYP', etc.
|
2006-04-20 17:04:08 +00:00
|
|
|
StringID name; ///< Name of this class.
|
2005-11-12 00:19:34 +00:00
|
|
|
uint stations; ///< Number of stations in this class.
|
|
|
|
StationSpec **spec; ///< Array of station specifications.
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2005-11-12 00:19:34 +00:00
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void ResetStationClasses();
|
2006-05-27 16:12:16 +00:00
|
|
|
StationClassID AllocateStationClass(uint32 cls);
|
2006-04-23 18:37:06 +00:00
|
|
|
void SetStationClassName(StationClassID sclass, StringID name);
|
|
|
|
StringID GetStationClassName(StationClassID sclass);
|
2007-03-07 11:47:46 +00:00
|
|
|
StringID *BuildStationClassDropdown();
|
2006-04-23 18:37:06 +00:00
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
uint GetNumStationClasses();
|
2005-11-12 00:19:34 +00:00
|
|
|
uint GetNumCustomStations(StationClassID sclass);
|
|
|
|
|
2006-04-27 18:28:56 +00:00
|
|
|
void SetCustomStationSpec(StationSpec *statspec);
|
|
|
|
const StationSpec *GetCustomStationSpec(StationClassID sclass, uint station);
|
2006-05-06 21:46:26 +00:00
|
|
|
const StationSpec *GetCustomStationSpecByGrf(uint32 grfid, byte localidx);
|
2005-11-12 00:19:34 +00:00
|
|
|
|
2006-05-06 22:30:36 +00:00
|
|
|
/* Evaluate a tile's position within a station, and return the result a bitstuffed format. */
|
|
|
|
uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, int y, bool centred);
|
|
|
|
|
2006-02-03 23:02:01 +00:00
|
|
|
/* Get sprite offset for a given custom station and station structure (may be
|
2006-05-04 19:21:16 +00:00
|
|
|
* NULL - that means we are in a build dialog). The station structure is used
|
|
|
|
* for variational sprite groups. */
|
|
|
|
SpriteID GetCustomStationRelocation(const StationSpec *statspec, const Station *st, TileIndex tile);
|
2006-05-07 10:58:53 +00:00
|
|
|
SpriteID GetCustomStationGroundRelocation(const StationSpec *statspec, const Station *st, TileIndex tile);
|
2007-07-25 19:06:29 +00:00
|
|
|
uint16 GetStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, const Station *st, TileIndex tile);
|
2006-02-03 23:02:01 +00:00
|
|
|
|
2006-05-06 22:08:14 +00:00
|
|
|
/* Check if a rail station tile is traversable. */
|
|
|
|
bool IsStationTileBlocked(TileIndex tile);
|
|
|
|
|
2006-05-08 21:59:36 +00:00
|
|
|
/* Check if a rail station tile is electrifiable. */
|
|
|
|
bool IsStationTileElectrifiable(TileIndex tile);
|
|
|
|
|
2006-04-19 07:17:00 +00:00
|
|
|
/* Allocate a StationSpec to a Station. This is called once per build operation. */
|
2006-04-27 18:28:56 +00:00
|
|
|
int AllocateSpecToStation(const StationSpec *statspec, Station *st, bool exec);
|
2006-04-19 07:17:00 +00:00
|
|
|
|
|
|
|
/* Deallocate a StationSpec from a Station. Called when removing a single station tile. */
|
2006-07-29 17:39:58 +00:00
|
|
|
void DeallocateSpecFromStation(Station* st, byte specindex);
|
2006-04-19 07:17:00 +00:00
|
|
|
|
2006-05-06 20:48:40 +00:00
|
|
|
/* Draw representation of a station tile for GUI purposes. */
|
|
|
|
bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station);
|
|
|
|
|
2006-02-03 15:51:00 +00:00
|
|
|
#endif /* NEWGRF_STATION_H */
|