00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #ifndef NEWGRF_STATION_H
00013 #define NEWGRF_STATION_H
00014
00015 #include "newgrf_callbacks.h"
00016 #include "sprite.h"
00017 #include "direction_type.h"
00018 #include "cargo_type.h"
00019 #include "strings_type.h"
00020 #include "station_type.h"
00021 #include "rail_type.h"
00022
00023 enum StationClassID {
00024 STAT_CLASS_BEGIN = 0,
00025 STAT_CLASS_DFLT = 0,
00026 STAT_CLASS_WAYP,
00027 STAT_CLASS_MAX = 32,
00028 };
00029 typedef SimpleTinyEnumT<StationClassID, byte> StationClassIDByte;
00030
00032 DECLARE_POSTFIX_INCREMENT(StationClassID);
00033
00034 enum StationSpecFlags {
00035 SSF_SEPARATE_GROUND,
00036 SSF_DIV_BY_STATION_SIZE,
00037 SSF_CB141_RANDOM_BITS,
00038 SSF_CUSTOM_FOUNDATIONS,
00039 SSF_EXTENDED_FOUNDATIONS,
00040 };
00041
00042
00043
00044 typedef byte *StationLayout;
00045
00046 struct StationSpec {
00047 const struct GRFFile *grffile;
00048 int localidx;
00049
00050 bool allocated;
00051
00052 StationClassID sclass;
00053 StringID name;
00054
00059 byte disallowed_platforms;
00064 byte disallowed_lengths;
00065
00073 uint tiles;
00074 DrawTileSprites *renderdata;
00075 bool copied_renderdata;
00076
00080 uint16 cargo_threshold;
00081
00082 uint32 cargo_triggers;
00083
00084 byte callback_mask;
00085
00086 byte flags;
00087
00088 byte pylons;
00089 byte wires;
00090 byte blocked;
00091
00092 byte lengths;
00093 byte *platforms;
00094 StationLayout **layouts;
00095 bool copied_layouts;
00096
00097 uint8 anim_frames;
00098 uint8 anim_status;
00099 uint8 anim_speed;
00100 uint16 anim_triggers;
00101
00107 const struct SpriteGroup *spritegroup[NUM_CARGO + 3];
00108 };
00109
00113 struct StationClass {
00114 uint32 id;
00115 StringID name;
00116 uint stations;
00117 StationSpec **spec;
00118 };
00119
00120 void ResetStationClasses();
00121 StationClassID AllocateStationClass(uint32 cls);
00122 void SetStationClassName(StationClassID sclass, StringID name);
00123 StringID GetStationClassName(StationClassID sclass);
00124 const StationSpec *GetStationSpec(TileIndex t);
00125
00126 uint GetNumStationClasses();
00127 uint GetNumCustomStations(StationClassID sclass);
00128
00129 void SetCustomStationSpec(StationSpec *statspec);
00130 const StationSpec *GetCustomStationSpec(StationClassID sclass, uint station);
00131 const StationSpec *GetCustomStationSpecByGrf(uint32 grfid, byte localidx, int *index);
00132
00133
00134 uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, int y, bool centred);
00135
00136
00137
00138
00139 SpriteID GetCustomStationRelocation(const StationSpec *statspec, const BaseStation *st, TileIndex tile);
00140 SpriteID GetCustomStationGroundRelocation(const StationSpec *statspec, const BaseStation *st, TileIndex tile);
00141 SpriteID GetCustomStationFoundationRelocation(const StationSpec *statspec, const BaseStation *st, TileIndex tile);
00142 uint16 GetStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, const BaseStation *st, TileIndex tile);
00143
00144
00145 int AllocateSpecToStation(const StationSpec *statspec, BaseStation *st, bool exec);
00146
00147
00148 void DeallocateSpecFromStation(BaseStation *st, byte specindex);
00149
00150
00151 bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station);
00152
00153 enum StatAnimTrigger {
00154 STAT_ANIM_BUILT,
00155 STAT_ANIM_NEW_CARGO,
00156 STAT_ANIM_CARGO_TAKEN,
00157 STAT_ANIM_TRAIN_ARRIVES,
00158 STAT_ANIM_TRAIN_DEPARTS,
00159 STAT_ANIM_TRAIN_LOADS,
00160 STAT_ANIM_250_TICKS,
00161 };
00162
00163 void AnimateStationTile(TileIndex tile);
00164 void StationAnimationTrigger(const BaseStation *st, TileIndex tile, StatAnimTrigger trigger, CargoID cargo_type = CT_INVALID);
00165 void StationUpdateAnimTriggers(BaseStation *st);
00166
00167 #endif