(svn r11680) -Codechange: refactor more out of openttd.h and functions.h.

This commit is contained in:
rubidium 2007-12-21 22:50:51 +00:00
parent 1b53dbf9cc
commit 6a9e77e079
56 changed files with 268 additions and 204 deletions

View File

@ -4,7 +4,7 @@
#include "../../openttd.h"
#include "../../aircraft.h"
#include "../../bridge_map.h"
#include "../../functions.h"
#include "../../tile_cmd.h"
#include "../../landscape.h"
#include "../../map.h"
#include "../../rail_map.h"

View File

@ -37,4 +37,8 @@ static inline const Bridge *GetBridge(uint i)
void DrawBridgeMiddle(const TileInfo *ti);
bool CheckBridge_Stuff(byte bridge_type, uint bridge_len);
uint32 GetBridgeLength(TileIndex begin, TileIndex end);
int CalcBridgeLenCostFactor(int x);
#endif /* BRIDGE_H */

58
src/cargo_type.h Normal file
View File

@ -0,0 +1,58 @@
/* $Id$ */
/** @file openttd.h */
#ifndef CARGO_TYPE_H
#define CARGO_TYPE_H
typedef byte CargoID;
enum {
// Temperate
CT_PASSENGERS = 0,
CT_COAL = 1,
CT_MAIL = 2,
CT_OIL = 3,
CT_LIVESTOCK = 4,
CT_GOODS = 5,
CT_GRAIN = 6,
CT_WOOD = 7,
CT_IRON_ORE = 8,
CT_STEEL = 9,
CT_VALUABLES = 10,
// Arctic
CT_WHEAT = 6,
CT_HILLY_UNUSED = 8,
CT_PAPER = 9,
CT_GOLD = 10,
CT_FOOD = 11,
// Tropic
CT_RUBBER = 1,
CT_FRUIT = 4,
CT_MAIZE = 6,
CT_COPPER_ORE = 8,
CT_WATER = 9,
CT_DIAMONDS = 10,
// Toyland
CT_SUGAR = 1,
CT_TOYS = 3,
CT_BATTERIES = 4,
CT_CANDY = 5,
CT_TOFFEE = 6,
CT_COLA = 7,
CT_COTTON_CANDY = 8,
CT_BUBBLES = 9,
CT_PLASTIC = 10,
CT_FIZZY_DRINKS = 11,
NUM_CARGO = 32,
CT_NO_REFIT = 0xFE,
CT_INVALID = 0xFF
};
typedef uint AcceptedCargo[NUM_CARGO];
#endif /* OPENTTD_H */

View File

@ -5,6 +5,7 @@
#ifndef CARGOPACKET_H
#define CARGOPACKET_H
#include "economy_type.h"
#include <list>
typedef uint32 CargoPacketID;

View File

@ -5,6 +5,7 @@
#ifndef CARGOTYPE_H
#define CARGOTYPE_H
#include "cargo_type.h"
typedef uint32 CargoLabel;

View File

@ -22,6 +22,7 @@
#include "genworld.h"
#include "industry.h"
#include "water_map.h"
#include "tile_cmd.h"
/*
* In one terraforming command all four corners of a initial tile can be raised/lowered (though this is not available to the player).

View File

@ -76,6 +76,7 @@ void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, Comma
* used for user input data like names or chat messages.
*/
extern const char *_cmd_text;
extern Money _additional_cash_required;
/**
* Checks if a integer value belongs to a command.

View File

@ -18,14 +18,16 @@
#include "stdafx.h"
#include "openttd.h"
#include "functions.h"
#include "gfx.h"
#include "landscape.h"
#include "industry_map.h"
#include "station_map.h"
#include "table/strings.h"
#include "map.h"
#include "vehicle.h"
#include "command_func.h"
#include "tile_cmd.h"
#include "news.h"
#include "station.h"
#include "waypoint.h"

View File

@ -5,10 +5,10 @@
#include "stdafx.h"
#include "openttd.h"
#include "table/strings.h"
#include "functions.h"
#include "viewport.h"
#include "tile_cmd.h"
#include "command_func.h"
#include "table/sprites.h"
#include "viewport.h"
static void DrawTile_Dummy(TileInfo *ti)
{

View File

@ -40,6 +40,7 @@
#include "player_face.h"
#include "group.h"
#include "strings_func.h"
#include "tile_cmd.h"
/**
* Multiply two integer values and shift the results to right.
@ -92,6 +93,9 @@ Economy _economy;
Subsidy _subsidies[MAX_PLAYERS];
Prices _price;
uint16 _price_frac[NUM_PRICES];
Money _cargo_payment_rates[NUM_CARGO];
uint16 _cargo_payment_rates_frac[NUM_CARGO];
Money _additional_cash_required;
Money CalculateCompanyValue(const Player* p)
{

View File

@ -6,6 +6,8 @@
#define ECONOMY_FUNC_H
#include "economy_type.h"
#include "cargo_type.h"
#include "vehicle_type.h"
struct Player;
@ -19,6 +21,8 @@ extern Subsidy _subsidies[MAX_PLAYERS];
/* Prices and also the fractional part. */
extern Prices _price;
extern uint16 _price_frac[NUM_PRICES];
extern Money _cargo_payment_rates[NUM_CARGO];
extern uint16 _cargo_payment_rates_frac[NUM_CARGO];
int UpdateCompanyRatingAndValue(Player *p, bool update);
Pair SetupSubsidyDecodeParam(const Subsidy *s, bool mode);

