tron@2186: /* $Id$ */ celestar@2536: /** @file openttd.h */ tron@2186: Darkvater@2075: #ifndef OPENTTD_H Darkvater@2075: #define OPENTTD_H truelight@0: truelight@0: #ifndef VARDEF truelight@0: #define VARDEF extern truelight@0: #endif truelight@0: rubidium@5838: #include "helpers.hpp" rubidium@8610: #include "strings_type.h" truelight@0: tron@2159: #include "map.h" rubidium@8604: #include "slope_type.h" truelight@0: truelight@0: // Forward declarations of structs. rubidium@6574: struct Depot; rubidium@6574: struct Waypoint; rubidium@6574: struct Station; rubidium@6574: struct ViewPort; rubidium@6574: struct Town; rubidium@6574: struct NewsItem; rubidium@6574: struct Industry; rubidium@6574: struct DrawPixelInfo; rubidium@7139: struct Group; truelight@4401: typedef byte VehicleOrderID; ///< The index of an order within its current vehicle (not pool related) truelight@4401: typedef byte LandscapeID; truelight@4401: typedef uint16 EngineID; truelight@4401: typedef uint16 UnitID; rubidium@7446: KUDr@5187: typedef EngineID *EngineList; ///< engine list type placeholder acceptable for C code (see helpers.cpp) truelight@4401: truelight@4401: /* IDs used in Pools */ Darkvater@3347: typedef uint16 StationID; rubidium@7506: static const StationID INVALID_STATION = 0xFFFF; truelight@4397: typedef uint16 RoadStopID; Darkvater@3346: typedef uint16 TownID; rubidium@4330: typedef uint16 IndustryID; truelight@4388: typedef uint16 DepotID; truelight@4389: typedef uint16 WaypointID; truelight@4392: typedef uint16 OrderID; truelight@4401: typedef uint16 SignID; rubidium@7139: typedef uint16 GroupID; truelight@4348: typedef uint16 EngineRenewID; tron@4527: typedef uint16 DestinationID; rubidium@8259: tron@4527: /* DestinationID must be at least as large as every these below, because it can tron@4527: * be any of them tron@4527: */ tron@4527: assert_compile(sizeof(DestinationID) == sizeof(DepotID)); tron@4527: assert_compile(sizeof(DestinationID) == sizeof(WaypointID)); tron@4527: assert_compile(sizeof(DestinationID) == sizeof(StationID)); truelight@0: truelight@0: rubidium@4293: enum { rubidium@4293: INVALID_YEAR = -1, rubidium@4326: INVALID_DATE = -1, rubidium@4293: }; rubidium@4293: rubidium@4326: typedef int32 Year; rubidium@4326: typedef int32 Date; rubidium@4261: rubidium@8230: typedef uint32 PlayerFace; ///< player face bits, info see in player_face.h truelight@0: rubidium@8617: enum GameModes { rubidium@8617: GM_MENU, rubidium@8617: GM_NORMAL, rubidium@8617: GM_EDITOR rubidium@8617: }; rubidium@8617: truelight@0: enum SwitchModes { rubidium@4344: SM_NONE = 0, rubidium@4344: SM_NEWGAME = 1, rubidium@4344: SM_EDITOR = 2, rubidium@4344: SM_LOAD = 3, rubidium@4344: SM_MENU = 4, rubidium@4344: SM_SAVE = 5, rubidium@4344: SM_GENRANDLAND = 6, rubidium@4344: SM_LOAD_SCENARIO = 9, rubidium@4344: SM_START_SCENARIO = 10, truelight@4300: SM_START_HEIGHTMAP = 11, rubidium@4344: SM_LOAD_HEIGHTMAP = 12, truelight@0: }; truelight@0: truelight@2828: truelight@2828: /* Modes for GenerateWorld */ truelight@2828: enum GenerateWorldModes { truelight@4300: GW_NEWGAME = 0, /* Generate a map for a new game */ truelight@4300: GW_EMPTY = 1, /* Generate an empty map (sea-level) */ truelight@4300: GW_RANDOM = 2, /* Generate a random map for SE */ truelight@4300: GW_HEIGHTMAP = 3, /* Generate a newgame from a heightmap */ truelight@2828: }; truelight@2828: truelight@2828: /* Modes for InitializeGame, those are _bits_! */ truelight@2828: enum InitializeGameModes { truelight@2828: IG_NONE = 0, /* Don't do anything special */ truelight@2828: IG_DATE_RESET = 1, /* Reset the date when initializing a game */ truelight@2828: }; truelight@2828: rubidium@5838: enum Owner { rubidium@5838: PLAYER_INACTIVE_CLIENT = 253, rubidium@5838: PLAYER_NEW_COMPANY = 254, rubidium@5838: PLAYER_SPECTATOR = 255, rubidium@5838: OWNER_BEGIN = 0x00, rubidium@5838: PLAYER_FIRST = 0x00, rubidium@5838: MAX_PLAYERS = 8, rubidium@5838: OWNER_TOWN = 0x0F, // a town owns the tile rubidium@5838: OWNER_NONE = 0x10, // nobody owns the tile rubidium@5838: OWNER_WATER = 0x11, // "water" owns the tile rubidium@5838: OWNER_END = 0x12, rubidium@5838: INVALID_OWNER = 0xFF, rubidium@5838: INVALID_PLAYER = 0xFF, rubidium@5838: /* Player identifiers All players below MAX_PLAYERS are playable rubidium@5838: * players, above, they are special, computer controlled players */ rubidium@5838: }; rubidium@5838: rubidium@5838: typedef Owner PlayerID; rubidium@5838: rubidium@5838: DECLARE_POSTFIX_INCREMENT(Owner); rubidium@5838: rubidium@5838: /** Define basic enum properties */ rubidium@5838: template <> struct EnumPropsT : MakeEnumPropsT {}; rubidium@5838: typedef TinyEnumT OwnerByte; rubidium@5838: typedef OwnerByte PlayerByte; rubidium@5838: truelight@2828: rubidium@6574: enum TransportType { truelight@159: /* These constants are for now linked to the representation of bridges tron@3333: * and tunnels, so they can be used by GetTileTrackStatus_TunnelBridge. tron@3333: * In an ideal world, these constants would be used everywhere when tron@3333: * accessing tunnels and bridges. For now, you should just not change tron@3333: * the values for road and rail. truelight@159: */ rubidium@5838: TRANSPORT_BEGIN = 0, tron@3017: TRANSPORT_RAIL = 0, truelight@159: TRANSPORT_ROAD = 1, rubidium@4434: TRANSPORT_WATER, // = 2 matthijs@1967: TRANSPORT_END, matthijs@1967: INVALID_TRANSPORT = 0xff, rubidium@6574: }; truelight@159: rubidium@5838: /** Define basic enum properties */ rubidium@5838: template <> struct EnumPropsT : MakeEnumPropsT {}; rubidium@5838: typedef TinyEnumT TransportTypeByte; rubidium@5838: rubidium@5838: rubidium@6574: struct TileInfo { truelight@0: uint x; truelight@0: uint y; tron@3636: Slope tileh; tron@1977: TileIndex tile; truelight@0: uint z; rubidium@6574: }; truelight@0: truelight@0: truelight@0: /* Display Options */ truelight@0: enum { peter1138@7087: DO_SHOW_TOWN_NAMES = 0, peter1138@7087: DO_SHOW_STATION_NAMES = 1, peter1138@7087: DO_SHOW_SIGNS = 2, peter1138@7087: DO_FULL_ANIMATION = 3, peter1138@7087: DO_FULL_DETAIL = 5, peter1138@7087: DO_WAYPOINTS = 6, peter1138@6923: }; peter1138@6923: truelight@0: /* Landscape types */ truelight@0: enum { belugas@6683: LT_TEMPERATE = 0, belugas@6683: LT_ARCTIC = 1, belugas@6683: LT_TROPIC = 2, belugas@6683: LT_TOYLAND = 3, truelight@0: truelight@0: NUM_LANDSCAPE = 4, truelight@0: }; truelight@0: belugas@7067: /** belugas@7067: * Town Layouts belugas@7067: */ belugas@7067: enum TownLayout { belugas@7067: TL_NO_ROADS = 0, ///< Build no more roads, but still build houses belugas@7067: TL_ORIGINAL, ///< Original algorithm (min. 1 distance between roads) belugas@7067: TL_BETTER_ROADS, ///< Extended original algorithm (min. 2 distance between roads) belugas@7067: TL_2X2_GRID, ///< Geometric 2x2 grid algorithm belugas@7067: TL_3X3_GRID, ///< Geometric 3x3 grid algorithm belugas@7067: belugas@7067: NUM_TLS, ///< Number of town layouts belugas@7067: }; belugas@7067: glx@7073: /* It needs to be 8bits, because we save and load it as such */ glx@7073: /** Define basic enum properties */ glx@7073: template <> struct EnumPropsT : MakeEnumPropsT {}; glx@7073: typedef TinyEnumT TownLayoutByte; //typedefing-enumification of TownLayout glx@7073: truelight@0: #define GAME_DIFFICULTY_NUM 18 truelight@0: rubidium@8238: /** Specific type for Game Difficulty to ease changing the type */ rubidium@8238: typedef uint16 GDType; rubidium@6574: struct GameDifficulty { rubidium@8238: GDType max_no_competitors; rubidium@8238: GDType competitor_start_time; rubidium@8238: GDType number_towns; rubidium@8238: GDType number_industries; rubidium@8238: GDType max_loan; rubidium@8238: GDType initial_interest; rubidium@8238: GDType vehicle_costs; rubidium@8238: GDType competitor_speed; rubidium@8238: GDType competitor_intelligence; // no longer in use rubidium@8238: GDType vehicle_breakdowns; rubidium@8238: GDType subsidy_multiplier; rubidium@8238: GDType construction_cost; rubidium@8238: GDType terrain_type; rubidium@8238: GDType quantity_sea_lakes; rubidium@8238: GDType economy; rubidium@8238: GDType line_reverse_mode; rubidium@8238: GDType disasters; rubidium@8238: GDType town_council_tolerance; // minimum required town ratings to be allowed to demolish stuff rubidium@6574: }; truelight@0: rubidium@6574: struct TileDesc { truelight@0: StringID str; Darkvater@4849: Owner owner; rubidium@4297: Date build_date; rubidium@7498: uint64 dparam[2]; rubidium@6574: }; truelight@0: rubidium@6574: struct ViewportSign { tron@849: int32 left; tron@849: int32 top; truelight@0: byte width_1, width_2; rubidium@6574: }; truelight@0: tron@1977: typedef void PlaceProc(TileIndex tile); truelight@0: tron@2526: enum { tron@2526: SORT_ASCENDING = 0, tron@2526: SORT_DESCENDING = 1, tron@2526: SORT_BY_DATE = 0, tron@2526: SORT_BY_NAME = 2 tron@2526: }; tron@2526: truelight@0: VARDEF byte _savegame_sort_order; truelight@0: truelight@0: enum { rubidium@4344: MAX_SCREEN_WIDTH = 2048, truelight@0: MAX_SCREEN_HEIGHT = 1200, truelight@0: }; truelight@0: Darkvater@1397: /* In certain windows you navigate with the arrow keys. Do not scroll the Darkvater@1397: * gameview when here. Bitencoded variable that only allows scrolling if all Darkvater@1397: * elements are zero */ Darkvater@1397: enum { rubidium@4344: SCROLL_CON = 0, Darkvater@1397: SCROLL_EDIT = 1, Darkvater@1397: SCROLL_SAVE = 2, Darkvater@1843: SCROLL_CHAT = 4, Darkvater@1397: }; Darkvater@1397: VARDEF byte _no_scroll; Darkvater@1397: Darkvater@2380: /** To have a concurrently running thread interface with the main program, use Darkvater@2380: * the OTTD_SendThreadMessage() function. Actions to perform upon the message are handled Darkvater@2380: * in the ProcessSentMessage() function */ rubidium@6574: enum ThreadMsg { truelight@4323: MSG_OTTD_NO_MESSAGE, truelight@4323: MSG_OTTD_SAVETHREAD_DONE, truelight@4323: MSG_OTTD_SAVETHREAD_ERROR, rubidium@6574: }; Darkvater@2380: Darkvater@2380: void OTTD_SendThreadMessage(ThreadMsg msg); Darkvater@2380: rubidium@8617: extern byte _game_mode; rubidium@8617: extern bool _exit_game; rubidium@8617: extern byte _pause_game; rubidium@8617: Darkvater@2075: #endif /* OPENTTD_H */