# tile_cmd.h

Go to the documentation of this file.

    00001 /* $Id: tile_cmd.h 16744 2009-07-04 21:06:17Z rubidium $ */
    00002
    00005 #ifndef TILE_CMD_H
    00006 #define TILE_CMD_H
    00007
    00008 #include "slope_type.h"
    00009 #include "tile_type.h"
    00010 #include "command_type.h"
    00011 #include "vehicle_type.h"
    00012 #include "cargo_type.h"
    00013 #include "strings_type.h"
    00014 #include "date_type.h"
    00015 #include "company_type.h"
    00016 #include "direction_type.h"
    00017 #include "track_type.h"
    00018 #include "transport_type.h"
    00019 #include "tile_map.h"
    00020
    00022 enum VehicleEnterTileStatus {
    00023   VETS_ENTERED_STATION  = 1,
    00024   VETS_ENTERED_WORMHOLE = 2,
    00025   VETS_CANNOT_ENTER     = 3,
    00026
    00032   VETS_STATION_ID_OFFSET = 8,
    00033   VETS_STATION_MASK      = 0xFFFF << VETS_STATION_ID_OFFSET,
    00034
    00036   VETSB_CONTINUE         = 0,
    00037   VETSB_ENTERED_STATION  = 1 << VETS_ENTERED_STATION,
    00038   VETSB_ENTERED_WORMHOLE = 1 << VETS_ENTERED_WORMHOLE,
    00039   VETSB_CANNOT_ENTER     = 1 << VETS_CANNOT_ENTER,
    00040 };
    00041 DECLARE_ENUM_AS_BIT_SET(VehicleEnterTileStatus);
    00042
    00044 struct TileInfo {
    00045   uint x;
    00046   uint y;
    00047   Slope tileh;
    00048   TileIndex tile;
    00049   uint z;
    00050 };
    00051
    00053 struct TileDesc {
    00054   StringID str;
    00055   Owner owner[4];
    00056   StringID owner_type[4];
    00057   Date build_date;
    00058   StringID station_class;
    00059   StringID station_name;
    00060   const char *grf;
    00061   uint64 dparam[2];
    00062 };
    00063
    00068 typedef void DrawTileProc(TileInfo *ti);
    00069 typedef uint GetSlopeZProc(TileIndex tile, uint x, uint y);
    00070 typedef CommandCost ClearTileProc(TileIndex tile, DoCommandFlag flags);
    00071
    00077 typedef void GetAcceptedCargoProc(TileIndex tile, AcceptedCargo res);
    00078
    00084 typedef void GetTileDescProc(TileIndex tile, TileDesc *td);
    00085
    00099 typedef TrackStatus GetTileTrackStatusProc(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side);
    00100
    00106 typedef void GetProducedCargoProc(TileIndex tile, CargoID *b);
    00107 typedef bool ClickTileProc(TileIndex tile);
    00108 typedef void AnimateTileProc(TileIndex tile);
    00109 typedef void TileLoopProc(TileIndex tile);
    00110 typedef void ChangeTileOwnerProc(TileIndex tile, Owner old_owner, Owner new_owner);
    00111
    00113 typedef VehicleEnterTileStatus VehicleEnterTileProc(Vehicle *v, TileIndex tile, int x, int y);
    00114 typedef Foundation GetFoundationProc(TileIndex tile, Slope tileh);
    00115
    00131 typedef CommandCost TerraformTileProc(TileIndex tile, DoCommandFlag flags, uint z_new, Slope tileh_new);
    00132
    00136 struct TileTypeProcs {
    00137   DrawTileProc *draw_tile_proc;
    00138   GetSlopeZProc *get_slope_z_proc;
    00139   ClearTileProc *clear_tile_proc;
    00140   GetAcceptedCargoProc *get_accepted_cargo_proc;
    00141   GetTileDescProc *get_tile_desc_proc;
    00142   GetTileTrackStatusProc *get_tile_track_status_proc;
    00143   ClickTileProc *click_tile_proc;
    00144   AnimateTileProc *animate_tile_proc;
    00145   TileLoopProc *tile_loop_proc;
    00146   ChangeTileOwnerProc *change_tile_owner_proc;
    00147   GetProducedCargoProc *get_produced_cargo_proc;
    00148   VehicleEnterTileProc *vehicle_enter_tile_proc;
    00149   GetFoundationProc *get_foundation_proc;
    00150   TerraformTileProc *terraform_tile_proc;
    00151 };
    00152
    00153 extern const TileTypeProcs * const _tile_type_procs[16];
    00154
    00155 TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side = INVALID_DIAGDIR);
    00156 VehicleEnterTileStatus VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y);
    00157 void GetAcceptedCargo(TileIndex tile, AcceptedCargo ac);
    00158 void ChangeTileOwner(TileIndex tile, Owner old_owner, Owner new_owner);
    00159 void GetTileDesc(TileIndex tile, TileDesc *td);
    00160
    00161 static inline void AnimateTile(TileIndex tile)
    00162 {
    00163   AnimateTileProc *proc = _tile_type_procs[GetTileType(tile)]->animate_tile_proc;
    00164   assert(proc != NULL);
    00165   proc(tile);
    00166 }
    00167
    00168 static inline bool ClickTile(TileIndex tile)
    00169 {
    00170   ClickTileProc *proc = _tile_type_procs[GetTileType(tile)]->click_tile_proc;
    00171   if (proc == NULL) return false;
    00172   return proc(tile);
    00173 }
    00174
    00175 #endif /* TILE_CMD_H */