View File

@ -7,6 +7,7 @@
#include "core/overflowsafe_type.hpp"
#include "core/enum_type.hpp"
#include "cargo_type.h"
typedef OverflowSafeInt64 Money;

View File

@ -7,8 +7,10 @@
#include "oldpool.h"
#include "rail_type.h"
#include "cargo_type.h"
#include "vehicle_type.h"
#include "command_type.h"
#include "sound.h"
#include "vehicle.h"
enum RailVehicleTypes {
RAILVEH_SINGLEHEAD, ///< indicates a "standalone" locomotive

View File

@ -8,6 +8,7 @@
#include "gfx.h"
#include "viewport.h"
#include "core/random_func.hpp"
#include "command_type.h"
void UpdateTownMaxPass(Town *t);
@ -38,11 +39,6 @@ void DeleteAnimatedTile(TileIndex tile);
void AnimateAnimatedTiles();
void InitializeAnimatedTiles();
/* tunnelbridge_cmd.cpp */
bool CheckBridge_Stuff(byte bridge_type, uint bridge_len);
uint32 GetBridgeLength(TileIndex begin, TileIndex end);
int CalcBridgeLenCostFactor(int x);
/* misc_cmd.cpp */
void PlaceTreesRandomly();

View File

@ -7,6 +7,7 @@
#include "string.h"
#include "window_type.h"
#include "gfx.h"
/* main_gui.cpp */
void CcPlaySound10(bool success, TileIndex tile, uint32 p1, uint32 p2);

View File

@ -6,8 +6,10 @@
#define INDUSTRY_H
#include "oldpool.h"
#include "helpers.hpp"
#include "core/random_func.hpp"
#include "newgrf_storage.h"
#include "cargo_type.h"
#include "economy_type.h"
typedef uint16 IndustryGfx;
typedef uint8 IndustryType;

View File

@ -39,6 +39,7 @@
#include "transparency.h"
#include "water.h"
#include "strings_func.h"
#include "tile_cmd.h"
void ShowIndustryViewWindow(int industry);
void BuildOilRig(TileIndex tile);
@ -1511,7 +1512,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, int type, const Ind
DoCommand(cur_tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
MakeIndustry(cur_tile, i->index, it->gfx);
MakeIndustry(cur_tile, i->index, it->gfx, Random());
if (_generating_world) {
SetIndustryConstructionCounter(cur_tile, 3);

View File

@ -156,11 +156,12 @@ static inline void SetIndustryGfx(TileIndex t, IndustryGfx gfx)
/**
* Make the given tile an industry tile
* @param t the tile to make an industry tile
* @param index the industry this tile belongs to
* @param gfx the graphics to use for the tile
* @param t the tile to make an industry tile
* @param index the industry this tile belongs to
* @param gfx the graphics to use for the tile
* @param random the random value
*/
static inline void MakeIndustry(TileIndex t, IndustryID index, IndustryGfx gfx)
static inline void MakeIndustry(TileIndex t, IndustryID index, IndustryGfx gfx, uint8 random)
{
SetTileType(t, MP_INDUSTRY);
_m[t].m1 = 0;
@ -168,7 +169,7 @@ static inline void MakeIndustry(TileIndex t, IndustryID index, IndustryGfx gfx)
_m[t].m3 = 0;
_m[t].m4 = 0;
SetIndustryGfx(t, gfx);
_me[t].m7 = Random();
_me[t].m7 = random;
}
/**

View File

@ -21,6 +21,7 @@
#include "water_map.h"
#include "tgp.h"
#include "genworld.h"
#include "tile_cmd.h"
extern const TileTypeProcs
_tile_type_clear_procs,

View File

@ -5,6 +5,8 @@
#ifndef LANDSCAPE_H
#define LANDSCAPE_H
#include "gfx.h"
enum {
SNOW_LINE_MONTHS = 12,
SNOW_LINE_DAYS = 32,
@ -47,13 +49,6 @@ void DrawFoundation(TileInfo *ti, Foundation f);
void DoClearSquare(TileIndex tile);
void RunTileLoop();
uint32 GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode);
void GetAcceptedCargo(TileIndex tile, AcceptedCargo ac);
void ChangeTileOwner(TileIndex tile, PlayerID old_player, PlayerID new_player);
void AnimateTile(TileIndex tile);
void ClickTile(TileIndex tile);
void GetTileDesc(TileIndex tile, TileDesc *td);
void InitializeLandscape();
void GenerateLandscape(byte mode);

View File

@ -24,6 +24,7 @@
#include "cargotype.h"
#include "group.h"
#include "viewport.h"
#include "economy_func.h"
char _name_array[512][32];

View File

@ -19,6 +19,7 @@
#include "livery.h"
#include "player_face.h"
#include "strings_func.h"
#include "vehicle.h"
/** Change the player's face.
* @param tile unused

View File

@ -40,6 +40,8 @@
#include "strings_func.h"
#include "fileio.h"
#include "fios.h"
#include "tile_cmd.h"
/* Variables to display file lists */
FiosItem *_fios_list;
int _saveload_mode;

View File

@ -30,6 +30,7 @@ extern const char _openttd_revision[];
#include <stdarg.h> /* va_list */
#include "../md5.h"
#include "../fileio.h"
#include "../texteff.hpp"
/* Check whether NETWORK_NUM_LANDSCAPES is still in sync with NUM_LANDSCAPE */
assert_compile((int)NETWORK_NUM_LANDSCAPES == (int)NUM_LANDSCAPE);

View File

@ -6,6 +6,7 @@
#define NEWGRF_CARGO_H
#include "newgrf_callbacks.h"
#include "cargo_type.h"
enum {
CC_NOAVAILABLE = 0, ///< No cargo class has been specified

View File

@ -5,7 +5,7 @@
#include "stdafx.h"
#include "openttd.h"
#include "variables.h"
#include "functions.h"
#include "tile_cmd.h"
#include "landscape.h"
#include "debug.h"
#include "sprite.h"

View File

@ -6,6 +6,7 @@
#define NEWS_H
#include "window_type.h"
#include "vehicle_type.h"
struct NewsItem {
StringID string_id; ///< Message text (sometimes also used for storing other info)

View File

@ -6,6 +6,8 @@
#include "openttd.h"
#include "bridge_map.h"
#include "debug.h"
#include "tile_cmd.h"
#include "bridge.h"
#include "functions.h"
#include "landscape.h"
#include "npf.h"

View File

@ -28,7 +28,6 @@ struct Pair {
#include "map.h"
#include "slope_type.h"
#include "vehicle_type.h"
// Forward declarations of structs.
struct Depot;
@ -41,7 +40,6 @@ struct Industry;
struct DrawPixelInfo;
struct Group;
typedef byte VehicleOrderID; ///< The index of an order within its current vehicle (not pool related)
typedef byte CargoID;
typedef byte LandscapeID;
typedef uint32 SpriteID; ///< The number of a sprite, without mapping bits and colortables
struct PalSpriteID {
@ -233,55 +231,6 @@ struct GameDifficulty {
GDType town_council_tolerance; // minimum required town ratings to be allowed to demolish stuff
};
enum {
// Temperate
CT_PASSENGERS = 0,
CT_COAL = 1,
CT_MAIL = 2,
CT_OIL = 3,
CT_LIVESTOCK = 4,
CT_GOODS = 5,
CT_GRAIN = 6,
CT_WOOD = 7,
CT_IRON_ORE = 8,
CT_STEEL = 9,
CT_VALUABLES = 10,
// Arctic
CT_WHEAT = 6,
CT_HILLY_UNUSED = 8,
CT_PAPER = 9,
CT_GOLD = 10,
CT_FOOD = 11,
// Tropic
CT_RUBBER = 1,
CT_FRUIT = 4,
CT_MAIZE = 6,
CT_COPPER_ORE = 8,
CT_WATER = 9,
CT_DIAMONDS = 10,
// Toyland
CT_SUGAR = 1,
CT_TOYS = 3,
CT_BATTERIES = 4,
CT_CANDY = 5,
CT_TOFFEE = 6,
CT_COLA = 7,
CT_COTTON_CANDY = 8,
CT_BUBBLES = 9,
CT_PLASTIC = 10,
CT_FIZZY_DRINKS = 11,
NUM_CARGO = 32,
CT_NO_REFIT = 0xFE,
CT_INVALID = 0xFF
};
typedef uint AcceptedCargo[NUM_CARGO];
struct TileDesc {
StringID str;
Owner owner;
@ -295,78 +244,6 @@ struct ViewportSign {
byte width_1, width_2;
};
#include "command_type.h"
typedef void DrawTileProc(TileInfo *ti);
typedef uint GetSlopeZProc(TileIndex tile, uint x, uint y);
typedef CommandCost ClearTileProc(TileIndex tile, byte flags);
typedef void GetAcceptedCargoProc(TileIndex tile, AcceptedCargo res);
typedef void GetTileDescProc(TileIndex tile, TileDesc *td);
/**
* GetTileTrackStatusProcs return a value that contains the possible tracks
* that can be taken on a given tile by a given transport. The return value is
* composed as follows: 0xaabbccdd. ccdd and aabb are bitmasks of trackdirs,
* where bit n corresponds to trackdir n. ccdd are the trackdirs that are
* present in the tile (1==present, 0==not present), aabb is the signal
* status, if applicable (0==green/no signal, 1==red, note that this is
* reversed from map3/2[tile] for railway signals).
*
* The result (let's call it ts) is often used as follows:
* tracks = (byte)(ts | ts >>8)
* This effectively converts the present part of the result (ccdd) to a
* track bitmask, which disregards directions. Normally, this is the same as just
* doing (byte)ts I think, although I am not really sure
*
* A trackdir is combination of a track and a dir, where the lower three bits
* are a track, the fourth bit is the direction. these give 12 (or 14)
* possible options: 0-5 and 8-13, so we need 14 bits for a trackdir bitmask
* above.
* @param tile the tile to get the track status from
* @param mode the mode of transportation
* @param sub_mode used to differentiate between different kinds within the mode
* @return the above mentions track status information
*/
typedef uint32 GetTileTrackStatusProc(TileIndex tile, TransportType mode, uint sub_mode);
typedef void GetProducedCargoProc(TileIndex tile, CargoID *b);
typedef void ClickTileProc(TileIndex tile);
typedef void AnimateTileProc(TileIndex tile);
typedef void TileLoopProc(TileIndex tile);
typedef void ChangeTileOwnerProc(TileIndex tile, PlayerID old_player, PlayerID new_player);
/** @see VehicleEnterTileStatus to see what the return values mean */
typedef uint32 VehicleEnterTileProc(Vehicle *v, TileIndex tile, int x, int y);
typedef Foundation GetFoundationProc(TileIndex tile, Slope tileh);
/**
* Called when a tile is affected by a terraforming operation.
* The function has to check if terraforming of the tile is allowed and return extra terraform-cost that depend on the tiletype.
* With DC_EXEC in flags it has to perform tiletype-specific actions (like clearing land etc., but not the terraforming itself).
*
* @note The terraforming has not yet taken place. So GetTileZ() and GetTileSlope() refer to the landscape before the terraforming operation.
*
* @param tile The involved tile.
* @param flags Command flags passed to the terraform command (DC_EXEC, DC_QUERY_COST, etc.).
* @param z_new TileZ after terraforming.
* @param tileh_new Slope after terraforming.
* @return Error code or extra cost for terraforming (like clearing land, building foundations, etc., but not the terraforming itself.)
*/
typedef CommandCost TerraformTileProc(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new);
struct TileTypeProcs {
DrawTileProc *draw_tile_proc;
GetSlopeZProc *get_slope_z_proc;
ClearTileProc *clear_tile_proc;
GetAcceptedCargoProc *get_accepted_cargo_proc;
GetTileDescProc *get_tile_desc_proc;
GetTileTrackStatusProc *get_tile_track_status_proc;
ClickTileProc *click_tile_proc;
AnimateTileProc *animate_tile_proc;
TileLoopProc *tile_loop_proc;
ChangeTileOwnerProc *change_tile_owner_proc;
GetProducedCargoProc *get_produced_cargo_proc;
VehicleEnterTileProc *vehicle_enter_tile_proc;
GetFoundationProc *get_foundation_proc;
TerraformTileProc *terraform_tile_proc;
};
typedef void PlaceProc(TileIndex tile);
enum {

View File

@ -7,6 +7,8 @@
#include "oldpool.h"
#include "core/bitmath_func.hpp"
#include "cargo_type.h"
#include "vehicle_type.h"
enum {
INVALID_VEH_ORDER_ID = 0xFF,

View File

@ -7,7 +7,7 @@
#include "bridge_map.h"
#include "station_map.h"
#include "depot.h"
#include "functions.h"
#include "tile_cmd.h"
#include "landscape.h"
#include "map.h"
#include "pathfind.h"
@ -17,6 +17,7 @@
#include "variables.h"
#include "depot.h"
#include "tunnelbridge_map.h"
#include "core/random_func.hpp"
/* remember which tiles we have already visited so we don't visit them again. */
static bool TPFSetTileBit(TrackPathFinder *tpf, TileIndex tile, int dir)

View File

@ -9,6 +9,8 @@
#include "aystar.h"
#include "rail_type.h"
#include "road_func.h"
#include "cargo_type.h"
#include "command_type.h"
#include "engine.h"
#include "livery.h"
#include "genworld.h"

View File

@ -8,6 +8,7 @@
#include "gfx.h"
#include "rail_type.h"
#include "track_type.h"
#include "vehicle_type.h"
#include "core/bitmath_func.hpp"
#include "variables.h"
#include "economy_func.h"

View File

@ -8,7 +8,7 @@
#include "bridge.h"
#include "cmd_helper.h"
#include "debug.h"
#include "functions.h"
#include "tile_cmd.h"
#include "rail_map.h"
#include "road_map.h"
#include "table/sprites.h"
@ -2334,7 +2334,7 @@ static const signed char _deltacoord_leaveoffset[8] = {
0, 1, 0, -1 /* y */
};
static uint32 VehicleEnter_Track(Vehicle *v, TileIndex tile, int x, int y)
static VehicleEnterTileStatus VehicleEnter_Track(Vehicle *v, TileIndex tile, int x, int y)
{
byte fract_coord;
byte fract_coord_leave;

View File

@ -7,6 +7,7 @@
#include "table/sprites.h"
#include "table/strings.h"
#include "functions.h"
#include "tile_cmd.h"
#include "landscape.h"
#include "date.h"
#include "map.h"

View File

@ -13,7 +13,7 @@
#include "sprite.h"
#include "table/sprites.h"
#include "table/strings.h"
#include "functions.h"
#include "tile_cmd.h"
#include "map.h"
#include "landscape.h"
#include "town_map.h"
@ -1353,7 +1353,7 @@ static const byte _roadveh_enter_depot_dir[4] = {
TRACKDIR_X_SW, TRACKDIR_Y_NW, TRACKDIR_X_NE, TRACKDIR_Y_SE
};
static uint32 VehicleEnter_Road(Vehicle *v, TileIndex tile, int x, int y)
static VehicleEnterTileStatus VehicleEnter_Road(Vehicle *v, TileIndex tile, int x, int y)
{
switch (GetRoadTileType(tile)) {
case ROAD_TILE_CROSSING:

View File

@ -5,8 +5,7 @@
#include "stdafx.h"
#include "openttd.h"
#include "bridge_map.h"
#include "functions.h"
#include "landscape.h"
#include "tile_cmd.h"
#include "road_map.h"
#include "station.h"
#include "tunnel_map.h"

View File

@ -5,7 +5,7 @@
#include "stdafx.h"
#include "openttd.h"
#include "debug.h"
#include "functions.h"
#include "tile_cmd.h"
#include "landscape.h"
#include "road_map.h"
#include "roadveh.h"

View File

@ -7,6 +7,7 @@
#include "ship.h"
#include "table/strings.h"
#include "functions.h"
#include "tile_cmd.h"
#include "landscape.h"
#include "map.h"
#include "vehicle.h"

View File

@ -5,7 +5,8 @@
#ifndef SOUND_H
#define SOUND_H
#include "helpers.hpp"
#include "core/enum_type.hpp"
#include "vehicle_type.h"
struct MusicFileSettings {
byte playlist;

View File

@ -12,6 +12,7 @@
#include "road_type.h"
#include "newgrf_station.h"
#include "cargopacket.h"
#include "cargo_type.h"
#include <list>
#include <set>

View File

@ -9,7 +9,7 @@
#include "bridge_map.h"
#include "cmd_helper.h"
#include "debug.h"
#include "functions.h"
#include "tile_cmd.h"
#include "landscape.h"
#include "station_map.h"
#include "table/sprites.h"
@ -2345,7 +2345,7 @@ static const byte _enter_station_speedtable[12] = {
215, 195, 175, 155, 135, 115, 95, 75, 55, 35, 15, 0
};
static uint32 VehicleEnter_Station(Vehicle *v, TileIndex tile, int x, int y)
static VehicleEnterTileStatus VehicleEnter_Station(Vehicle *v, TileIndex tile, int x, int y)
{
if (v->type == VEH_TRAIN) {
if (IsRailwayStation(tile) && IsFrontEngine(v) &&
@ -2365,7 +2365,7 @@ static uint32 VehicleEnter_Station(Vehicle *v, TileIndex tile, int x, int y)
if (DiagDirToAxis(dir) != AXIS_X) Swap(x, y);
if (y == TILE_SIZE / 2) {
if (dir != DIAGDIR_SE && dir != DIAGDIR_SW) x = TILE_SIZE - 1 - x;
if (x == 12) return VETSB_ENTERED_STATION | (station_id << VETS_STATION_ID_OFFSET); /* enter station */
if (x == 12) return VETSB_ENTERED_STATION | (VehicleEnterTileStatus)(station_id << VETS_STATION_ID_OFFSET); /* enter station */
if (x < 12) {
uint16 spd;

View File

@ -5,6 +5,7 @@
#include "stdafx.h"
#include "openttd.h"
#include "functions.h"
#include "tile_cmd.h"
#include "gfx.h"
#include "landscape.h"
#include "viewport.h"

116
src/tile_cmd.h Normal file
View File

@ -0,0 +1,116 @@
/* $Id$ */
/** @file tile_cmd.h Generic 'commands' that can be performed on all tiles. */
#ifndef TILE_CMD_H
#define TILE_CMD_H
#include "slope_type.h"
#include "command_type.h"
#include "vehicle_type.h"
#include "cargo_type.h"
/** The returned bits of VehicleEnterTile. */
enum VehicleEnterTileStatus {
VETS_ENTERED_STATION = 1, ///< The vehicle entered a station
VETS_ENTERED_WORMHOLE = 2, ///< The vehicle either entered a bridge, tunnel or depot tile (this includes the last tile of the bridge/tunnel)
VETS_CANNOT_ENTER = 3, ///< The vehicle cannot enter the tile
/**
* Shift the VehicleEnterTileStatus this many bits
* to the right to get the station ID when
* VETS_ENTERED_STATION is set
*/
VETS_STATION_ID_OFFSET = 8,
/** Bit sets of the above specified bits */
VETSB_CONTINUE = 0, ///< The vehicle can continue normally
VETSB_ENTERED_STATION = 1 << VETS_ENTERED_STATION, ///< The vehicle entered a station
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)
VETSB_CANNOT_ENTER = 1 << VETS_CANNOT_ENTER, ///< The vehicle cannot enter the tile
};
DECLARE_ENUM_AS_BIT_SET(VehicleEnterTileStatus);
typedef void DrawTileProc(TileInfo *ti);
typedef uint GetSlopeZProc(TileIndex tile, uint x, uint y);
typedef CommandCost ClearTileProc(TileIndex tile, byte flags);
typedef void GetAcceptedCargoProc(TileIndex tile, AcceptedCargo res);
typedef void GetTileDescProc(TileIndex tile, TileDesc *td);
/**
* GetTileTrackStatusProcs return a value that contains the possible tracks
* that can be taken on a given tile by a given transport. The return value is
* composed as follows: 0xaabbccdd. ccdd and aabb are bitmasks of trackdirs,
* where bit n corresponds to trackdir n. ccdd are the trackdirs that are
* present in the tile (1==present, 0==not present), aabb is the signal
* status, if applicable (0==green/no signal, 1==red, note that this is
* reversed from map3/2[tile] for railway signals).
*
* The result (let's call it ts) is often used as follows:
* tracks = (byte)(ts | ts >>8)
* This effectively converts the present part of the result (ccdd) to a
* track bitmask, which disregards directions. Normally, this is the same as just
* doing (byte)ts I think, although I am not really sure
*
* A trackdir is combination of a track and a dir, where the lower three bits
* are a track, the fourth bit is the direction. these give 12 (or 14)
* possible options: 0-5 and 8-13, so we need 14 bits for a trackdir bitmask
* above.
* @param tile the tile to get the track status from
* @param mode the mode of transportation
* @param sub_mode used to differentiate between different kinds within the mode
* @return the above mentions track status information
*/
typedef uint32 GetTileTrackStatusProc(TileIndex tile, TransportType mode, uint sub_mode);
typedef void GetProducedCargoProc(TileIndex tile, CargoID *b);
typedef void ClickTileProc(TileIndex tile);
typedef void AnimateTileProc(TileIndex tile);
typedef void TileLoopProc(TileIndex tile);
typedef void ChangeTileOwnerProc(TileIndex tile, PlayerID old_player, PlayerID new_player);
/** @see VehicleEnterTileStatus to see what the return values mean */
typedef VehicleEnterTileStatus VehicleEnterTileProc(Vehicle *v, TileIndex tile, int x, int y);
typedef Foundation GetFoundationProc(TileIndex tile, Slope tileh);
/**
* Called when a tile is affected by a terraforming operation.
* The function has to check if terraforming of the tile is allowed and return extra terraform-cost that depend on the tiletype.
* With DC_EXEC in flags it has to perform tiletype-specific actions (like clearing land etc., but not the terraforming itself).
*
* @note The terraforming has not yet taken place. So GetTileZ() and GetTileSlope() refer to the landscape before the terraforming operation.
*
* @param tile The involved tile.
* @param flags Command flags passed to the terraform command (DC_EXEC, DC_QUERY_COST, etc.).
* @param z_new TileZ after terraforming.
* @param tileh_new Slope after terraforming.
* @return Error code or extra cost for terraforming (like clearing land, building foundations, etc., but not the terraforming itself.)
*/
typedef CommandCost TerraformTileProc(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new);
struct TileTypeProcs {
DrawTileProc *draw_tile_proc;
GetSlopeZProc *get_slope_z_proc;
ClearTileProc *clear_tile_proc;
GetAcceptedCargoProc *get_accepted_cargo_proc;
GetTileDescProc *get_tile_desc_proc;
GetTileTrackStatusProc *get_tile_track_status_proc;
ClickTileProc *click_tile_proc;
AnimateTileProc *animate_tile_proc;
TileLoopProc *tile_loop_proc;
ChangeTileOwnerProc *change_tile_owner_proc;
GetProducedCargoProc *get_produced_cargo_proc;
VehicleEnterTileProc *vehicle_enter_tile_proc;
GetFoundationProc *get_foundation_proc;
TerraformTileProc *terraform_tile_proc;
};
extern const TileTypeProcs * const _tile_type_procs[16];
uint32 GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode);
void GetAcceptedCargo(TileIndex tile, AcceptedCargo ac);
void ChangeTileOwner(TileIndex tile, PlayerID old_player, PlayerID new_player);
void AnimateTile(TileIndex tile);
void ClickTile(TileIndex tile);
void GetTileDesc(TileIndex tile, TileDesc *td);
#endif /* TILE_CMD_H */

View File

@ -4,7 +4,7 @@
#include "stdafx.h"
#include "openttd.h"
#include "functions.h"
#include "tile_cmd.h"
#include "debug.h"
#include "road_map.h"
#include "road_internal.h" /* Cleaning up road bits */

View File

@ -6,7 +6,7 @@
#include "openttd.h"
#include "bridge_map.h"
#include "debug.h"
#include "functions.h"
#include "tile_cmd.h"
#include "landscape.h"
#include "gui.h"
#include "station_map.h"

View File

@ -9,7 +9,7 @@
#include "table/strings.h"
#include "table/sprites.h"
#include "table/tree_land.h"
#include "functions.h"
#include "tile_cmd.h"
#include "map.h"
#include "landscape.h"
#include "tree_map.h"

View File

@ -12,7 +12,7 @@
#include "road_map.h"
#include "table/sprites.h"
#include "table/strings.h"
#include "functions.h"
#include "tile_cmd.h"
#include "map.h"
#include "landscape.h"
#include "tunnel_map.h"
@ -1257,7 +1257,7 @@ static const byte _tunnel_fractcoord_5[4] = {0x92, 0x89, 0x58, 0x25};
static const byte _tunnel_fractcoord_6[4] = {0x92, 0x89, 0x56, 0x45};
static const byte _tunnel_fractcoord_7[4] = {0x52, 0x85, 0x96, 0x49};
static uint32 VehicleEnter_TunnelBridge(Vehicle *v, TileIndex tile, int x, int y)
static VehicleEnterTileStatus VehicleEnter_TunnelBridge(Vehicle *v, TileIndex tile, int x, int y)
{
int z = GetSlopeZ(x, y) - v->z_pos;

View File

@ -6,7 +6,7 @@
#include "openttd.h"
#include "table/strings.h"
#include "table/sprites.h"
#include "functions.h"
#include "tile_cmd.h"
#include "landscape.h"
#include "map.h"
#include "command_func.h"

View File

@ -11,9 +11,6 @@
#include "gfx.h"
VARDEF Money _cargo_payment_rates[NUM_CARGO];
VARDEF uint16 _cargo_payment_rates_frac[NUM_CARGO];
struct GameOptions {
GameDifficulty diff;
byte diff_level;
@ -39,9 +36,6 @@ VARDEF GameOptions *_opt_ptr;
/* Amount of game ticks */
VARDEF uint16 _tick_counter;
/* This one is not used anymore. */
VARDEF VehicleID _vehicle_id_ctr_day;
/* Skip aging of cargo? */
VARDEF byte _age_cargo_skip_counter;
@ -293,7 +287,6 @@ VARDEF uint32 _news_display_opt;
VARDEF bool _news_ticker_sound;
VARDEF StringID _error_message;
VARDEF Money _additional_cash_required;
VARDEF bool _rightclick_emulate;
@ -317,10 +310,6 @@ VARDEF byte _switch_mode;
VARDEF StringID _switch_mode_errorstr;
VARDEF SmallFiosItem _file_to_saveload;
VARDEF Vehicle *_place_clicked_vehicle;
VARDEF char _ini_videodriver[32], _ini_musicdriver[32], _ini_sounddriver[32], _ini_blitter[32];
VARDEF int _num_resolutions;
@ -339,8 +328,6 @@ VARDEF char *_log_file;
/* landscape.cpp */
extern const byte _tileh_to_sprite[32];
extern const TileTypeProcs * const _tile_type_procs[16];
extern bool _draw_bounding_boxes;
/* misc */

View File

@ -10,7 +10,7 @@
#include "spritecache.h"
#include "table/sprites.h"
#include "table/strings.h"
#include "functions.h"
#include "tile_cmd.h"
#include "landscape.h"
#include "map.h"
#include "vehicle.h"

View File

@ -11,29 +11,11 @@
#include "track_type.h"
#include "rail_type.h"
#include "road_type.h"
#include "cargo_type.h"
#include "window_type.h"
#include "cargopacket.h"
#include "texteff.hpp"
/** The returned bits of VehicleEnterTile. */
enum VehicleEnterTileStatus {
VETS_ENTERED_STATION = 1, ///< The vehicle entered a station
VETS_ENTERED_WORMHOLE = 2, ///< The vehicle either entered a bridge, tunnel or depot tile (this includes the last tile of the bridge/tunnel)
VETS_CANNOT_ENTER = 3, ///< The vehicle cannot enter the tile
/**
* Shift the VehicleEnterTileStatus this many bits
* to the right to get the station ID when
* VETS_ENTERED_STATION is set
*/
VETS_STATION_ID_OFFSET = 8,
/** Bit sets of the above specified bits */
VETSB_CONTINUE = 0, ///< The vehicle can continue normally
VETSB_ENTERED_STATION = 1 << VETS_ENTERED_STATION, ///< The vehicle entered a station
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)
VETSB_CANNOT_ENTER = 1 << VETS_CANNOT_ENTER, ///< The vehicle cannot enter the tile
};
#include "command_type.h"
/** Road vehicle states */
enum RoadVehicleStates {
@ -829,4 +811,9 @@ static inline uint32 GetCmdSendToDepot(const Vehicle *v)
return GetCmdSendToDepot(v->type);
}
/* This one is not used anymore. */
VARDEF VehicleID _vehicle_id_ctr_day;
VARDEF Vehicle *_place_clicked_vehicle;
#endif /* VEHICLE_H */

View File

@ -5,7 +5,7 @@
#include "stdafx.h"
#include "openttd.h"
#include "debug.h"
#include "functions.h"
#include "tile_cmd.h"
#include "gui.h"
#include "spritecache.h"
#include "table/sprites.h"

View File

@ -7,6 +7,8 @@
#include "zoom.hpp"
#include "window_type.h"
#include "vehicle_type.h"
#include "gfx.h"
struct ViewPort {
int left,top; // screen coordinates for the viewport

View File

@ -10,7 +10,7 @@
#include "station_map.h"
#include "table/sprites.h"
#include "table/strings.h"
#include "functions.h"
#include "tile_cmd.h"
#include "landscape.h"
#include "map.h"
#include "vehicle.h"
@ -891,7 +891,7 @@ static void ChangeTileOwner_Water(TileIndex tile, PlayerID old_player, PlayerID
}
}
static uint32 VehicleEnter_Water(Vehicle *v, TileIndex tile, int x, int y)
static VehicleEnterTileStatus VehicleEnter_Water(Vehicle *v, TileIndex tile, int x, int y)
{
return VETSB_CONTINUE;
}

View File

@ -17,7 +17,7 @@
#include "../station.h"
#include "../station_map.h"
#include "../date.h"
#include "../functions.h"
#include "../tile_cmd.h"
#include "../landscape.h"
#include "yapf.h"
#include "../pathfind.h"