2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
2005-10-19 08:34:37 +00:00
|
|
|
/** @file openttd.h */
|
2005-07-24 14:12:37 +00:00
|
|
|
|
2005-07-15 21:28:26 +00:00
|
|
|
#ifndef OPENTTD_H
|
|
|
|
#define OPENTTD_H
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
#ifndef VARDEF
|
|
|
|
#define VARDEF extern
|
|
|
|
#endif
|
|
|
|
|
2007-01-10 18:56:51 +00:00
|
|
|
#include "helpers.hpp"
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
struct Oblong {
|
2006-10-27 10:27:38 +00:00
|
|
|
int x, y;
|
|
|
|
int width, height;
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2006-10-27 10:27:38 +00:00
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
struct BoundingRect {
|
2006-09-16 13:20:14 +00:00
|
|
|
int width;
|
|
|
|
int height;
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2006-09-16 13:20:14 +00:00
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
struct Pair {
|
2004-08-09 17:04:08 +00:00
|
|
|
int a;
|
|
|
|
int b;
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-07-21 22:15:02 +00:00
|
|
|
#include "map.h"
|
2007-12-19 23:26:02 +00:00
|
|
|
#include "slope_type.h"
|
|
|
|
#include "vehicle_type.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
// Forward declarations of structs.
|
2007-03-07 12:11:48 +00:00
|
|
|
struct Depot;
|
|
|
|
struct Waypoint;
|
|
|
|
struct Station;
|
|
|
|
struct ViewPort;
|
|
|
|
struct Town;
|
|
|
|
struct NewsItem;
|
|
|
|
struct Industry;
|
|
|
|
struct DrawPixelInfo;
|
2007-05-19 09:40:18 +00:00
|
|
|
struct Group;
|
2006-08-26 17:12:24 +00:00
|
|
|
typedef byte VehicleOrderID; ///< The index of an order within its current vehicle (not pool related)
|
2005-05-14 12:36:16 +00:00
|
|
|
typedef byte CargoID;
|
2006-05-12 00:27:12 +00:00
|
|
|
typedef byte LandscapeID;
|
2006-08-26 16:34:03 +00:00
|
|
|
typedef uint32 SpriteID; ///< The number of a sprite, without mapping bits and colortables
|
2007-03-07 12:11:48 +00:00
|
|
|
struct PalSpriteID {
|
2007-01-14 19:57:49 +00:00
|
|
|
SpriteID sprite;
|
|
|
|
SpriteID pal;
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2006-08-26 16:34:03 +00:00
|
|
|
typedef uint16 EngineID;
|
|
|
|
typedef uint16 UnitID;
|
2006-08-26 19:40:40 +00:00
|
|
|
typedef uint16 StringID;
|
2007-08-03 09:08:49 +00:00
|
|
|
static const StringID INVALID_STRING_ID = 0xFFFF;
|
2007-06-18 19:53:50 +00:00
|
|
|
|
2006-11-30 16:03:12 +00:00
|
|
|
typedef EngineID *EngineList; ///< engine list type placeholder acceptable for C code (see helpers.cpp)
|
2006-08-26 19:40:40 +00:00
|
|
|
|
|
|
|
/* IDs used in Pools */
|
|
|
|
typedef uint16 StationID;
|
2007-06-22 11:58:59 +00:00
|
|
|
static const StationID INVALID_STATION = 0xFFFF;
|
2006-08-26 19:40:40 +00:00
|
|
|
typedef uint16 RoadStopID;
|
|
|
|
typedef uint16 TownID;
|
|
|
|
typedef uint16 IndustryID;
|
|
|
|
typedef uint16 DepotID;
|
|
|
|
typedef uint16 WaypointID;
|
|
|
|
typedef uint16 OrderID;
|
|
|
|
typedef uint16 SignID;
|
2007-05-19 09:40:18 +00:00
|
|
|
typedef uint16 GroupID;
|
2006-08-26 19:40:40 +00:00
|
|
|
typedef uint16 EngineRenewID;
|
2006-09-03 08:25:27 +00:00
|
|
|
typedef uint16 DestinationID;
|
2007-10-20 14:51:09 +00:00
|
|
|
|
2007-12-21 08:34:53 +00:00
|
|
|
#include "core/overflowsafe_type.hpp"
|
2007-10-20 14:51:09 +00:00
|
|
|
typedef OverflowSafeInt64 Money;
|
2006-09-03 08:25:27 +00:00
|
|
|
|
|
|
|
/* DestinationID must be at least as large as every these below, because it can
|
|
|
|
* be any of them
|
|
|
|
*/
|
|
|
|
assert_compile(sizeof(DestinationID) == sizeof(DepotID));
|
|
|
|
assert_compile(sizeof(DestinationID) == sizeof(WaypointID));
|
|
|
|
assert_compile(sizeof(DestinationID) == sizeof(StationID));
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
|
2006-08-16 11:39:55 +00:00
|
|
|
enum {
|
|
|
|
INVALID_YEAR = -1,
|
2006-08-20 18:40:57 +00:00
|
|
|
INVALID_DATE = -1,
|
2006-08-16 11:39:55 +00:00
|
|
|
};
|
|
|
|
|
2006-08-20 18:40:57 +00:00
|
|
|
typedef int32 Year;
|
|
|
|
typedef int32 Date;
|
2006-08-14 14:21:15 +00:00
|
|
|
|
2007-10-15 19:59:27 +00:00
|
|
|
typedef uint32 PlayerFace; ///< player face bits, info see in player_face.h
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
enum SwitchModes {
|
2006-08-22 14:38:37 +00:00
|
|
|
SM_NONE = 0,
|
|
|
|
SM_NEWGAME = 1,
|
|
|
|
SM_EDITOR = 2,
|
|
|
|
SM_LOAD = 3,
|
|
|
|
SM_MENU = 4,
|
|
|
|
SM_SAVE = 5,
|
|
|
|
SM_GENRANDLAND = 6,
|
|
|
|
SM_LOAD_SCENARIO = 9,
|
|
|
|
SM_START_SCENARIO = 10,
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
SM_START_HEIGHTMAP = 11,
|
2006-08-22 14:38:37 +00:00
|
|
|
SM_LOAD_HEIGHTMAP = 12,
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
2006-01-06 21:57:37 +00:00
|
|
|
|
|
|
|
/* Modes for GenerateWorld */
|
|
|
|
enum GenerateWorldModes {
|
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
2006-08-19 10:00:30 +00:00
|
|
|
GW_NEWGAME = 0, /* Generate a map for a new game */
|
|
|
|
GW_EMPTY = 1, /* Generate an empty map (sea-level) */
|
|
|
|
GW_RANDOM = 2, /* Generate a random map for SE */
|
|
|
|
GW_HEIGHTMAP = 3, /* Generate a newgame from a heightmap */
|
2006-01-06 21:57:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Modes for InitializeGame, those are _bits_! */
|
|
|
|
enum InitializeGameModes {
|
|
|
|
IG_NONE = 0, /* Don't do anything special */
|
|
|
|
IG_DATE_RESET = 1, /* Reset the date when initializing a game */
|
|
|
|
};
|
|
|
|
|
2007-01-10 18:56:51 +00:00
|
|
|
enum Owner {
|
|
|
|
PLAYER_INACTIVE_CLIENT = 253,
|
|
|
|
PLAYER_NEW_COMPANY = 254,
|
|
|
|
PLAYER_SPECTATOR = 255,
|
|
|
|
OWNER_BEGIN = 0x00,
|
|
|
|
PLAYER_FIRST = 0x00,
|
|
|
|
MAX_PLAYERS = 8,
|
|
|
|
OWNER_TOWN = 0x0F, // a town owns the tile
|
|
|
|
OWNER_NONE = 0x10, // nobody owns the tile
|
|
|
|
OWNER_WATER = 0x11, // "water" owns the tile
|
|
|
|
OWNER_END = 0x12,
|
|
|
|
INVALID_OWNER = 0xFF,
|
|
|
|
INVALID_PLAYER = 0xFF,
|
|
|
|
/* Player identifiers All players below MAX_PLAYERS are playable
|
|
|
|
* players, above, they are special, computer controlled players */
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef Owner PlayerID;
|
|
|
|
|
|
|
|
DECLARE_POSTFIX_INCREMENT(Owner);
|
|
|
|
|
|
|
|
/** Define basic enum properties */
|
|
|
|
template <> struct EnumPropsT<Owner> : MakeEnumPropsT<Owner, byte, OWNER_BEGIN, OWNER_END, INVALID_OWNER> {};
|
|
|
|
typedef TinyEnumT<Owner> OwnerByte;
|
|
|
|
typedef OwnerByte PlayerByte;
|
|
|
|
|
2006-01-06 21:57:37 +00:00
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
enum TransportType {
|
2004-09-05 16:15:22 +00:00
|
|
|
/* These constants are for now linked to the representation of bridges
|
2006-03-26 11:08:44 +00:00
|
|
|
* and tunnels, so they can be used by GetTileTrackStatus_TunnelBridge.
|
|
|
|
* In an ideal world, these constants would be used everywhere when
|
|
|
|
* accessing tunnels and bridges. For now, you should just not change
|
|
|
|
* the values for road and rail.
|
2004-09-05 16:15:22 +00:00
|
|
|
*/
|
2007-01-10 18:56:51 +00:00
|
|
|
TRANSPORT_BEGIN = 0,
|
2006-02-13 21:15:00 +00:00
|
|
|
TRANSPORT_RAIL = 0,
|
2004-09-05 16:15:22 +00:00
|
|
|
TRANSPORT_ROAD = 1,
|
2006-08-28 18:53:03 +00:00
|
|
|
TRANSPORT_WATER, // = 2
|
2005-06-22 22:38:18 +00:00
|
|
|
TRANSPORT_END,
|
|
|
|
INVALID_TRANSPORT = 0xff,
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2004-09-05 16:15:22 +00:00
|
|
|
|
2007-01-10 18:56:51 +00:00
|
|
|
/** Define basic enum properties */
|
|
|
|
template <> struct EnumPropsT<TransportType> : MakeEnumPropsT<TransportType, byte, TRANSPORT_BEGIN, TRANSPORT_END, INVALID_TRANSPORT> {};
|
|
|
|
typedef TinyEnumT<TransportType> TransportTypeByte;
|
|
|
|
|
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
struct TileInfo {
|
2004-08-09 17:04:08 +00:00
|
|
|
uint x;
|
|
|
|
uint y;
|
2006-04-23 13:48:16 +00:00
|
|
|
Slope tileh;
|
2005-06-24 12:38:35 +00:00
|
|
|
TileIndex tile;
|
2004-08-09 17:04:08 +00:00
|
|
|
uint z;
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Display Options */
|
|
|
|
enum {
|
2007-05-07 11:24:23 +00:00
|
|
|
DO_SHOW_TOWN_NAMES = 0,
|
|
|
|
DO_SHOW_STATION_NAMES = 1,
|
|
|
|
DO_SHOW_SIGNS = 2,
|
|
|
|
DO_FULL_ANIMATION = 3,
|
|
|
|
DO_FULL_DETAIL = 5,
|
|
|
|
DO_WAYPOINTS = 6,
|
2007-04-05 07:49:04 +00:00
|
|
|
};
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
/* Landscape types */
|
|
|
|
enum {
|
2007-03-22 03:42:43 +00:00
|
|
|
LT_TEMPERATE = 0,
|
|
|
|
LT_ARCTIC = 1,
|
|
|
|
LT_TROPIC = 2,
|
|
|
|
LT_TOYLAND = 3,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
NUM_LANDSCAPE = 4,
|
|
|
|
};
|
|
|
|
|
2007-05-04 16:27:13 +00:00
|
|
|
/**
|
|
|
|
* Town Layouts
|
|
|
|
*/
|
|
|
|
enum TownLayout {
|
|
|
|
TL_NO_ROADS = 0, ///< Build no more roads, but still build houses
|
|
|
|
TL_ORIGINAL, ///< Original algorithm (min. 1 distance between roads)
|
|
|
|
TL_BETTER_ROADS, ///< Extended original algorithm (min. 2 distance between roads)
|
|
|
|
TL_2X2_GRID, ///< Geometric 2x2 grid algorithm
|
|
|
|
TL_3X3_GRID, ///< Geometric 3x3 grid algorithm
|
|
|
|
|
|
|
|
NUM_TLS, ///< Number of town layouts
|
|
|
|
};
|
|
|
|
|
2007-05-05 23:21:49 +00:00
|
|
|
/* It needs to be 8bits, because we save and load it as such */
|
|
|
|
/** Define basic enum properties */
|
|
|
|
template <> struct EnumPropsT<TownLayout> : MakeEnumPropsT<TownLayout, byte, TL_NO_ROADS, NUM_TLS, NUM_TLS> {};
|
|
|
|
typedef TinyEnumT<TownLayout> TownLayoutByte; //typedefing-enumification of TownLayout
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
enum {
|
|
|
|
NUM_PRICES = 49,
|
|
|
|
};
|
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
struct Prices {
|
2007-06-18 21:44:47 +00:00
|
|
|
Money station_value;
|
|
|
|
Money build_rail;
|
|
|
|
Money build_road;
|
|
|
|
Money build_signals;
|
|
|
|
Money build_bridge;
|
|
|
|
Money build_train_depot;
|
|
|
|
Money build_road_depot;
|
|
|
|
Money build_ship_depot;
|
|
|
|
Money build_tunnel;
|
|
|
|
Money train_station_track;
|
|
|
|
Money train_station_length;
|
|
|
|
Money build_airport;
|
|
|
|
Money build_bus_station;
|
|
|
|
Money build_truck_station;
|
|
|
|
Money build_dock;
|
|
|
|
Money build_railvehicle;
|
|
|
|
Money build_railwagon;
|
|
|
|
Money aircraft_base;
|
|
|
|
Money roadveh_base;
|
|
|
|
Money ship_base;
|
|
|
|
Money build_trees;
|
|
|
|
Money terraform;
|
2007-11-27 16:02:13 +00:00
|
|
|
Money clear_grass;
|
|
|
|
Money clear_roughland;
|
|
|
|
Money clear_rocks;
|
|
|
|
Money clear_fields;
|
2007-06-18 21:44:47 +00:00
|
|
|
Money remove_trees;
|
|
|
|
Money remove_rail;
|
|
|
|
Money remove_signals;
|
|
|
|
Money clear_bridge;
|
|
|
|
Money remove_train_depot;
|
|
|
|
Money remove_road_depot;
|
|
|
|
Money remove_ship_depot;
|
|
|
|
Money clear_tunnel;
|
|
|
|
Money clear_water;
|
|
|
|
Money remove_rail_station;
|
|
|
|
Money remove_airport;
|
|
|
|
Money remove_bus_station;
|
|
|
|
Money remove_truck_station;
|
|
|
|
Money remove_dock;
|
|
|
|
Money remove_house;
|
|
|
|
Money remove_road;
|
|
|
|
Money running_rail[3];
|
|
|
|
Money aircraft_running;
|
|
|
|
Money roadveh_running;
|
|
|
|
Money ship_running;
|
|
|
|
Money build_industry;
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
#define GAME_DIFFICULTY_NUM 18
|
|
|
|
|
2007-10-16 21:15:34 +00:00
|
|
|
/** Specific type for Game Difficulty to ease changing the type */
|
|
|
|
typedef uint16 GDType;
|
2007-03-07 12:11:48 +00:00
|
|
|
struct GameDifficulty {
|
2007-10-16 21:15:34 +00:00
|
|
|
GDType max_no_competitors;
|
|
|
|
GDType competitor_start_time;
|
|
|
|
GDType number_towns;
|
|
|
|
GDType number_industries;
|
|
|
|
GDType max_loan;
|
|
|
|
GDType initial_interest;
|
|
|
|
GDType vehicle_costs;
|
|
|
|
GDType competitor_speed;
|
|
|
|
GDType competitor_intelligence; // no longer in use
|
|
|
|
GDType vehicle_breakdowns;
|
|
|
|
GDType subsidy_multiplier;
|
|
|
|
GDType construction_cost;
|
|
|
|
GDType terrain_type;
|
|
|
|
GDType quantity_sea_lakes;
|
|
|
|
GDType economy;
|
|
|
|
GDType line_reverse_mode;
|
|
|
|
GDType disasters;
|
|
|
|
GDType town_council_tolerance; // minimum required town ratings to be allowed to demolish stuff
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2004-11-21 10:49:40 +00:00
|
|
|
enum {
|
|
|
|
// Temperate
|
2006-08-22 14:38:37 +00:00
|
|
|
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,
|
2004-11-21 10:49:40 +00:00
|
|
|
|
|
|
|
// Arctic
|
2006-08-22 14:38:37 +00:00
|
|
|
CT_WHEAT = 6,
|
|
|
|
CT_HILLY_UNUSED = 8,
|
|
|
|
CT_PAPER = 9,
|
|
|
|
CT_GOLD = 10,
|
2007-04-17 19:08:00 +00:00
|
|
|
CT_FOOD = 11,
|
2004-11-21 10:49:40 +00:00
|
|
|
|
|
|
|
// Tropic
|
2006-08-22 14:38:37 +00:00
|
|
|
CT_RUBBER = 1,
|
|
|
|
CT_FRUIT = 4,
|
|
|
|
CT_MAIZE = 6,
|
|
|
|
CT_COPPER_ORE = 8,
|
|
|
|
CT_WATER = 9,
|
|
|
|
CT_DIAMONDS = 10,
|
2004-11-21 10:49:40 +00:00
|
|
|
|
|
|
|
// Toyland
|
2006-08-22 14:38:37 +00:00
|
|
|
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,
|
2004-11-21 10:49:40 +00:00
|
|
|
CT_FIZZY_DRINKS = 11,
|
|
|
|
|
2007-04-15 16:20:35 +00:00
|
|
|
NUM_CARGO = 32,
|
2005-01-14 00:14:13 +00:00
|
|
|
|
2006-09-05 12:46:14 +00:00
|
|
|
CT_NO_REFIT = 0xFE,
|
2006-08-22 14:38:37 +00:00
|
|
|
CT_INVALID = 0xFF
|
2004-11-21 10:49:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef uint AcceptedCargo[NUM_CARGO];
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
struct TileDesc {
|
2004-08-09 17:04:08 +00:00
|
|
|
StringID str;
|
2006-10-14 22:22:48 +00:00
|
|
|
Owner owner;
|
2006-08-17 20:22:35 +00:00
|
|
|
Date build_date;
|
2007-06-21 17:25:17 +00:00
|
|
|
uint64 dparam[2];
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
struct ViewportSign {
|
2005-01-03 08:50:44 +00:00
|
|
|
int32 left;
|
|
|
|
int32 top;
|
2004-08-09 17:04:08 +00:00
|
|
|
byte width_1, width_2;
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-06-18 19:53:50 +00:00
|
|
|
/**
|
|
|
|
* Common return value for all commands. Wraps the cost and
|
|
|
|
* a possible error message/state together.
|
|
|
|
*/
|
|
|
|
class CommandCost {
|
2007-06-18 21:44:47 +00:00
|
|
|
Money cost; ///< The cost of this action
|
2007-06-18 19:53:50 +00:00
|
|
|
StringID message; ///< Warning message for when success is unset
|
|
|
|
bool success; ///< Whether the comment went fine up to this moment
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Creates a command cost return with no cost and no error
|
|
|
|
*/
|
|
|
|
CommandCost() : cost(0), message(INVALID_STRING_ID), success(true) {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a command return value the is failed with the given message
|
|
|
|
*/
|
|
|
|
CommandCost(StringID msg) : cost(0), message(msg), success(false) {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a command return value with the given start cost
|
|
|
|
* @param cst the initial cost of this command
|
|
|
|
*/
|
2007-06-18 21:44:47 +00:00
|
|
|
CommandCost(Money cst) : cost(cst), message(INVALID_STRING_ID), success(true) {}
|
2007-06-18 19:53:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds the cost of the given command return value to this cost.
|
|
|
|
* Also takes a possible error message when it is set.
|
|
|
|
* @param ret the command to add the cost of.
|
|
|
|
* @return this class.
|
|
|
|
*/
|
|
|
|
CommandCost AddCost(CommandCost ret);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds the given cost to the cost of the command.
|
|
|
|
* @param cost the cost to add
|
|
|
|
* @return this class.
|
|
|
|
*/
|
2007-06-18 21:44:47 +00:00
|
|
|
CommandCost AddCost(Money cost);
|
2007-06-18 19:53:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Multiplies the cost of the command by the given factor.
|
|
|
|
* @param cost factor to multiply the costs with
|
|
|
|
* @return this class
|
|
|
|
*/
|
|
|
|
CommandCost MultiplyCost(int factor);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The costs as made up to this moment
|
|
|
|
* @return the costs
|
|
|
|
*/
|
2007-06-18 21:44:47 +00:00
|
|
|
Money GetCost() const;
|
2007-06-18 19:53:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the global error message *if* this class has one.
|
|
|
|
*/
|
|
|
|
void SetGlobalErrorMessage() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Did this command succeed?
|
|
|
|
* @return true if and only if it succeeded
|
|
|
|
*/
|
|
|
|
bool Succeeded() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Did this command fail?
|
|
|
|
* @return true if and only if it failed
|
|
|
|
*/
|
|
|
|
bool Failed() const;
|
|
|
|
};
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
typedef void DrawTileProc(TileInfo *ti);
|
2006-08-06 16:32:49 +00:00
|
|
|
typedef uint GetSlopeZProc(TileIndex tile, uint x, uint y);
|
2007-06-18 19:53:50 +00:00
|
|
|
typedef CommandCost ClearTileProc(TileIndex tile, byte flags);
|
2005-06-24 12:38:35 +00:00
|
|
|
typedef void GetAcceptedCargoProc(TileIndex tile, AcceptedCargo res);
|
|
|
|
typedef void GetTileDescProc(TileIndex tile, TileDesc *td);
|
2007-05-24 22:41:50 +00:00
|
|
|
/**
|
|
|
|
* GetTileTrackStatusProcs return a value that contains the possible tracks
|
2004-09-05 16:15:22 +00:00
|
|
|
* 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
|
2004-09-10 19:02:27 +00:00
|
|
|
* doing (byte)ts I think, although I am not really sure
|
2004-09-05 16:15:22 +00:00
|
|
|
*
|
|
|
|
* 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
|
2004-09-10 19:02:27 +00:00
|
|
|
* above.
|
2007-05-24 22:41:50 +00:00
|
|
|
* @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
|
2004-09-05 16:15:22 +00:00
|
|
|
*/
|
2007-05-24 22:41:50 +00:00
|
|
|
typedef uint32 GetTileTrackStatusProc(TileIndex tile, TransportType mode, uint sub_mode);
|
2006-03-26 22:23:32 +00:00
|
|
|
typedef void GetProducedCargoProc(TileIndex tile, CargoID *b);
|
2005-06-24 12:38:35 +00:00
|
|
|
typedef void ClickTileProc(TileIndex tile);
|
|
|
|
typedef void AnimateTileProc(TileIndex tile);
|
|
|
|
typedef void TileLoopProc(TileIndex tile);
|
2005-09-18 20:56:44 +00:00
|
|
|
typedef void ChangeTileOwnerProc(TileIndex tile, PlayerID old_player, PlayerID new_player);
|
2007-02-13 10:26:53 +00:00
|
|
|
/** @see VehicleEnterTileStatus to see what the return values mean */
|
2005-06-24 12:38:35 +00:00
|
|
|
typedef uint32 VehicleEnterTileProc(Vehicle *v, TileIndex tile, int x, int y);
|
2007-07-26 16:51:10 +00:00
|
|
|
typedef Foundation GetFoundationProc(TileIndex tile, Slope tileh);
|
2007-08-30 17:17:04 +00:00
|
|
|
/**
|
|
|
|
* 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);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
struct TileTypeProcs {
|
2004-08-09 17:04:08 +00:00
|
|
|
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;
|
2007-07-26 16:51:10 +00:00
|
|
|
GetFoundationProc *get_foundation_proc;
|
2007-08-30 17:17:04 +00:00
|
|
|
TerraformTileProc *terraform_tile_proc;
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2007-05-02 09:29:41 +00:00
|
|
|
enum ExpensesType {
|
2006-08-22 14:38:37 +00:00
|
|
|
EXPENSES_CONSTRUCTION = 0,
|
|
|
|
EXPENSES_NEW_VEHICLES = 1,
|
|
|
|
EXPENSES_TRAIN_RUN = 2,
|
|
|
|
EXPENSES_ROADVEH_RUN = 3,
|
|
|
|
EXPENSES_AIRCRAFT_RUN = 4,
|
|
|
|
EXPENSES_SHIP_RUN = 5,
|
|
|
|
EXPENSES_PROPERTY = 6,
|
|
|
|
EXPENSES_TRAIN_INC = 7,
|
|
|
|
EXPENSES_ROADVEH_INC = 8,
|
|
|
|
EXPENSES_AIRCRAFT_INC = 9,
|
|
|
|
EXPENSES_SHIP_INC = 10,
|
|
|
|
EXPENSES_LOAN_INT = 11,
|
|
|
|
EXPENSES_OTHER = 12,
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
2006-11-16 22:05:33 +00:00
|
|
|
enum {
|
|
|
|
MAX_LANG = 64,
|
|
|
|
};
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
// special string constants
|
|
|
|
enum SpecialStrings {
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
// special strings for town names. the town name is generated dynamically on request.
|
2006-08-22 14:38:37 +00:00
|
|
|
SPECSTR_TOWNNAME_START = 0x20C0,
|
|
|
|
SPECSTR_TOWNNAME_ENGLISH = SPECSTR_TOWNNAME_START,
|
2004-08-09 17:04:08 +00:00
|
|
|
SPECSTR_TOWNNAME_FRENCH,
|
|
|
|
SPECSTR_TOWNNAME_GERMAN,
|
|
|
|
SPECSTR_TOWNNAME_AMERICAN,
|
|
|
|
SPECSTR_TOWNNAME_LATIN,
|
|
|
|
SPECSTR_TOWNNAME_SILLY,
|
|
|
|
SPECSTR_TOWNNAME_SWEDISH,
|
|
|
|
SPECSTR_TOWNNAME_DUTCH,
|
|
|
|
SPECSTR_TOWNNAME_FINNISH,
|
|
|
|
SPECSTR_TOWNNAME_POLISH,
|
|
|
|
SPECSTR_TOWNNAME_SLOVAKISH,
|
2005-01-09 00:17:01 +00:00
|
|
|
SPECSTR_TOWNNAME_NORWEGIAN,
|
2004-08-09 17:04:08 +00:00
|
|
|
SPECSTR_TOWNNAME_HUNGARIAN,
|
2004-09-16 10:41:56 +00:00
|
|
|
SPECSTR_TOWNNAME_AUSTRIAN,
|
|
|
|
SPECSTR_TOWNNAME_ROMANIAN,
|
|
|
|
SPECSTR_TOWNNAME_CZECH,
|
2005-01-15 21:41:49 +00:00
|
|
|
SPECSTR_TOWNNAME_SWISS,
|
2005-09-16 10:37:21 +00:00
|
|
|
SPECSTR_TOWNNAME_DANISH,
|
2006-05-01 09:25:23 +00:00
|
|
|
SPECSTR_TOWNNAME_TURKISH,
|
2006-07-16 00:32:00 +00:00
|
|
|
SPECSTR_TOWNNAME_ITALIAN,
|
2006-08-20 09:52:15 +00:00
|
|
|
SPECSTR_TOWNNAME_CATALAN,
|
2006-08-22 14:38:37 +00:00
|
|
|
SPECSTR_TOWNNAME_LAST = SPECSTR_TOWNNAME_CATALAN,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
// special strings for player names on the form "TownName transport".
|
2006-08-22 14:38:37 +00:00
|
|
|
SPECSTR_PLAYERNAME_START = 0x70EA,
|
2004-08-09 17:04:08 +00:00
|
|
|
SPECSTR_PLAYERNAME_ENGLISH = SPECSTR_PLAYERNAME_START,
|
|
|
|
SPECSTR_PLAYERNAME_FRENCH,
|
|
|
|
SPECSTR_PLAYERNAME_GERMAN,
|
|
|
|
SPECSTR_PLAYERNAME_AMERICAN,
|
|
|
|
SPECSTR_PLAYERNAME_LATIN,
|
|
|
|
SPECSTR_PLAYERNAME_SILLY,
|
2006-08-22 14:38:37 +00:00
|
|
|
SPECSTR_PLAYERNAME_LAST = SPECSTR_PLAYERNAME_SILLY,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 14:38:37 +00:00
|
|
|
SPECSTR_ANDCO_NAME = 0x70E6,
|
|
|
|
SPECSTR_PRESIDENT_NAME = 0x70E7,
|
|
|
|
SPECSTR_SONGNAME = 0x70E8,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-11-16 22:05:33 +00:00
|
|
|
// reserve MAX_LANG strings for the *.lng files
|
2006-08-22 14:38:37 +00:00
|
|
|
SPECSTR_LANGUAGE_START = 0x7100,
|
2006-11-16 22:05:33 +00:00
|
|
|
SPECSTR_LANGUAGE_END = SPECSTR_LANGUAGE_START + MAX_LANG - 1,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
// reserve 32 strings for various screen resolutions
|
2006-11-16 22:05:33 +00:00
|
|
|
SPECSTR_RESOLUTION_START = SPECSTR_LANGUAGE_END + 1,
|
|
|
|
SPECSTR_RESOLUTION_END = SPECSTR_RESOLUTION_START + 0x1F,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
// reserve 32 strings for screenshot formats
|
2006-11-16 22:05:33 +00:00
|
|
|
SPECSTR_SCREENSHOT_START = SPECSTR_RESOLUTION_END + 1,
|
|
|
|
SPECSTR_SCREENSHOT_END = SPECSTR_SCREENSHOT_START + 0x1F,
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-07-14 09:43:59 +00:00
|
|
|
// Used to implement SetDParamStr
|
2006-08-22 14:38:37 +00:00
|
|
|
STR_SPEC_DYNSTRING = 0xF800,
|
|
|
|
STR_SPEC_USERSTRING = 0xF808,
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
2005-06-24 12:38:35 +00:00
|
|
|
typedef void PlaceProc(TileIndex tile);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-10-17 19:57:00 +00:00
|
|
|
enum {
|
|
|
|
SORT_ASCENDING = 0,
|
|
|
|
SORT_DESCENDING = 1,
|
|
|
|
SORT_BY_DATE = 0,
|
|
|
|
SORT_BY_NAME = 2
|
|
|
|
};
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
VARDEF byte _savegame_sort_order;
|
|
|
|
|
|
|
|
enum {
|
2006-08-22 14:38:37 +00:00
|
|
|
MAX_SCREEN_WIDTH = 2048,
|
2004-08-09 17:04:08 +00:00
|
|
|
MAX_SCREEN_HEIGHT = 1200,
|
|
|
|
};
|
|
|
|
|
2005-02-22 14:52:20 +00:00
|
|
|
/* In certain windows you navigate with the arrow keys. Do not scroll the
|
|
|
|
* gameview when here. Bitencoded variable that only allows scrolling if all
|
|
|
|
* elements are zero */
|
|
|
|
enum {
|
2006-08-22 14:38:37 +00:00
|
|
|
SCROLL_CON = 0,
|
2005-02-22 14:52:20 +00:00
|
|
|
SCROLL_EDIT = 1,
|
|
|
|
SCROLL_SAVE = 2,
|
2005-05-17 23:25:18 +00:00
|
|
|
SCROLL_CHAT = 4,
|
2005-02-22 14:52:20 +00:00
|
|
|
};
|
|
|
|
VARDEF byte _no_scroll;
|
|
|
|
|
2005-09-02 16:05:59 +00:00
|
|
|
/** To have a concurrently running thread interface with the main program, use
|
|
|
|
* the OTTD_SendThreadMessage() function. Actions to perform upon the message are handled
|
|
|
|
* in the ProcessSentMessage() function */
|
2007-03-07 12:11:48 +00:00
|
|
|
enum ThreadMsg {
|
2006-08-20 13:39:33 +00:00
|
|
|
MSG_OTTD_NO_MESSAGE,
|
|
|
|
MSG_OTTD_SAVETHREAD_DONE,
|
|
|
|
MSG_OTTD_SAVETHREAD_ERROR,
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2005-09-02 16:05:59 +00:00
|
|
|
|
|
|
|
void OTTD_SendThreadMessage(ThreadMsg msg);
|
|
|
|
|
2005-07-15 21:28:26 +00:00
|
|
|
#endif /* OPENTTD_H */
|