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@8138: #include "core/enum_type.hpp" rubidium@8114: #include "strings_type.h" truelight@0: truelight@0: // Forward declarations of structs. rubidium@6248: struct Depot; rubidium@6248: struct Waypoint; rubidium@6248: struct Station; rubidium@6248: struct ViewPort; rubidium@6248: struct Town; rubidium@6248: struct NewsItem; rubidium@6248: struct Industry; rubidium@6248: struct DrawPixelInfo; rubidium@6643: 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@6950: 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@7010: 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@6643: typedef uint16 GroupID; truelight@4348: typedef uint16 EngineRenewID; tron@4527: typedef uint16 DestinationID; rubidium@7763: 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: rubidium@7734: typedef uint32 PlayerFace; ///< player face bits, info see in player_face.h truelight@0: rubidium@8121: enum GameModes { rubidium@8121: GM_MENU, rubidium@8121: GM_NORMAL, rubidium@8121: GM_EDITOR rubidium@8121: }; rubidium@8121: 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@5587: enum Owner { rubidium@5587: PLAYER_INACTIVE_CLIENT = 253, rubidium@5587: PLAYER_NEW_COMPANY = 254, rubidium@5587: PLAYER_SPECTATOR = 255, rubidium@5587: OWNER_BEGIN = 0x00, rubidium@5587: PLAYER_FIRST = 0x00, rubidium@5587: MAX_PLAYERS = 8, rubidium@5587: OWNER_TOWN = 0x0F, // a town owns the tile rubidium@5587: OWNER_NONE = 0x10, // nobody owns the tile rubidium@5587: OWNER_WATER = 0x11, // "water" owns the tile rubidium@5587: OWNER_END = 0x12, rubidium@5587: INVALID_OWNER = 0xFF, rubidium@5587: INVALID_PLAYER = 0xFF, rubidium@5587: /* Player identifiers All players below MAX_PLAYERS are playable rubidium@5587: * players, above, they are special, computer controlled players */ rubidium@5587: }; rubidium@5587: rubidium@5587: typedef Owner PlayerID; rubidium@5587: rubidium@5587: DECLARE_POSTFIX_INCREMENT(Owner); rubidium@5587: rubidium@5587: /** Define basic enum properties */ rubidium@5587: template <> struct EnumPropsT : MakeEnumPropsT {}; rubidium@5587: typedef TinyEnumT OwnerByte; rubidium@5587: typedef OwnerByte PlayerByte; rubidium@5587: truelight@2828: rubidium@6248: 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@5587: 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@6248: }; truelight@159: rubidium@5587: /** Define basic enum properties */ rubidium@5587: template <> struct EnumPropsT : MakeEnumPropsT {}; rubidium@5587: typedef TinyEnumT TransportTypeByte; rubidium@5587: rubidium@5587: truelight@0: /* Display Options */ truelight@0: enum { peter1138@6591: DO_SHOW_TOWN_NAMES = 0, peter1138@6591: DO_SHOW_STATION_NAMES = 1, peter1138@6591: DO_SHOW_SIGNS = 2, peter1138@6591: DO_FULL_ANIMATION = 3, peter1138@6591: DO_FULL_DETAIL = 5, peter1138@6591: DO_WAYPOINTS = 6, peter1138@6427: }; peter1138@6427: truelight@0: /* Landscape types */ truelight@0: enum { belugas@6357: LT_TEMPERATE = 0, belugas@6357: LT_ARCTIC = 1, belugas@6357: LT_TROPIC = 2, belugas@6357: LT_TOYLAND = 3, truelight@0: truelight@0: NUM_LANDSCAPE = 4, truelight@0: }; truelight@0: belugas@6571: /** belugas@6571: * Town Layouts belugas@6571: */ belugas@6571: enum TownLayout { belugas@6571: TL_NO_ROADS = 0, ///< Build no more roads, but still build houses belugas@6571: TL_ORIGINAL, ///< Original algorithm (min. 1 distance between roads) belugas@6571: TL_BETTER_ROADS, ///< Extended original algorithm (min. 2 distance between roads) belugas@6571: TL_2X2_GRID, ///< Geometric 2x2 grid algorithm belugas@6571: TL_3X3_GRID, ///< Geometric 3x3 grid algorithm belugas@6571: belugas@6571: NUM_TLS, ///< Number of town layouts belugas@6571: }; belugas@6571: glx@6577: /* It needs to be 8bits, because we save and load it as such */ glx@6577: /** Define basic enum properties */ glx@6577: template <> struct EnumPropsT : MakeEnumPropsT {}; glx@6577: typedef TinyEnumT TownLayoutByte; //typedefing-enumification of TownLayout glx@6577: truelight@0: #define GAME_DIFFICULTY_NUM 18 truelight@0: rubidium@7742: /** Specific type for Game Difficulty to ease changing the type */ rubidium@7742: typedef uint16 GDType; rubidium@6248: struct GameDifficulty { rubidium@7742: GDType max_no_competitors; rubidium@7742: GDType competitor_start_time; rubidium@7742: GDType number_towns; rubidium@7742: GDType number_industries; rubidium@7742: GDType max_loan; rubidium@7742: GDType initial_interest; rubidium@7742: GDType vehicle_costs; rubidium@7742: GDType competitor_speed; rubidium@7742: GDType competitor_intelligence; // no longer in use rubidium@7742: GDType vehicle_breakdowns; rubidium@7742: GDType subsidy_multiplier; rubidium@7742: GDType construction_cost; rubidium@7742: GDType terrain_type; rubidium@7742: GDType quantity_sea_lakes; rubidium@7742: GDType economy; rubidium@7742: GDType line_reverse_mode; rubidium@7742: GDType disasters; rubidium@7742: GDType town_council_tolerance; // minimum required town ratings to be allowed to demolish stuff rubidium@6248: }; truelight@0: rubidium@6248: struct ViewportSign { tron@849: int32 left; tron@849: int32 top; truelight@0: byte width_1, width_2; rubidium@6248: }; 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@6248: enum ThreadMsg { truelight@4323: MSG_OTTD_NO_MESSAGE, truelight@4323: MSG_OTTD_SAVETHREAD_DONE, truelight@4323: MSG_OTTD_SAVETHREAD_ERROR, rubidium@6248: }; Darkvater@2380: Darkvater@2380: void OTTD_SendThreadMessage(ThreadMsg msg); Darkvater@2380: rubidium@8121: extern byte _game_mode; rubidium@8121: extern bool _exit_game; rubidium@8121: extern byte _pause_game; rubidium@8121: Darkvater@2075: #endif /* OPENTTD_H */