tron@2186: /* $Id$ */ truelight@2828: rubidium@8615: /** @file tile_cmd.h Generic 'commands' that can be performed on all tiles. */ truelight@0: rubidium@8615: #ifndef TILE_CMD_H rubidium@8615: #define TILE_CMD_H tron@473: rubidium@8615: #include "slope_type.h" rubidium@8634: #include "tile_type.h" rubidium@8615: #include "command_type.h" rubidium@8615: #include "vehicle_type.h" rubidium@8615: #include "cargo_type.h" rubidium@8634: #include "strings_type.h" rubidium@8636: #include "date_type.h" rubidium@8750: #include "player_type.h" smatz@9092: #include "direction_type.h" frosch@9112: #include "track_type.h" rubidium@10444: #include "transport_type.h" tron@473: rubidium@8615: /** The returned bits of VehicleEnterTile. */ rubidium@8615: enum VehicleEnterTileStatus { rubidium@8615: VETS_ENTERED_STATION = 1, ///< The vehicle entered a station rubidium@8615: VETS_ENTERED_WORMHOLE = 2, ///< The vehicle either entered a bridge, tunnel or depot tile (this includes the last tile of the bridge/tunnel) rubidium@8615: VETS_CANNOT_ENTER = 3, ///< The vehicle cannot enter the tile tron@473: rubidium@8615: /** rubidium@8615: * Shift the VehicleEnterTileStatus this many bits rubidium@8615: * to the right to get the station ID when rubidium@8615: * VETS_ENTERED_STATION is set rubidium@8615: */ rubidium@8615: VETS_STATION_ID_OFFSET = 8, rubidium@8869: VETS_STATION_MASK = 0xFFFF << VETS_STATION_ID_OFFSET, miham@1004: rubidium@8615: /** Bit sets of the above specified bits */ rubidium@8615: VETSB_CONTINUE = 0, ///< The vehicle can continue normally rubidium@8615: VETSB_ENTERED_STATION = 1 << VETS_ENTERED_STATION, ///< The vehicle entered a station rubidium@8615: VETSB_ENTERED_WORMHOLE = 1 << VETS_ENTERED_WORMHOLE, ///< The vehicle either entered a bridge, tunnel or depot tile (this includes the last tile of the bridge/tunnel) rubidium@8615: VETSB_CANNOT_ENTER = 1 << VETS_CANNOT_ENTER, ///< The vehicle cannot enter the tile tron@473: }; rubidium@8615: DECLARE_ENUM_AS_BIT_SET(VehicleEnterTileStatus); truelight@0: rubidium@8634: struct TileInfo { rubidium@8634: uint x; rubidium@8634: uint y; rubidium@8634: Slope tileh; rubidium@8634: TileIndex tile; rubidium@8634: uint z; rubidium@8634: }; rubidium@8634: rubidium@8634: struct TileDesc { rubidium@8634: StringID str; frosch@10662: Owner owner[4]; frosch@10662: StringID owner_type[4]; rubidium@8634: Date build_date; rubidium@8634: uint64 dparam[2]; rubidium@8634: }; rubidium@8634: truelight@0: typedef void DrawTileProc(TileInfo *ti); tron@4231: typedef uint GetSlopeZProc(TileIndex tile, uint x, uint y); rubidium@7446: typedef CommandCost ClearTileProc(TileIndex tile, byte flags); tron@1977: typedef void GetAcceptedCargoProc(TileIndex tile, AcceptedCargo res); tron@1977: typedef void GetTileDescProc(TileIndex tile, TileDesc *td); rubidium@8615: rubidium@7179: /** rubidium@7179: * GetTileTrackStatusProcs return a value that contains the possible tracks frosch@9112: * that can be taken on a given tile by a given transport. frosch@9112: * The return value contains the existing trackdirs and signal states. truelight@159: * frosch@9112: * see track_func.h for usage of TrackStatus. truelight@159: * rubidium@7179: * @param tile the tile to get the track status from rubidium@7179: * @param mode the mode of transportation rubidium@7179: * @param sub_mode used to differentiate between different kinds within the mode frosch@9112: * @return the track status information truelight@159: */ frosch@9112: typedef TrackStatus GetTileTrackStatusProc(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side); Darkvater@3344: typedef void GetProducedCargoProc(TileIndex tile, CargoID *b); tron@1977: typedef void ClickTileProc(TileIndex tile); tron@1977: typedef void AnimateTileProc(TileIndex tile); tron@1977: typedef void TileLoopProc(TileIndex tile); Darkvater@2436: typedef void ChangeTileOwnerProc(TileIndex tile, PlayerID old_player, PlayerID new_player); rubidium@8615: rubidium@6317: /** @see VehicleEnterTileStatus to see what the return values mean */ rubidium@8615: typedef VehicleEnterTileStatus VehicleEnterTileProc(Vehicle *v, TileIndex tile, int x, int y); rubidium@7831: typedef Foundation GetFoundationProc(TileIndex tile, Slope tileh); rubidium@8615: rubidium@7990: /** rubidium@7990: * Called when a tile is affected by a terraforming operation. rubidium@7990: * The function has to check if terraforming of the tile is allowed and return extra terraform-cost that depend on the tiletype. rubidium@7990: * With DC_EXEC in flags it has to perform tiletype-specific actions (like clearing land etc., but not the terraforming itself). rubidium@7990: * rubidium@7990: * @note The terraforming has not yet taken place. So GetTileZ() and GetTileSlope() refer to the landscape before the terraforming operation. rubidium@7990: * rubidium@7990: * @param tile The involved tile. rubidium@7990: * @param flags Command flags passed to the terraform command (DC_EXEC, DC_QUERY_COST, etc.). rubidium@7990: * @param z_new TileZ after terraforming. rubidium@7990: * @param tileh_new Slope after terraforming. rubidium@7990: * @return Error code or extra cost for terraforming (like clearing land, building foundations, etc., but not the terraforming itself.) rubidium@7990: */ rubidium@7990: typedef CommandCost TerraformTileProc(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new); truelight@0: rubidium@6574: struct TileTypeProcs { truelight@0: DrawTileProc *draw_tile_proc; truelight@0: GetSlopeZProc *get_slope_z_proc; truelight@0: ClearTileProc *clear_tile_proc; truelight@0: GetAcceptedCargoProc *get_accepted_cargo_proc; truelight@0: GetTileDescProc *get_tile_desc_proc; truelight@0: GetTileTrackStatusProc *get_tile_track_status_proc; truelight@0: ClickTileProc *click_tile_proc; truelight@0: AnimateTileProc *animate_tile_proc; truelight@0: TileLoopProc *tile_loop_proc; truelight@0: ChangeTileOwnerProc *change_tile_owner_proc; truelight@0: GetProducedCargoProc *get_produced_cargo_proc; truelight@0: VehicleEnterTileProc *vehicle_enter_tile_proc; rubidium@7831: GetFoundationProc *get_foundation_proc; rubidium@7990: TerraformTileProc *terraform_tile_proc; rubidium@6574: }; truelight@0: rubidium@8615: extern const TileTypeProcs * const _tile_type_procs[16]; truelight@0: frosch@9112: TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side = INVALID_DIAGDIR); rubidium@8615: void GetAcceptedCargo(TileIndex tile, AcceptedCargo ac); rubidium@8615: void ChangeTileOwner(TileIndex tile, PlayerID old_player, PlayerID new_player); rubidium@8615: void AnimateTile(TileIndex tile); rubidium@8615: void ClickTile(TileIndex tile); rubidium@8615: void GetTileDesc(TileIndex tile, TileDesc *td); Darkvater@1397: rubidium@8615: #endif /* TILE_CMD_H */