diff --git a/src/ai/ai.h b/src/ai/ai.h index 424bfc2efa..c1d0726c38 100644 --- a/src/ai/ai.h +++ b/src/ai/ai.h @@ -7,7 +7,7 @@ #include "../command.h" /* How DoCommands look like for an AI */ -typedef struct AICommand { +struct AICommand { uint32 tile; uint32 p1; uint32 p2; @@ -17,22 +17,22 @@ typedef struct AICommand { char *text; uint uid; - struct AICommand *next; -} AICommand; + AICommand *next; +}; /* The struct for an AIScript Player */ -typedef struct AIPlayer { +struct AIPlayer { bool active; ///< Is this AI active? AICommand *queue; ///< The commands that he has in his queue AICommand *queue_tail; ///< The tail of this queue -} AIPlayer; +}; /* The struct to keep some data about the AI in general */ -typedef struct AIStruct { +struct AIStruct { /* General */ bool enabled; ///< Is AI enabled? uint tick; ///< The current tick (something like _frame_counter, only for AIs) -} AIStruct; +}; VARDEF AIStruct _ai; VARDEF AIPlayer _ai_player[MAX_PLAYERS]; diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp index d311ba71f4..8784b6f366 100644 --- a/src/ai/default/default.cpp +++ b/src/ai/default/default.cpp @@ -446,12 +446,12 @@ static void AiStateDoReplaceVehicle(Player *p) _veh_do_replace_proc[v->type - VEH_Train](p); } -typedef struct FoundRoute { +struct FoundRoute { int distance; CargoID cargo; void *from; void *to; -} FoundRoute; +}; static Town *AiFindRandomTown() { @@ -1824,12 +1824,12 @@ static TileIndex AiGetEdgeOfDefaultRailBlock(byte rule, TileIndex tile, byte cmd return tile + ToTileIndexDiff(p->tileoffs) - TileOffsByDiagDir(*dir = p->attr); } -typedef struct AiRailPathFindData { +struct AiRailPathFindData { TileIndex tile; TileIndex tile2; int count; bool flag; -} AiRailPathFindData; +}; static bool AiEnumFollowTrack(TileIndex tile, AiRailPathFindData *a, int track, uint length, byte *state) { @@ -1858,7 +1858,7 @@ static bool AiDoFollowTrack(const Player* p) return arpfd.count > 8; } -typedef struct AiRailFinder { +struct AiRailFinder { TileIndex final_tile; byte final_dir; byte depth; @@ -1873,7 +1873,7 @@ typedef struct AiRailFinder { TileIndex cur_best_tile, best_tile; TileIndex bridge_end_tile; Player *player; -} AiRailFinder; +}; static const byte _ai_table_15[4][8] = { {0, 0, 4, 3, 3, 1, 128 + 0, 64}, @@ -2713,7 +2713,7 @@ static void AiStateBuildDefaultRoadBlocks(Player *p) p->ai.state_mode = 255; } -typedef struct { +struct AiRoadFinder { TileIndex final_tile; byte final_dir; byte depth; @@ -2728,14 +2728,14 @@ typedef struct { TileIndex cur_best_tile, best_tile; TileIndex bridge_end_tile; Player *player; -} AiRoadFinder; +}; -typedef struct AiRoadEnum { +struct AiRoadEnum { TileIndex dest; TileIndex best_tile; int best_track; uint best_dist; -} AiRoadEnum; +}; static const byte _dir_by_track[] = { 0, 1, 0, 1, 2, 1, diff --git a/src/ai/trolly/pathfinder.cpp b/src/ai/trolly/pathfinder.cpp index 297d12a008..0091939b11 100644 --- a/src/ai/trolly/pathfinder.cpp +++ b/src/ai/trolly/pathfinder.cpp @@ -372,9 +372,9 @@ static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *curr extern uint GetRailFoundation(Slope tileh, TrackBits bits); // XXX function declaration in .c extern uint GetRoadFoundation(Slope tileh, RoadBits bits); // XXX function declaration in .c extern uint GetBridgeFoundation(Slope tileh, Axis); // XXX function declaration in .c -typedef enum BridgeFoundations{ +enum BridgeFoundation { BRIDGE_NO_FOUNDATION = 1 << 0 | 1 << 3 | 1 << 6 | 1 << 9 | 1 << 12, -} BridgeFoundation; +}; // The most important function: it calculates the g-value static int32 AyStar_AiPathFinder_CalculateG(AyStar *aystar, AyStarNode *current, OpenListNode *parent) diff --git a/src/aircraft.h b/src/aircraft.h index 545464e52a..3acb7babf8 100644 --- a/src/aircraft.h +++ b/src/aircraft.h @@ -8,12 +8,12 @@ #include "station_map.h" #include "vehicle.h" -typedef enum AircraftSubTypes { +enum AircraftSubType { AIR_HELICOPTER = 0, AIR_AIRCRAFT = 2, AIR_SHADOW = 4, AIR_ROTOR = 6 -} AircraftSubType; +}; /** Check if the aircraft type is a normal flying device; eg diff --git a/src/airport.h b/src/airport.h index 71c93ce4cc..27af62e62d 100644 --- a/src/airport.h +++ b/src/airport.h @@ -112,17 +112,17 @@ static const uint64 NOTHING_block = 1 << 30; -typedef struct AirportMovingData { +struct AirportMovingData { int16 x; int16 y; uint16 flag; DirectionByte direction; -} AirportMovingData; +}; struct AirportFTAbuildup; // Finite sTate mAchine --> FTA -typedef struct AirportFTAClass { +struct AirportFTAClass { public: enum Flags { AIRPLANES = 0x1, @@ -167,19 +167,19 @@ typedef struct AirportFTAClass { byte size_y; byte delta_z; // Z adjustment for helicopter pads byte catchment; -} AirportFTAClass; +}; DECLARE_ENUM_AS_BIT_SET(AirportFTAClass::Flags) // internal structure used in openttd - Finite sTate mAchine --> FTA -typedef struct AirportFTA { - struct AirportFTA *next; // possible extra movement choices from this position +struct AirportFTA { + AirportFTA *next; // possible extra movement choices from this position uint64 block; // 64 bit blocks (st->airport_flags), should be enough for the most complex airports byte position; // the position that an airplane is at byte next_position; // next position from this position byte heading; // heading (current orders), guiding an airplane to its target on an airport -} AirportFTA; +}; void InitializeAirports(); void UnInitializeAirports(); diff --git a/src/airport_movement.h b/src/airport_movement.h index f8bed45f5f..53d6174d55 100644 --- a/src/airport_movement.h +++ b/src/airport_movement.h @@ -8,12 +8,12 @@ // state machine input struct (from external file, etc.) // Finite sTate mAchine --> FTA -typedef struct AirportFTAbuildup { +struct AirportFTAbuildup { byte position; // the position that an airplane is at byte heading; // the current orders (eg. TAKEOFF, HANGAR, ENDLANDING, etc.) uint64 block; // the block this position is on on the airport (st->airport_flags) byte next; // next position from this position -} AirportFTAbuildup; +}; /////////////////////////////////////////////////////////////////////// /////*********Movement Positions on Airports********************/////// diff --git a/src/aystar.h b/src/aystar.h index ebbd53add4..f25ac76041 100644 --- a/src/aystar.h +++ b/src/aystar.h @@ -27,7 +27,6 @@ enum{ AYSTAR_INVALID_NODE = -1, }; -typedef struct AyStarNode AyStarNode; struct AyStarNode { TileIndex tile; int direction; @@ -35,7 +34,6 @@ struct AyStarNode { }; // The resulting path has nodes looking like this. -typedef struct PathNode PathNode; struct PathNode { AyStarNode node; // The parent of this item @@ -45,13 +43,12 @@ struct PathNode { // For internal use only // We do not save the h-value, because it is only needed to calculate the f-value. // h-value should _always_ be the distance left to the end-tile. -typedef struct OpenListNode OpenListNode; struct OpenListNode { int g; PathNode path; }; -typedef struct AyStar AyStar; +struct AyStar; /* * This function is called to check if the end-tile is found * return values can be: diff --git a/src/bmp.h b/src/bmp.h index e67b611e6a..d508078bc1 100644 --- a/src/bmp.h +++ b/src/bmp.h @@ -5,7 +5,7 @@ #ifndef BMP_H #define BMP_H -typedef struct { +struct BmpInfo { uint32 offset; ///< offset of bitmap data from .bmp file begining uint32 width; ///< bitmap width uint32 height; ///< bitmap height @@ -13,22 +13,22 @@ typedef struct { uint16 bpp; ///< bits per pixel uint32 compression; ///< compression method (0 = none, 1 = 8-bit RLE, 2 = 4-bit RLE) uint32 palette_size; ///< number of colors in palette -} BmpInfo; +}; -typedef struct { +struct BmpData { Colour *palette; byte *bitmap; -} BmpData; +}; #define BMP_BUFFER_SIZE 1024 -typedef struct { +struct BmpBuffer { byte data[BMP_BUFFER_SIZE]; int pos; int read; FILE *file; uint real_pos; -} BmpBuffer; +}; void BmpInitializeBuffer(BmpBuffer *buffer, FILE *file); bool BmpReadHeader(BmpBuffer *buffer, BmpInfo *info, BmpData *data); diff --git a/src/bridge.h b/src/bridge.h index 6690988a50..27e47af3bd 100644 --- a/src/bridge.h +++ b/src/bridge.h @@ -11,7 +11,7 @@ enum { /** Struct containing information about a single bridge type */ -typedef struct Bridge { +struct Bridge { Year avail_year; ///< the year in which the bridge becomes available byte min_length; ///< the minimum length of the bridge (not counting start and end tile) byte max_length; ///< the maximum length of the bridge (not counting start and end tile) @@ -22,7 +22,7 @@ typedef struct Bridge { StringID material; ///< the string that contains the bridge description PalSpriteID **sprite_table; ///< table of sprites for drawing the bridge byte flags; ///< bit 0 set: disable drawing of far pillars. -} Bridge; +}; extern const Bridge orig_bridge[MAX_BRIDGES]; extern Bridge _bridge[MAX_BRIDGES]; diff --git a/src/cargotype.h b/src/cargotype.h index e006bc9930..03ccf421e3 100644 --- a/src/cargotype.h +++ b/src/cargotype.h @@ -9,7 +9,7 @@ typedef uint32 CargoLabel; -typedef struct CargoSpec { +struct CargoSpec { uint8 bitnum; CargoLabel label; uint32 grfid; @@ -35,7 +35,7 @@ typedef struct CargoSpec { uint16 classes; bool IsValid() const; -} CargoSpec; +}; extern uint32 _cargo_mask; diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp index 8765f55ef4..4dab240247 100644 --- a/src/clear_cmd.cpp +++ b/src/clear_cmd.cpp @@ -22,12 +22,12 @@ #include "genworld.h" #include "industry.h" -typedef struct TerraformerHeightMod { +struct TerraformerHeightMod { TileIndex tile; byte height; -} TerraformerHeightMod; +}; -typedef struct TerraformerState { +struct TerraformerState { int height[4]; uint32 flags; @@ -40,7 +40,7 @@ typedef struct TerraformerState { TileIndex *tile_table; TerraformerHeightMod *modheight; -} TerraformerState; +}; static int TerraformAllowTileProcess(TerraformerState *ts, TileIndex tile) { diff --git a/src/clear_map.h b/src/clear_map.h index b44d7ec99d..de97c22d6e 100644 --- a/src/clear_map.h +++ b/src/clear_map.h @@ -12,14 +12,14 @@ /* ground type, m5 bits 2...4 * valid densities (bits 0...1) in comments after the enum */ -typedef enum ClearGround { +enum ClearGround { CLEAR_GRASS = 0, ///< 0-3 CLEAR_ROUGH = 1, ///< 3 CLEAR_ROCKS = 2, ///< 3 CLEAR_FIELDS = 3, ///< 3 CLEAR_SNOW = 4, ///< 0-3 CLEAR_DESERT = 5 ///< 1,3 -} ClearGround; +}; static inline ClearGround GetClearGround(TileIndex t) diff --git a/src/command.h b/src/command.h index 91ee393793..ace80dc89b 100644 --- a/src/command.h +++ b/src/command.h @@ -176,10 +176,10 @@ enum { typedef int32 CommandProc(TileIndex tile, uint32 flags, uint32 p1, uint32 p2); -typedef struct Command { +struct Command { CommandProc *proc; byte flags; -} Command; +}; //#define return_cmd_error(errcode) do { _error_message=(errcode); return CMD_ERROR; } while(0) #define return_cmd_error(errcode) do { return CMD_ERROR | (errcode); } while (0) diff --git a/src/console.h b/src/console.h index 5734a148b7..3a58716f0f 100644 --- a/src/console.h +++ b/src/console.h @@ -10,7 +10,7 @@ /* maximum length of a totally expanded command */ #define ICON_MAX_STREAMSIZE 1024 -typedef enum IConsoleVarTypes { +enum IConsoleVarTypes { ICONSOLE_VAR_BOOLEAN, ICONSOLE_VAR_BYTE, ICONSOLE_VAR_UINT16, @@ -18,19 +18,19 @@ typedef enum IConsoleVarTypes { ICONSOLE_VAR_INT16, ICONSOLE_VAR_INT32, ICONSOLE_VAR_STRING -} IConsoleVarTypes; +}; -typedef enum IConsoleModes { +enum IConsoleModes { ICONSOLE_FULL, ICONSOLE_OPENED, ICONSOLE_CLOSED -} IConsoleModes; +}; -typedef enum IConsoleHookTypes { +enum IConsoleHookTypes { ICONSOLE_HOOK_ACCESS, ICONSOLE_HOOK_PRE_ACTION, ICONSOLE_HOOK_POST_ACTION -} IConsoleHookTypes; +}; /** --Hooks-- * Hooks are certain triggers get get accessed/executed on either @@ -38,11 +38,11 @@ typedef enum IConsoleHookTypes { * for general flow of permissions or special action needed in some cases */ typedef bool IConsoleHook(); -typedef struct IConsoleHooks{ +struct IConsoleHooks{ IConsoleHook *access; ///< trigger when accessing the variable/command IConsoleHook *pre; ///< trigger before the variable/command is changed/executed IConsoleHook *post; ///< trigger after the variable/command is changed/executed -} IConsoleHooks; +}; /** --Commands-- * Commands are commands, or functions. They get executed once and any @@ -53,14 +53,13 @@ typedef struct IConsoleHooks{ */ typedef bool (IConsoleCmdProc)(byte argc, char *argv[]); -struct IConsoleCmd; -typedef struct IConsoleCmd { +struct IConsoleCmd { char *name; ///< name of command - struct IConsoleCmd *next; ///< next command in list + IConsoleCmd *next; ///< next command in list IConsoleCmdProc *proc; ///< process executed when command is typed IConsoleHooks hook; ///< any special trigger action that needs executing -} IConsoleCmd; +}; /** --Variables-- * Variables are pointers to real ingame variables which allow for @@ -71,10 +70,9 @@ typedef struct IConsoleCmd { * - '++' to increase value by one * - '--' to decrease value by one */ -struct IConsoleVar; -typedef struct IConsoleVar { +struct IConsoleVar { char *name; ///< name of the variable - struct IConsoleVar *next; ///< next variable in list + IConsoleVar *next; ///< next variable in list void *addr; ///< the address where the variable is pointing at uint32 size; ///< size of the variable, used for strings @@ -82,7 +80,7 @@ typedef struct IConsoleVar { IConsoleVarTypes type; ///< type of variable (for correct assignment/output) IConsoleCmdProc *proc; ///< some variables need really special handling, use a callback function for that IConsoleHooks hook; ///< any special trigger action that needs executing -} IConsoleVar; +}; /** --Aliases-- * Aliases are like shortcuts for complex functions, variable assignments, @@ -95,13 +93,12 @@ typedef struct IConsoleVar { * - "%!" also lists all parameters but presenting them to the aliased command as one argument * - ";" allows for combining commands (see example 'ng') */ -struct IConsoleAlias; -typedef struct IConsoleAlias { +struct IConsoleAlias { char *name; ///< name of the alias - struct IConsoleAlias *next; ///< next alias in list + IConsoleAlias *next; ///< next alias in list char *cmdline; ///< command(s) that is/are being aliased -} IConsoleAlias; +}; /* console parser */ VARDEF IConsoleCmd *_iconsole_cmds; ///< list of registred commands diff --git a/src/currency.h b/src/currency.h index 3bb0b9e2f9..a72eab7d02 100644 --- a/src/currency.h +++ b/src/currency.h @@ -12,7 +12,7 @@ enum { CUSTOM_CURRENCY_ID = NUM_CURRENCY - 1 }; -typedef struct { +struct CurrencySpec { uint16 rate; char separator; Year to_euro; @@ -29,7 +29,7 @@ typedef struct { */ byte symbol_pos; StringID name; -} CurrencySpec; +}; extern CurrencySpec _currency_specs[NUM_CURRENCY]; diff --git a/src/date.h b/src/date.h index c954d47d54..3e279f7e60 100644 --- a/src/date.h +++ b/src/date.h @@ -44,11 +44,11 @@ typedef uint8 Month; typedef uint8 Day; typedef uint16 DateFract; -typedef struct YearMonthDay { +struct YearMonthDay { Year year; Month month; Day day; -} YearMonthDay; +}; extern Year _cur_year; extern Month _cur_month; diff --git a/src/debug.cpp b/src/debug.cpp index 968e7d31c3..9f25f8faf7 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -33,10 +33,10 @@ int _debug_sl_level; int _debug_station_level; -typedef struct DebugLevel { +struct DebugLevel { const char *name; int *level; -} DebugLevel; +}; #define DEBUG_LEVEL(x) { #x, &_debug_##x##_level } static const DebugLevel debug_level[] = { diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index fb06839951..d6705c455a 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -290,10 +290,10 @@ static void DrawDepotWindow(Window *w) } } -typedef struct GetDepotVehiclePtData { +struct GetDepotVehiclePtData { Vehicle *head; Vehicle *wagon; -} GetDepotVehiclePtData; +}; enum { MODE_ERROR = 1, diff --git a/src/direction.h b/src/direction.h index 5feda580c6..d0dd988eb7 100644 --- a/src/direction.h +++ b/src/direction.h @@ -8,7 +8,7 @@ #include "helpers.hpp" /* Direction as commonly used in v->direction, 8 way. */ -typedef enum Direction { +enum Direction { DIR_BEGIN = 0, DIR_N = 0, DIR_NE = 1, ///< Northeast, upper right on your monitor @@ -20,7 +20,7 @@ typedef enum Direction { DIR_NW = 7, DIR_END, INVALID_DIR = 0xFF, -} Direction; +}; /** Define basic enum properties */ template <> struct EnumPropsT : MakeEnumPropsT {}; @@ -32,14 +32,14 @@ static inline Direction ReverseDir(Direction d) } -typedef enum DirDiff { +enum DirDiff { DIRDIFF_SAME = 0, DIRDIFF_45RIGHT = 1, DIRDIFF_90RIGHT = 2, DIRDIFF_REVERSE = 4, DIRDIFF_90LEFT = 6, DIRDIFF_45LEFT = 7 -} DirDiff; +}; static inline DirDiff DirDifference(Direction d0, Direction d1) { @@ -59,7 +59,7 @@ static inline Direction ChangeDir(Direction d, DirDiff delta) /* Direction commonly used as the direction of entering and leaving tiles, 4-way */ -typedef enum DiagDirection { +enum DiagDirection { DIAGDIR_BEGIN = 0, DIAGDIR_NE = 0, ///< Northeast, upper right on your monitor DIAGDIR_SE = 1, @@ -67,7 +67,7 @@ typedef enum DiagDirection { DIAGDIR_NW = 3, DIAGDIR_END, INVALID_DIAGDIR = 0xFF, -} DiagDirection; +}; DECLARE_POSTFIX_INCREMENT(DiagDirection); @@ -81,12 +81,12 @@ static inline DiagDirection ReverseDiagDir(DiagDirection d) } -typedef enum DiagDirDiff { +enum DiagDirDiff { DIAGDIRDIFF_SAME = 0, DIAGDIRDIFF_90RIGHT = 1, DIAGDIRDIFF_REVERSE = 2, DIAGDIRDIFF_90LEFT = 3 -} DiagDirDiff; +}; static inline DiagDirection ChangeDiagDir(DiagDirection d, DiagDirDiff delta) { @@ -107,11 +107,11 @@ static inline Direction DiagDirToDir(DiagDirection dir) /* the 2 axis */ -typedef enum Axis { +enum Axis { AXIS_X = 0, AXIS_Y = 1, AXIS_END -} Axis; +}; static inline Axis OtherAxis(Axis a) diff --git a/src/driver.cpp b/src/driver.cpp index bc02df7452..c134fe903f 100644 --- a/src/driver.cpp +++ b/src/driver.cpp @@ -30,17 +30,17 @@ #include "video/cocoa_v.h" #include "video/win32_v.h" -typedef struct DriverDesc { +struct DriverDesc { const char* name; const char* longname; const HalCommonDriver* drv; -} DriverDesc; +}; -typedef struct DriverClass { +struct DriverClass { const DriverDesc *descs; const char *name; const HalCommonDriver** drv; -} DriverClass; +}; #define M(x, y, z) { x, y, (const HalCommonDriver *)(void *)z } diff --git a/src/economy.cpp b/src/economy.cpp index 173da95476..0d5a27aade 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -901,12 +901,12 @@ void DeleteSubsidyWithStation(StationID index) InvalidateWindow(WC_SUBSIDIES_LIST, 0); } -typedef struct FoundRoute { +struct FoundRoute { uint distance; CargoID cargo; void *from; void *to; -} FoundRoute; +}; static void FindSubsidyPassengerRoute(FoundRoute *fr) { diff --git a/src/economy.h b/src/economy.h index ae5cf0cd72..4519e182f5 100644 --- a/src/economy.h +++ b/src/economy.h @@ -8,24 +8,24 @@ void ResetPriceBaseMultipliers(); void SetPriceBaseMultiplier(uint price, byte factor); -typedef struct { +struct Economy { int32 max_loan; ///< Maximum possible loan int32 max_loan_unround; ///< Economy fluctuation status int fluct; byte interest_rate; ///< Interest byte infl_amount; ///< inflation amount byte infl_amount_pr; ///< "floating" portion of inflation -} Economy; +}; VARDEF Economy _economy; -typedef struct Subsidy { +struct Subsidy { CargoID cargo_type; byte age; /* from and to can either be TownID, StationID or IndustryID */ uint16 from; uint16 to; -} Subsidy; +}; enum ScoreID { @@ -48,11 +48,11 @@ enum ScoreID { DECLARE_POSTFIX_INCREMENT(ScoreID); -typedef struct ScoreInfo { +struct ScoreInfo { byte id; ///< Unique ID of the score int needed; ///< How much you need to get the perfect score int score; ///< How much score it will give -} ScoreInfo; +}; extern const ScoreInfo _score_info[]; extern int _score_part[MAX_PLAYERS][SCORE_END]; diff --git a/src/engine.h b/src/engine.h index 2983e38702..cd6b0948e2 100644 --- a/src/engine.h +++ b/src/engine.h @@ -16,7 +16,7 @@ enum RailVehicleTypes { RAILVEH_WAGON, ///< simple wagon, not motorized }; -typedef struct RailVehicleInfo { +struct RailVehicleInfo { byte image_index; RailVehicleTypes railveh_type; byte base_cost; @@ -39,9 +39,9 @@ typedef struct RailVehicleInfo { byte shorten_factor; ///< length on main map for this type is 8 - shorten_factor byte tractive_effort; ///< Tractive effort coefficient byte user_def_data; ///< Property 0x25: "User-defined bit mask" Used only for (very few) NewGRF vehicles -} RailVehicleInfo; +}; -typedef struct ShipVehicleInfo { +struct ShipVehicleInfo { byte image_index; byte base_cost; uint16 max_speed; @@ -50,7 +50,7 @@ typedef struct ShipVehicleInfo { byte running_cost; SoundFxByte sfx; bool refittable; -} ShipVehicleInfo; +}; /* AircraftVehicleInfo subtypes, bitmask type. * If bit 0 is 0 then it is a helicopter, otherwise it is a plane @@ -61,7 +61,7 @@ enum { AIR_FAST = 2 }; -typedef struct AircraftVehicleInfo { +struct AircraftVehicleInfo { byte image_index; byte base_cost; byte running_cost; @@ -71,9 +71,9 @@ typedef struct AircraftVehicleInfo { uint16 max_speed; byte mail_capacity; uint16 passenger_capacity; -} AircraftVehicleInfo; +}; -typedef struct RoadVehicleInfo { +struct RoadVehicleInfo { byte image_index; byte base_cost; byte running_cost; @@ -81,12 +81,12 @@ typedef struct RoadVehicleInfo { byte max_speed; byte capacity; CargoID cargo_type; -} RoadVehicleInfo; +}; /** Information about a vehicle * @see table/engines.h */ -typedef struct EngineInfo { +struct EngineInfo { Date base_intro; Year lifelength; Year base_life; @@ -97,9 +97,9 @@ typedef struct EngineInfo { byte refit_cost; byte misc_flags; byte callbackmask; -} EngineInfo; +}; -typedef struct Engine { +struct Engine { Date intro_date; Date age; uint16 reliability; @@ -112,7 +112,7 @@ typedef struct Engine { byte preview_wait; byte player_avail; byte type; ///< type, ie VEH_Road, VEH_Train, etc. Same as in vehicle.h -} Engine; +}; /** * EngineInfo.misc_flags is a bitmask, with the following values @@ -261,11 +261,9 @@ struct EngineRenew { EngineRenewID index; EngineID from; EngineID to; - struct EngineRenew *next; + EngineRenew *next; }; -typedef struct EngineRenew EngineRenew; - /** * Memory pool for engine renew elements. DO NOT USE outside of engine.c. Is * placed here so the only exception to this rule, the saveload code, can use diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp index c635158269..6426f724ee 100644 --- a/src/engine_gui.cpp +++ b/src/engine_gui.cpp @@ -48,10 +48,10 @@ static const Widget _engine_preview_widgets[] = { typedef void DrawEngineProc(int x, int y, EngineID engine, SpriteID pal); typedef void DrawEngineInfoProc(EngineID, int x, int y, int maxw); -typedef struct DrawEngineInfo { +struct DrawEngineInfo { DrawEngineProc *engine_proc; DrawEngineInfoProc *info_proc; -} DrawEngineInfo; +}; static void DrawTrainEngineInfo(EngineID engine, int x, int y, int maxw); static void DrawRoadVehEngineInfo(EngineID engine, int x, int y, int maxw); diff --git a/src/fileio.cpp b/src/fileio.cpp index e317987cd8..897785d1b0 100644 --- a/src/fileio.cpp +++ b/src/fileio.cpp @@ -18,7 +18,7 @@ #define FIO_BUFFER_SIZE 512 #define MAX_HANDLES 64 -typedef struct { +struct Fio { byte *buffer, *buffer_end; ///< position pointer in local buffer and last valid byte of buffer uint32 pos; ///< current (system) position in file FILE *cur_fh; ///< current file handle @@ -29,7 +29,7 @@ typedef struct { const char *filename[MAX_HANDLES]; ///< array of filenames we (should) have open uint usage_count[MAX_HANDLES]; ///< count how many times this file has been opened #endif /* LIMITED_FDS */ -} Fio; +}; static Fio _fio; diff --git a/src/fios.h b/src/fios.h index 9060724d89..bb119cc881 100644 --- a/src/fios.h +++ b/src/fios.h @@ -6,12 +6,12 @@ #define FIOS_H /* Deals with finding savegames */ -typedef struct { +struct FiosItem { byte type; uint64 mtime; char title[64]; char name[256 - 12 - 64]; -} FiosItem; +}; enum { FIOS_TYPE_DRIVE = 0, @@ -56,15 +56,15 @@ int CDECL compare_FiosItems(const void *a, const void *b); /* Implementation of opendir/readdir/closedir for Windows */ #if defined(WIN32) #include -typedef struct DIR DIR; +struct DIR; -typedef struct dirent { // XXX - only d_name implemented +struct dirent { // XXX - only d_name implemented wchar_t *d_name; // name of found file /* little hack which will point to parent DIR struct which will * save us a call to GetFileAttributes if we want information * about the file (for example in function fio_bla) */ DIR *dir; -} dirent; +}; struct DIR { HANDLE hFind; diff --git a/src/fontcache.cpp b/src/fontcache.cpp index 46aa5a5739..f976de4d47 100644 --- a/src/fontcache.cpp +++ b/src/fontcache.cpp @@ -315,10 +315,10 @@ static FT_Face GetFontFace(FontSize size) } -typedef struct GlyphEntry { +struct GlyphEntry { Sprite *sprite; byte width; -} GlyphEntry; +}; /* The glyph cache. This is structured to reduce memory consumption. diff --git a/src/fontcache.h b/src/fontcache.h index 4fa4004173..f2240e6d2f 100644 --- a/src/fontcache.h +++ b/src/fontcache.h @@ -14,14 +14,14 @@ void InitializeUnicodeGlyphMap(); #ifdef WITH_FREETYPE -typedef struct FreeTypeSettings { +struct FreeTypeSettings { char small_font[260]; char medium_font[260]; char large_font[260]; uint small_size; uint medium_size; uint large_size; -} FreeTypeSettings; +}; extern FreeTypeSettings _freetype; diff --git a/src/genworld.h b/src/genworld.h index 1e7f8404e0..4c78e612f0 100644 --- a/src/genworld.h +++ b/src/genworld.h @@ -29,7 +29,7 @@ enum { typedef void gw_done_proc(); typedef void gw_abort_proc(); -typedef struct gw_info { +struct gw_info { bool active; ///< Is generating world active bool abort; ///< Whether to abort the thread ASAP bool wait_for_draw; ///< Are we waiting on a draw event @@ -42,14 +42,14 @@ typedef struct gw_info { gw_done_proc *proc; ///< Proc that is called when done (can be NULL) gw_abort_proc *abortp; ///< Proc that is called when aborting (can be NULL) OTTDThread *thread; ///< The thread we are in (can be NULL) -} gw_info; +}; #ifdef TEMPORARY_OTTDTHREAD_DEFINITION #undef OTTDThread #undef TEMPORARY_OTTDTHREAD_DEFINITION #endif -typedef enum gwp_classes { +enum gwp_class { GWP_MAP_INIT, ///< Initialize/allocate the map, start economy GWP_LANDSCAPE, ///< Create the landscape GWP_ROUGH_ROCKY, ///< Make rough and rocky areas @@ -61,7 +61,7 @@ typedef enum gwp_classes { GWP_RUNTILELOOP, ///< Runs the tile loop 1280 times to make snow etc GWP_GAME_START, ///< Really prepare to start the game GWP_CLASS_COUNT -} gwp_class; +}; /** * Check if we are currently in the process of generating a world. diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index 703ce72d98..76a5a593a2 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -29,12 +29,12 @@ /** * In what 'mode' the GenerateLandscapeWindowProc is. */ -typedef enum glwp_modes { +enum glwp_modes { GLWP_GENERATE, GLWP_HEIGHTMAP, GLWP_SCENARIO, GLWP_END -} glwp_modes; +}; static uint _heightmap_x = 0; static uint _heightmap_y = 0; @@ -740,13 +740,13 @@ static const Widget _show_terrain_progress_widgets[] = { { WIDGETS_END}, }; -typedef struct tp_info { +struct tp_info { uint percent; StringID cls; uint current; uint total; int timer; -} tp_info; +}; static tp_info _tp; diff --git a/src/gfx.cpp b/src/gfx.cpp index 9340134be7..3f0a72a55a 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -44,11 +44,11 @@ int _pal_last_dirty; Colour _cur_palette[256]; byte _stringwidth_table[FS_END][224]; -typedef enum BlitterModes { +enum BlitterMode { BM_NORMAL, BM_COLOUR_REMAP, BM_TRANSPARENT, -} BlitterMode; +}; static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode); @@ -718,7 +718,7 @@ void DrawSprite(SpriteID img, SpriteID pal, int x, int y) } } -typedef struct BlitterParams { +struct BlitterParams { int start_x, start_y; const byte *sprite; Pixel *dst; @@ -726,7 +726,7 @@ typedef struct BlitterParams { int width, height; int width_org; int pitch; -} BlitterParams; +}; static void GfxBlitTileZoomIn(BlitterParams *bp) { diff --git a/src/gfx.h b/src/gfx.h index a970830b67..3a3269d417 100644 --- a/src/gfx.h +++ b/src/gfx.h @@ -93,13 +93,13 @@ void CreateConsole(); typedef int32 CursorID; typedef byte Pixel; -typedef struct Point { +struct Point { int x,y; -} Point; +}; -typedef struct Rect { +struct Rect { int left,top,right,bottom; -} Rect; +}; /** A single sprite of a list of animated cursors */ struct AnimCursor { @@ -108,7 +108,7 @@ struct AnimCursor { byte display_time; ///< Amount of ticks this sprite will be shown }; -typedef struct CursorVars { +struct CursorVars { Point pos, size, offs, delta; ///< position, size, offset from top-left, and movement Point draw_pos, draw_size; ///< position and size bounding-box for drawing SpriteID sprite; ///< current image of cursor @@ -123,20 +123,20 @@ typedef struct CursorVars { bool dirty; ///< the rect occupied by the mouse is dirty (redraw) bool fix_at; ///< mouse is moving, but cursor is not (used for scrolling) bool in_window; ///< mouse inside this window, determines drawing logic -} CursorVars; +}; -typedef struct DrawPixelInfo { +struct DrawPixelInfo { Pixel *dst_ptr; int left, top, width, height; int pitch; uint16 zoom; -} DrawPixelInfo; +}; -typedef struct Colour { +struct Colour { byte r; byte g; byte b; -} Colour; +}; @@ -181,12 +181,12 @@ void UndrawMouseCursor(); #include "helpers.hpp" -typedef enum FontSizes { +enum FontSize { FS_NORMAL, FS_SMALL, FS_LARGE, FS_END, -} FontSize; +}; DECLARE_POSTFIX_INCREMENT(FontSize); @@ -292,9 +292,9 @@ VARDEF byte _colour_gradient[16][8]; VARDEF bool _use_dos_palette; -typedef enum StringColorFlags { +enum StringColorFlags { IS_PALETTE_COLOR = 0x100, ///< color value is already a real palette color index, not an index of a StringColor -} StringColorFlags; +}; #ifdef _DEBUG diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp index 27c7e18af6..28dd902e7c 100644 --- a/src/gfxinit.cpp +++ b/src/gfxinit.cpp @@ -18,15 +18,15 @@ #include "fontcache.h" #include -typedef struct MD5File { +struct MD5File { const char * filename; ///< filename md5_byte_t hash[16]; ///< md5 sum of the file -} MD5File; +}; -typedef struct FileList { +struct FileList { MD5File basic[4]; ///< grf files that always have to be loaded MD5File landscape[3]; ///< landscape specific grf files -} FileList; +}; enum { SKIP = 0xFFFE, diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index 585be36881..ef3b62df8f 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -43,7 +43,7 @@ enum { static const int64 INVALID_DATAPOINT = INT64_MAX; // Value used for a datapoint that shouldn't be drawn. static const uint INVALID_DATAPOINT_POS = UINT_MAX; // Used to determine if the previous point was drawn. -typedef struct GraphDrawer { +struct GraphDrawer { uint excluded_data; ///< bitmask of the datasets that shouldn't be displayed. byte num_dataset; byte num_on_x_axis; @@ -65,7 +65,7 @@ typedef struct GraphDrawer { StringID format_str_y_axis; byte colors[GRAPH_MAX_DATASETS]; int64 cost[GRAPH_MAX_DATASETS][24]; ///< last 2 years -} GraphDrawer; +}; static void DrawGraph(const GraphDrawer *gw) { diff --git a/src/hal.h b/src/hal.h index dc8ba321e2..ed6564e7d0 100644 --- a/src/hal.h +++ b/src/hal.h @@ -5,26 +5,26 @@ #ifndef HAL_H #define HAL_H -typedef struct { +struct HalCommonDriver { const char *(*start)(const char * const *parm); void (*stop)(); -} HalCommonDriver; +}; -typedef struct { +struct HalVideoDriver { const char *(*start)(const char * const *parm); void (*stop)(); void (*make_dirty)(int left, int top, int width, int height); void (*main_loop)(); bool (*change_resolution)(int w, int h); void (*toggle_fullscreen)(bool fullscreen); -} HalVideoDriver; +}; -typedef struct { +struct HalSoundDriver { const char *(*start)(const char * const *parm); void (*stop)(); -} HalSoundDriver; +}; -typedef struct { +struct HalMusicDriver { const char *(*start)(const char * const *parm); void (*stop)(); @@ -32,7 +32,7 @@ typedef struct { void (*stop_song)(); bool (*is_song_playing)(); void (*set_volume)(byte vol); -} HalMusicDriver; +}; extern HalMusicDriver *_music_driver; extern HalSoundDriver *_sound_driver; diff --git a/src/industry.h b/src/industry.h index e634c27de9..131b6d4f22 100644 --- a/src/industry.h +++ b/src/industry.h @@ -14,11 +14,11 @@ enum { INVALID_INDUSTRY = 0xFFFF, }; -typedef enum IndustryLifeTypes { +enum IndustryLifeType { INDUSTRYLIFE_NOT_CLOSABLE, ///< Industry can never close INDUSTRYLIFE_PRODUCTION, ///< Industry can close and change of production INDUSTRYLIFE_CLOSABLE, ///< Industry can only close (no production change) -} IndustryLifeType; +}; /** * Defines the internal data of a functionnal industry @@ -49,15 +49,15 @@ struct Industry { IndustryID index; ///< index of the industry in the pool of industries }; -typedef struct IndustryTileTable { +struct IndustryTileTable { TileIndexDiffC ti; IndustryGfx gfx; -} IndustryTileTable; +}; /** * Defines the data structure for constructing industry. */ -typedef struct IndustrySpec { +struct IndustrySpec { const IndustryTileTable *const *table;///< List of the tiles composing the industry byte num_table; ///< Number of elements in the table byte cost_multiplier; ///< Base cost multiplier*/ @@ -74,15 +74,15 @@ typedef struct IndustrySpec { StringID closure_text; ///< Message appearing when the industry closes StringID production_up_text; ///< Message appearing when the industry's production is increasing StringID production_down_text; ///< Message appearing when the industry's production is decreasing -} IndustrySpec; +}; /** * Defines the data structure of each indivudual tile of an industry. */ -typedef struct IndustryTileSpec { +struct IndustryTileSpec { CargoID accepts_cargo[3]; ///< Cargo accepted by this tile Slope slopes_refused; ///< slope pattern on which this tile cannot be built -} IndustryTileSpec; +}; const IndustrySpec *GetIndustrySpec(IndustryType thistype); ///< Array of industries default data const IndustryTileSpec *GetIndustryTileSpec(IndustryGfx gfx); ///< Array of industry tiles default data diff --git a/src/industry_map.h b/src/industry_map.h index 4427b58fb5..9896ae3a01 100644 --- a/src/industry_map.h +++ b/src/industry_map.h @@ -166,10 +166,10 @@ static inline void ResetIndustryConstructionStage(TileIndex tile) _m[tile].m1 = 0; } -typedef struct IndustryTypeSolver { +struct IndustryTypeSolver { IndustryGfx MinGfx; IndustryGfx MaxGfx; -} IndustryTypeSolver; +}; static const IndustryTypeSolver industry_gfx_Solver [IT_END] = { { 0, 6}, ///< IT_COAL_MINE diff --git a/src/livery.h b/src/livery.h index 18fa0b11cb..f9f99fc9f7 100644 --- a/src/livery.h +++ b/src/livery.h @@ -8,7 +8,7 @@ #include "helpers.hpp" /* List of different livery schemes. */ -typedef enum LiverySchemes { +enum LiveryScheme { LS_BEGIN = 0, LS_DEFAULT = 0, @@ -39,25 +39,25 @@ typedef enum LiverySchemes { LS_LARGE_PLANE, LS_END -} LiveryScheme; +}; DECLARE_POSTFIX_INCREMENT(LiveryScheme); /* List of different livery classes, used only by the livery GUI. */ -typedef enum LiveryClasses { +enum LiveryClass { LC_OTHER, LC_RAIL, LC_ROAD, LC_SHIP, LC_AIRCRAFT, LC_END -} LiveryClass; +}; -typedef struct Livery { +struct Livery { bool in_use; ///< Set if this livery should be used instead of the default livery. byte colour1; ///< First colour, for all vehicles. byte colour2; ///< Second colour, for vehicles with 2CC support. -} Livery; +}; #endif /* LIVERY_H */ diff --git a/src/map.h b/src/map.h index f096f1458f..67e141c53e 100644 --- a/src/map.h +++ b/src/map.h @@ -18,7 +18,7 @@ extern uint _map_size; #define TILE_MASK(x) ((x) & _map_tile_mask) #define TILE_ASSERT(x) assert(TILE_MASK(x) == (x)); -typedef struct Tile { +struct Tile { byte type_height; byte m1; uint16 m2; @@ -26,7 +26,7 @@ typedef struct Tile { byte m4; byte m5; byte m6; -} Tile; +}; extern Tile* _m; @@ -92,10 +92,10 @@ static inline uint TileY(TileIndex tile) } -typedef struct TileIndexDiffC { +struct TileIndexDiffC { int16 x; int16 y; -} TileIndexDiffC; +}; static inline TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc) { diff --git a/src/md5.h b/src/md5.h index 42cddc392a..0e48fb4c22 100644 --- a/src/md5.h +++ b/src/md5.h @@ -68,11 +68,11 @@ typedef unsigned char md5_byte_t; /* 8-bit byte */ typedef unsigned int md5_word_t; /* 32-bit word */ /* Define the state of the MD5 Algorithm. */ -typedef struct md5_state_s { +struct md5_state_t { md5_word_t count[2]; /* message length in bits, lsw first */ md5_word_t abcd[4]; /* digest buffer */ md5_byte_t buf[64]; /* accumulate block */ -} md5_state_t; +}; /* Initialize the algorithm. */ void md5_init(md5_state_t *pms); diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index d7355e1bdf..c2c0ff1208 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -1191,12 +1191,12 @@ enum QueryWidgets { }; -typedef struct query_d { +struct query_d { void (*proc)(Window*, bool); ///< callback function executed on closing of popup. Window* points to parent, bool is true if 'yes' clicked, false otherwise StringID message; ///< message shown for query window uint32 params[20]; ///< local copy of _decode_parameters bool calledback; ///< has callback been executed already (internal usage for WE_DESTROY event) -} query_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(query_d)); @@ -1766,7 +1766,7 @@ template <> struct EnumPropsT : MakeEnumPropsT ce_flags; -typedef struct CheatEntry { +struct CheatEntry { VarType type; ///< type of selector ce_flags flags; ///< selector flags StringID str; ///< string with descriptive text @@ -1774,7 +1774,7 @@ typedef struct CheatEntry { bool *been_used; ///< has this cheat been used before? CheckButtonClick *proc;///< procedure int16 min, max; ///< range for spinbox setting -} CheatEntry; +}; static const CheatEntry _cheats_ui[] = { {SLE_BOOL, {CE_CLICK}, STR_CHEAT_MONEY, &_cheats.money.value, &_cheats.money.been_used, &ClickMoneyCheat, 0, 0}, diff --git a/src/mixer.h b/src/mixer.h index 2cdf41938e..42e458c822 100644 --- a/src/mixer.h +++ b/src/mixer.h @@ -5,7 +5,7 @@ #ifndef MIXER_H #define MIXER_H -typedef struct MixerChannel MixerChannel; +struct MixerChannel; enum { MX_AUTOFREE = 1, diff --git a/src/music.h b/src/music.h index 9a33b43196..dbb5214aad 100644 --- a/src/music.h +++ b/src/music.h @@ -8,10 +8,10 @@ #define NUM_SONGS_PLAYLIST 33 #define NUM_SONGS_AVAILABLE 22 -typedef struct SongSpecs { +struct SongSpecs { char filename[256]; char song_name[64]; -} SongSpecs; +}; extern const SongSpecs origin_songs_specs[NUM_SONGS_AVAILABLE]; diff --git a/src/network/core/core.h b/src/network/core/core.h index c07f5ab815..54ff156f35 100644 --- a/src/network/core/core.h +++ b/src/network/core/core.h @@ -16,7 +16,7 @@ bool NetworkCoreInitialize(); void NetworkCoreShutdown(); /** Status of a network client; reasons why a client has quit */ -typedef enum { +enum NetworkRecvStatus { NETWORK_RECV_STATUS_OKAY, ///< Everything is okay NETWORK_RECV_STATUS_DESYNC, ///< A desync did occur NETWORK_RECV_STATUS_NEWGRF_MISMATCH, ///< We did not have the required NewGRFs @@ -27,7 +27,7 @@ typedef enum { NETWORK_RECV_STATUS_SERVER_FULL, ///< The server is full NETWORK_RECV_STATUS_SERVER_BANNED, ///< The server has banned us NETWORK_RECV_STATUS_CLOSE_QUERY, ///< Done quering the server -} NetworkRecvStatus; +}; /** Forward declaration due to circular dependencies */ struct Packet; diff --git a/src/network/core/game.h b/src/network/core/game.h index 4347fc6b58..049e5020e2 100644 --- a/src/network/core/game.h +++ b/src/network/core/game.h @@ -19,7 +19,7 @@ * some fields will be empty on the client (like game_password) by default * and only filled with data a player enters. */ -typedef struct NetworkGameInfo { +struct NetworkGameInfo { byte game_info_version; ///< Version of the game info char server_name[NETWORK_NAME_LENGTH]; ///< Server name char hostname[NETWORK_HOSTNAME_LENGTH]; ///< Hostname of the server (if any) @@ -43,8 +43,8 @@ typedef struct NetworkGameInfo { byte map_set; ///< Graphical set bool dedicated; ///< Is this a dedicated server? char rcon_password[NETWORK_PASSWORD_LENGTH]; ///< RCon password for the server. "" if rcon is disabled - struct GRFConfig *grfconfig; ///< List of NewGRF files used -} NetworkGameInfo; + GRFConfig *grfconfig; ///< List of NewGRF files used +}; #endif /* ENABLE_NETWORK */ diff --git a/src/network/core/tcp.h b/src/network/core/tcp.h index a667ab0990..bd6a1d01fb 100644 --- a/src/network/core/tcp.h +++ b/src/network/core/tcp.h @@ -58,8 +58,8 @@ enum { }; /** Packet that wraps a command */ -typedef struct CommandPacket { - struct CommandPacket *next; ///< the next command packet (if in queue) +struct CommandPacket { + CommandPacket *next; ///< the next command packet (if in queue) PlayerByte player; ///< player that is executing the command uint32 cmd; ///< command being executed uint32 p1; ///< parameter p1 @@ -68,10 +68,10 @@ typedef struct CommandPacket { char text[80]; ///< possible text sent for name changes etc uint32 frame; ///< the frame in which this packet is executed byte callback; ///< any callback function executed upon successful completion of the command -} CommandPacket; +}; /** Status of a client */ -typedef enum { +enum ClientStatus { STATUS_INACTIVE, ///< The client is not connected nor active STATUS_AUTHORIZING,///< The client is authorizing STATUS_AUTH, ///< The client is authorized @@ -80,7 +80,7 @@ typedef enum { STATUS_DONE_MAP, ///< The client has downloaded the map STATUS_PRE_ACTIVE, ///< The client is catching up the delayed frames STATUS_ACTIVE, ///< The client is an active player in the game -} ClientStatus; +}; /** Base socket handler for all TCP sockets */ class NetworkTCPSocketHandler : public NetworkSocketHandler { diff --git a/src/network/network.h b/src/network/network.h index 29fabedaa5..da8b52c012 100644 --- a/src/network/network.h +++ b/src/network/network.h @@ -40,7 +40,7 @@ #define NETWORK_VEHICLE_TYPES 5 #define NETWORK_STATION_TYPES 5 -typedef struct NetworkPlayerInfo { +struct NetworkPlayerInfo { char company_name[NETWORK_NAME_LENGTH]; // Company name char password[NETWORK_PASSWORD_LENGTH]; // The password for the player Year inaugurated_year; // What year the company started in @@ -53,9 +53,9 @@ typedef struct NetworkPlayerInfo { uint16 num_station[NETWORK_STATION_TYPES]; // How many stations are there of this type? char players[NETWORK_PLAYERS_LENGTH]; // The players that control this company (Name1, name2, ..) uint16 months_empty; // How many months the company is empty -} NetworkPlayerInfo; +}; -typedef struct NetworkClientInfo { +struct NetworkClientInfo { uint16 client_index; // Index of the client (same as ClientState->index) char client_name[NETWORK_CLIENT_NAME_LENGTH]; // Name of the client byte client_lang; // The language of the client @@ -63,9 +63,9 @@ typedef struct NetworkClientInfo { uint32 client_ip; // IP-address of the client (so he can be banned) Date join_date; // Gamedate the player has joined char unique_id[NETWORK_NAME_LENGTH]; // Every play sends an unique id so we can indentify him -} NetworkClientInfo; +}; -typedef enum { +enum NetworkJoinStatus { NETWORK_JOIN_STATUS_CONNECTING, NETWORK_JOIN_STATUS_AUTHORIZING, NETWORK_JOIN_STATUS_WAITING, @@ -74,15 +74,15 @@ typedef enum { NETWORK_JOIN_STATUS_REGISTERING, NETWORK_JOIN_STATUS_GETTING_COMPANY_INFO, -} NetworkJoinStatus; +}; // language ids for server_lang and client_lang -typedef enum { +enum NetworkLanguage { NETLANG_ANY = 0, NETLANG_ENGLISH = 1, NETLANG_GERMAN = 2, NETLANG_FRENCH = 3, -} NetworkLanguage; +}; VARDEF NetworkGameInfo _network_game_info; VARDEF NetworkPlayerInfo _network_player_info[MAX_PLAYERS]; diff --git a/src/network/network_data.h b/src/network/network_data.h index 3c41831fdf..02c112ae99 100644 --- a/src/network/network_data.h +++ b/src/network/network_data.h @@ -20,13 +20,13 @@ #define NETWORK_SERVER_INDEX 1 #define NETWORK_EMPTY_INDEX 0 -typedef enum { +enum MapPacket { MAP_PACKET_START, MAP_PACKET_NORMAL, MAP_PACKET_END, -} MapPacket; +}; -typedef enum { +enum NetworkErrorCode { NETWORK_ERROR_GENERAL, // Try to use thisone like never // Signals from clients @@ -46,10 +46,10 @@ typedef enum { NETWORK_ERROR_KICKED, NETWORK_ERROR_CHEATER, NETWORK_ERROR_FULL, -} NetworkErrorCode; +}; // Actions that can be used for NetworkTextMessage -typedef enum { +enum NetworkAction { NETWORK_ACTION_JOIN, NETWORK_ACTION_LEAVE, NETWORK_ACTION_SERVER_MESSAGE, @@ -58,18 +58,18 @@ typedef enum { NETWORK_ACTION_CHAT_CLIENT, NETWORK_ACTION_GIVE_MONEY, NETWORK_ACTION_NAME_CHANGE, -} NetworkAction; +}; -typedef enum { +enum NetworkPasswordType { NETWORK_GAME_PASSWORD, NETWORK_COMPANY_PASSWORD, -} NetworkPasswordType; +}; -typedef enum { +enum DestType { DESTTYPE_BROADCAST, ///< Send message/notice to all players (All) DESTTYPE_TEAM, ///< Send message/notice to everyone playing the same company (Team) DESTTYPE_CLIENT, ///< Send message/notice to only a certain player (Private) -} DestType; +}; // following externs are instantiated at network.cpp extern CommandPacket *_local_command_queue; diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index a2f8ab4863..6686a13646 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -32,20 +32,20 @@ #define BGC 5 #define BTC 15 -typedef struct network_d { +struct network_d { PlayerID company; // select company in network lobby byte field; // select text-field in start-server and game-listing NetworkGameList *server; // selected server in lobby and game-listing FiosItem *map; // selected map in start-server -} network_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(network_d)); -typedef struct network_ql_d { +struct network_ql_d { network_d n; // see above; general stuff querystr_d q; // text-input in start-server and game-listing NetworkGameList **sort_list; // list of games (sorted) list_d l; // accompanying list-administration -} network_ql_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(network_ql_d)); /* Global to remember sorting after window has been closed */ diff --git a/src/newgrf.cpp b/src/newgrf.cpp index a5c891b17c..56ed3988a2 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -73,15 +73,15 @@ static const uint _default_cargo_max = 27; static CargoLabel _default_cargo_list[_default_cargo_max]; -typedef enum GrfDataType { +enum GrfDataType { GDT_SOUND, -} GrfDataType; +}; static byte _grf_data_blocks; static GrfDataType _grf_data_type; -typedef enum grfspec_feature { +enum grfspec_feature { GSF_TRAIN, GSF_ROAD, GSF_SHIP, @@ -95,7 +95,7 @@ typedef enum grfspec_feature { GSF_INDUSTRIES, GSF_CARGOS, GSF_SOUNDFX, -} grfspec_feature; +}; typedef void (*SpecialSpriteHandler)(byte *buf, int len); diff --git a/src/newgrf.h b/src/newgrf.h index dd388a72a7..963145f658 100644 --- a/src/newgrf.h +++ b/src/newgrf.h @@ -8,31 +8,31 @@ #include "helpers.hpp" #include "cargotype.h" -typedef enum GrfLoadingStage { +enum GrfLoadingStage { GLS_FILESCAN, GLS_SAFETYSCAN, GLS_LABELSCAN, GLS_INIT, GLS_ACTIVATION, GLS_END, -} GrfLoadingStage; +}; DECLARE_POSTFIX_INCREMENT(GrfLoadingStage); -typedef struct GRFLabel { +struct GRFLabel { byte label; uint32 nfo_line; uint32 pos; struct GRFLabel *next; -} GRFLabel; +}; -typedef struct GRFFile { +struct GRFFile { char *filename; uint32 grfid; uint16 sprite_offset; byte grf_version; - struct GRFFile *next; + GRFFile *next; /* A sprite group contains all sprites of a given vehicle (or multiple * vehicles) when carrying given cargo. It consists of several sprite @@ -65,7 +65,7 @@ typedef struct GRFFile { uint8 cargo_max; CargoLabel *cargo_list; uint8 cargo_map[NUM_CARGO]; -} GRFFile; +}; extern GRFFile *_first_grffile; diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp index 3eecd50e56..12f072889d 100644 --- a/src/newgrf_config.cpp +++ b/src/newgrf_config.cpp @@ -364,7 +364,6 @@ const GRFConfig *FindGRFConfig(uint32 grfid, const uint8 *md5sum) #ifdef ENABLE_NETWORK /** Structure for UnknownGRFs; this is a lightweight variant of GRFConfig */ -typedef struct UnknownGRF UnknownGRF; struct UnknownGRF : public GRFIdentifier { UnknownGRF *next; char name[NETWORK_GRF_NAME_LENGTH]; diff --git a/src/newgrf_config.h b/src/newgrf_config.h index 647850ce1e..26246594f3 100644 --- a/src/newgrf_config.h +++ b/src/newgrf_config.h @@ -6,42 +6,42 @@ #include "openttd.h" /* GRF config bit flags */ -typedef enum { +enum GCF_Flags { GCF_SYSTEM, ///< GRF file is an openttd-internal system grf GCF_UNSAFE, ///< GRF file is unsafe for static usage GCF_STATIC, ///< GRF file is used statically (can be used in any MP game) GCF_COMPATIBLE,///< GRF file does not exactly match the requested GRF (different MD5SUM), but grfid matches) GCF_COPY, ///< The data is copied from a grf in _all_grfs -} GCF_Flags; +}; -typedef enum { +enum GRFStatus { GCS_UNKNOWN, ///< The status of this grf file is unknown GCS_DISABLED, ///< GRF file is disabled GCS_NOT_FOUND, ///< GRF file was not found in the local cache GCS_INITIALISED, ///< GRF file has been initialised GCS_ACTIVATED ///< GRF file has been activated -} GRFStatus; +}; -typedef enum { +enum GRFListCompatibility{ GLC_ALL_GOOD, GLC_COMPATIBLE, GLC_NOT_FOUND -} GRFListCompatibility; +}; -typedef struct GRFIdentifier { +struct GRFIdentifier { uint32 grfid; uint8 md5sum[16]; -} GRF; +}; -typedef struct GRFError { +struct GRFError { StringID message; StringID data; StringID severity; uint8 num_params; uint8 param_number[2]; -} GRFError; +}; -typedef struct GRFConfig : public GRFIdentifier { +struct GRFConfig : public GRFIdentifier { char *filename; char *name; char *info; @@ -53,7 +53,7 @@ typedef struct GRFConfig : public GRFIdentifier { uint8 num_params; struct GRFConfig *next; -} GRFConfig; +}; /* First item in list of all scanned NewGRFs */ extern GRFConfig *_all_grfs; diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index aaec97a467..dc4ad2766d 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -24,17 +24,17 @@ int _traininfo_vehicle_pitch = 0; int _traininfo_vehicle_width = 29; -typedef struct WagonOverride { +struct WagonOverride { byte *train_id; int trains; CargoID cargo; const SpriteGroup *group; -} WagonOverride; +}; -typedef struct WagonOverrides { +struct WagonOverrides { int overrides_count; WagonOverride *overrides; -} WagonOverrides; +}; static WagonOverrides _engine_wagon_overrides[TOTAL_NUM_ENGINES]; diff --git a/src/newgrf_engine.h b/src/newgrf_engine.h index 48a62fc561..de1eb77d0c 100644 --- a/src/newgrf_engine.h +++ b/src/newgrf_engine.h @@ -36,7 +36,7 @@ bool UsesWagonOverride(const Vehicle *v); #define GetCustomVehicleSprite(v, direction) GetCustomEngineSprite(v->engine_type, v, direction) #define GetCustomVehicleIcon(et, direction) GetCustomEngineSprite(et, NULL, direction) -typedef enum VehicleTrigger { +enum VehicleTrigger { VEHICLE_TRIGGER_NEW_CARGO = 1, // Externally triggered only for the first vehicle in chain VEHICLE_TRIGGER_DEPOT = 2, @@ -44,7 +44,7 @@ typedef enum VehicleTrigger { VEHICLE_TRIGGER_EMPTY = 4, // Not triggered externally (called for the whole chain if we got NEW_CARGO) VEHICLE_TRIGGER_ANY_NEW_CARGO = 8, -} VehicleTrigger; +}; void TriggerVehicle(Vehicle *veh, VehicleTrigger trigger); void SetCustomEngineName(EngineID engine, StringID name); diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index 3a1c497199..cf9a52508d 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -106,10 +106,10 @@ static void ShowNewGRFInfo(const GRFConfig *c, uint x, uint y, uint w, bool show /* Dialogue for adding NewGRF files to the selection */ -typedef struct newgrf_add_d { +struct newgrf_add_d { GRFConfig **list; const GRFConfig *sel; -} newgrf_add_d; +}; static void NewGRFAddDlgWndProc(Window *w, WindowEvent *e) @@ -236,14 +236,14 @@ static const WindowDesc _newgrf_add_dlg_desc = { /* 'NewGRF Settings' dialogue */ -typedef struct newgrf_d { +struct newgrf_d { GRFConfig **orig_list; ///< grf list the window is shown with GRFConfig **list; ///< temporary grf list to which changes are made GRFConfig *sel; ///< selected grf item bool editable; ///< is the window editable bool show_params; ///< are the grf-parameters shown in the info-panel bool execute; ///< on pressing 'apply changes' are grf changes applied immediately, or only list is updated -} newgrf_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(newgrf_d)); diff --git a/src/newgrf_sound.h b/src/newgrf_sound.h index 01bfce1334..61f7df12ef 100644 --- a/src/newgrf_sound.h +++ b/src/newgrf_sound.h @@ -3,7 +3,7 @@ #ifndef NEWGRF_SOUND_H #define NEWGRF_SOUND_H -typedef enum VehicleSoundEvents { +enum VehicleSoundEvent { VSE_START = 1, VSE_TUNNEL = 2, VSE_BREAKDOWN = 3, @@ -13,7 +13,7 @@ typedef enum VehicleSoundEvents { VSE_RUNNING_16 = 7, VSE_STOPPED_16 = 8, VSE_LOAD_UNLOAD = 9, -} VehicleSoundEvent; +}; FileEntry *AllocateFileEntry(); diff --git a/src/newgrf_spritegroup.h b/src/newgrf_spritegroup.h index 7451052c4d..cbd79a97d6 100644 --- a/src/newgrf_spritegroup.h +++ b/src/newgrf_spritegroup.h @@ -4,12 +4,12 @@ #define NEWGRF_SPRITEGROUP_H -typedef struct SpriteGroup SpriteGroup; +struct SpriteGroup; /* 'Real' sprite groups contain a list of other result or callback sprite * groups. */ -typedef struct RealSpriteGroup { +struct RealSpriteGroup { // Loaded = in motion, loading = not moving // Each group contains several spritesets, for various loading stages @@ -21,28 +21,28 @@ typedef struct RealSpriteGroup { byte num_loading; ///< Number of loading groups const SpriteGroup **loaded; ///< List of loaded groups (can be SpriteIDs or Callback results) const SpriteGroup **loading; ///< List of loading groups (can be SpriteIDs or Callback results) -} RealSpriteGroup; +}; /* Shared by deterministic and random groups. */ -typedef enum VarSpriteGroupScopes { +enum VarSpriteGroupScope { VSG_SCOPE_SELF, // Engine of consists for vehicles, city for stations. VSG_SCOPE_PARENT, -} VarSpriteGroupScope; +}; -typedef enum DeterministicSpriteGroupSizes { +enum DeterministicSpriteGroupSize { DSG_SIZE_BYTE, DSG_SIZE_WORD, DSG_SIZE_DWORD, -} DeterministicSpriteGroupSize; +}; -typedef enum DeterministicSpriteGroupAdjustTypes { +enum DeterministicSpriteGroupAdjustType { DSGA_TYPE_NONE, DSGA_TYPE_DIV, DSGA_TYPE_MOD, -} DeterministicSpriteGroupAdjustType; +}; -typedef enum DeterministicSpriteGroupAdjustOperations { +enum DeterministicSpriteGroupAdjustOperation { DSGA_OP_ADD, // a + b DSGA_OP_SUB, // a - b DSGA_OP_SMIN, // (signed) min(a, b) @@ -57,10 +57,10 @@ typedef enum DeterministicSpriteGroupAdjustOperations { DSGA_OP_AND, // a & b DSGA_OP_OR, // a | b DSGA_OP_XOR, // a ^ b -} DeterministicSpriteGroupAdjustOperation; +}; -typedef struct DeterministicSpriteGroupAdjust { +struct DeterministicSpriteGroupAdjust { DeterministicSpriteGroupAdjustOperation operation; DeterministicSpriteGroupAdjustType type; byte variable; @@ -70,17 +70,17 @@ typedef struct DeterministicSpriteGroupAdjust { uint32 add_val; uint32 divmod_val; const SpriteGroup *subroutine; -} DeterministicSpriteGroupAdjust; +}; -typedef struct DeterministicSpriteGroupRange { +struct DeterministicSpriteGroupRange { const SpriteGroup *group; uint32 low; uint32 high; -} DeterministicSpriteGroupRange; +}; -typedef struct DeterministicSpriteGroup { +struct DeterministicSpriteGroup { VarSpriteGroupScope var_scope; DeterministicSpriteGroupSize size; byte num_adjusts; @@ -90,14 +90,14 @@ typedef struct DeterministicSpriteGroup { // Dynamically allocated, this is the sole owner const SpriteGroup *default_group; -} DeterministicSpriteGroup; +}; -typedef enum RandomizedSpriteGroupCompareModes { +enum RandomizedSpriteGroupCompareMode { RSG_CMP_ANY, RSG_CMP_ALL, -} RandomizedSpriteGroupCompareMode; +}; -typedef struct RandomizedSpriteGroup { +struct RandomizedSpriteGroup { // Take this object: VarSpriteGroupScope var_scope; @@ -111,32 +111,32 @@ typedef struct RandomizedSpriteGroup { // Take the group with appropriate index: const SpriteGroup **groups; -} RandomizedSpriteGroup; +}; /* This contains a callback result. A failed callback has a value of * CALLBACK_FAILED */ -typedef struct CallbackResultSpriteGroup { +struct CallbackResultSpriteGroup { uint16 result; -} CallbackResultSpriteGroup; +}; /* A result sprite group returns the first SpriteID and the number of * sprites in the set */ -typedef struct ResultSpriteGroup { +struct ResultSpriteGroup { SpriteID sprite; byte num_sprites; -} ResultSpriteGroup; +}; /* List of different sprite group types */ -typedef enum SpriteGroupType { +enum SpriteGroupType { SGT_INVALID, SGT_REAL, SGT_DETERMINISTIC, SGT_RANDOMIZED, SGT_CALLBACK, SGT_RESULT, -} SpriteGroupType; +}; /* Common wrapper for all the different sprite group types */ struct SpriteGroup { @@ -156,7 +156,7 @@ SpriteGroup *AllocateSpriteGroup(); void InitializeSpriteGroupPool(); -typedef struct ResolverObject { +struct ResolverObject { uint16 callback; uint32 callback_param1; uint32 callback_param2; @@ -187,7 +187,7 @@ typedef struct ResolverObject { void (*SetTriggers)(const struct ResolverObject*, int); uint32 (*GetVariable)(const struct ResolverObject*, byte, byte, bool*); const SpriteGroup *(*ResolveReal)(const struct ResolverObject*, const SpriteGroup*); -} ResolverObject; +}; /* Base sprite group resolver */ diff --git a/src/newgrf_station.h b/src/newgrf_station.h index 40cdc33fb2..640620fe7e 100644 --- a/src/newgrf_station.h +++ b/src/newgrf_station.h @@ -9,12 +9,12 @@ #include "newgrf_cargo.h" #include "helpers.hpp" -typedef enum { +enum StationClassID { STAT_CLASS_BEGIN = 0, ///< the lowest valid value STAT_CLASS_DFLT = 0, ///< Default station class. STAT_CLASS_WAYP, ///< Waypoint class. STAT_CLASS_MAX = 32, ///< Maximum number of classes. -} StationClassID; +}; /** Define basic enum properties */ template <> struct EnumPropsT : MakeEnumPropsT {}; @@ -27,7 +27,7 @@ DECLARE_POSTFIX_INCREMENT(StationClassID); * where index is computed as (x * platforms) + platform. */ typedef byte *StationLayout; -typedef struct StationSpec { +struct StationSpec { uint32 grfid; ///< ID of GRF file station belongs to. int localidx; ///< Index within GRF file of station. @@ -84,17 +84,17 @@ typedef struct StationSpec { * evaluating callbacks. */ const struct SpriteGroup *spritegroup[NUM_CARGO + 3]; -} StationSpec; +}; /** * Struct containing information relating to station classes. */ -typedef struct StationClass { +struct StationClass { uint32 id; ///< ID of this class, e.g. 'DFLT', 'WAYP', etc. StringID name; ///< Name of this class. uint stations; ///< Number of stations in this class. StationSpec **spec; ///< Array of station specifications. -} StationClass; +}; void ResetStationClasses(); StationClassID AllocateStationClass(uint32 cls); diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp index ae012f3f16..d5dfb5fcff 100644 --- a/src/newgrf_text.cpp +++ b/src/newgrf_text.cpp @@ -30,16 +30,16 @@ * the grf base will not be used in order to find the string, but rather for * jumping from standard langID scheme to the new one. */ -typedef enum grf_base_languages { +enum grf_base_languages { GRFLB_AMERICAN = 0x01, GRFLB_ENGLISH = 0x02, GRFLB_GERMAN = 0x04, GRFLB_FRENCH = 0x08, GRFLB_SPANISH = 0x10, GRFLB_GENERIC = 0x80, -} grf_base_language; +}; -typedef enum grf_extended_languages { +enum grf_extended_languages { GRFLX_AMERICAN = 0x00, GRFLX_ENGLISH = 0x01, GRFLX_GERMAN = 0x02, @@ -73,13 +73,13 @@ typedef enum grf_extended_languages { GRFLX_CROATIAN = 0x38, GRFLX_TURKISH = 0x3E, GRFLX_UNSPECIFIED = 0x7F, -} grf_language; +}; -typedef struct iso_grf { +struct iso_grf { char code[6]; byte grfLangID; -} iso_grf; +}; /** * ISO code VS NewGrf langID conversion array. @@ -170,12 +170,12 @@ public: * Putting both grfid and stringid together allows us to avoid duplicates, * since it is NOT SUPPOSED to happen. */ -typedef struct GRFTextEntry { +struct GRFTextEntry { uint32 grfid; uint16 stringid; StringID def_string; GRFText *textholder; -} GRFTextEntry; +}; static uint _num_grf_texts = 0; diff --git a/src/npf.h b/src/npf.h index 653d31b9ab..81329b93f8 100644 --- a/src/npf.h +++ b/src/npf.h @@ -35,10 +35,10 @@ enum { NPF_INFINITE_PENALTY = 1000 * NPF_TILE_LENGTH }; -typedef struct NPFFindStationOrTileData { /* Meant to be stored in AyStar.targetdata */ +struct NPFFindStationOrTileData { /* Meant to be stored in AyStar.targetdata */ TileIndex dest_coords; /* An indication of where the station is, for heuristic purposes, or the target tile */ StationID station_index; /* station index we're heading for, or INVALID_STATION when we're heading for a tile */ -} NPFFindStationOrTileData; +}; enum { /* Indices into AyStar.userdata[] */ NPF_TYPE = 0, /* Contains a TransportTypes value */ @@ -51,18 +51,18 @@ enum { /* Indices into AyStarNode.userdata[] */ NPF_NODE_FLAGS, }; -typedef enum { /* Flags for AyStarNode.userdata[NPF_NODE_FLAGS]. Use NPFGetBit() and NPFGetBit() to use them. */ +enum NPFNodeFlag { /* Flags for AyStarNode.userdata[NPF_NODE_FLAGS]. Use NPFGetBit() and NPFGetBit() to use them. */ NPF_FLAG_SEEN_SIGNAL, /* Used to mark that a signal was seen on the way, for rail only */ NPF_FLAG_REVERSE, /* Used to mark that this node was reached from the second start node, if applicable */ NPF_FLAG_LAST_SIGNAL_RED, /* Used to mark that the last signal on this path was red */ -} NPFNodeFlag; +}; -typedef struct NPFFoundTargetData { /* Meant to be stored in AyStar.userpath */ +struct NPFFoundTargetData { /* Meant to be stored in AyStar.userpath */ uint best_bird_dist; /* The best heuristic found. Is 0 if the target was found */ uint best_path_dist; /* The shortest path. Is (uint)-1 if no path is found */ Trackdir best_trackdir; /* The trackdir that leads to the shortest path/closest birds dist */ AyStarNode node; /* The node within the target the search led us to */ -} NPFFoundTargetData; +}; /* These functions below are _not_ re-entrant, in favor of speed! */ diff --git a/src/oldloader.cpp b/src/oldloader.cpp index 5082900c99..4ccfc8cd00 100644 --- a/src/oldloader.cpp +++ b/src/oldloader.cpp @@ -27,7 +27,7 @@ enum { OLD_MAP_SIZE = 256 * 256 }; -typedef struct LoadgameState { +struct LoadgameState { FILE *file; uint chunk_size; @@ -41,10 +41,10 @@ typedef struct LoadgameState { uint total_read; bool failed; -} LoadgameState; +}; /* OldChunk-Type */ -typedef enum OldChunkTypes { +enum OldChunkType { OC_SIMPLE = 0, OC_NULL = 1, OC_CHUNK = 2, @@ -78,20 +78,20 @@ typedef enum OldChunkTypes { OC_TILE = OC_VAR_U32 | OC_FILE_U16, OC_END = 0 ///< End of the whole chunk, all 32bits set to zero -} OldChunkType; +}; DECLARE_ENUM_AS_BIT_SET(OldChunkType); typedef bool OldChunkProc(LoadgameState *ls, int num); -typedef struct OldChunks { +struct OldChunks { OldChunkType type; ///< Type of field uint32 amount; ///< Amount of fields void *ptr; ///< Pointer where to save the data (may only be set if offset is 0) uint offset; ///< Offset from basepointer (may only be set if ptr is NULL) OldChunkProc *proc; ///< Pointer to function that is called with OC_CHUNK -} OldChunks; +}; /* If it fails, check lines above.. */ assert_compile(sizeof(TileIndex) == 4); diff --git a/src/oldpool.h b/src/oldpool.h index 8176ba30c3..7b296715e6 100644 --- a/src/oldpool.h +++ b/src/oldpool.h @@ -3,7 +3,7 @@ #ifndef OLDPOOL_H #define OLDPOOL_H -typedef struct OldMemoryPool OldMemoryPool; +struct OldMemoryPool; /* The function that is called after a new block is added start_item is the first item of the new made block */ diff --git a/src/openttd.h b/src/openttd.h index b4581ea362..4fa9fbf9ae 100644 --- a/src/openttd.h +++ b/src/openttd.h @@ -11,43 +11,43 @@ #include "hal.h" #include "helpers.hpp" -typedef struct Oblong { +struct Oblong { int x, y; int width, height; -} Oblong; +}; -typedef struct BoundingRect { +struct BoundingRect { int width; int height; -} BoundingRect; +}; -typedef struct Pair { +struct Pair { int a; int b; -} Pair; +}; #include "map.h" #include "slope.h" // Forward declarations of structs. -typedef struct Vehicle Vehicle; -typedef struct Depot Depot; -typedef struct Waypoint Waypoint; -typedef struct Window Window; -typedef struct Station Station; -typedef struct ViewPort ViewPort; -typedef struct Town Town; -typedef struct NewsItem NewsItem; -typedef struct Industry Industry; -typedef struct DrawPixelInfo DrawPixelInfo; +struct Vehicle; +struct Depot; +struct Waypoint; +struct Window; +struct Station; +struct ViewPort; +struct Town; +struct NewsItem; +struct Industry; +struct DrawPixelInfo; 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 -typedef struct PalSpriteID { +struct PalSpriteID { SpriteID sprite; SpriteID pal; -} PalSpriteID; +}; typedef uint16 EngineID; typedef uint16 UnitID; typedef uint16 StringID; @@ -140,7 +140,7 @@ typedef TinyEnumT OwnerByte; typedef OwnerByte PlayerByte; -typedef enum TransportTypes { +enum TransportType { /* These constants are for now linked to the representation of bridges * and tunnels, so they can be used by GetTileTrackStatus_TunnelBridge. * In an ideal world, these constants would be used everywhere when @@ -153,20 +153,20 @@ typedef enum TransportTypes { TRANSPORT_WATER, // = 2 TRANSPORT_END, INVALID_TRANSPORT = 0xff, -} TransportType; +}; /** Define basic enum properties */ template <> struct EnumPropsT : MakeEnumPropsT {}; typedef TinyEnumT TransportTypeByte; -typedef struct TileInfo { +struct TileInfo { uint x; uint y; Slope tileh; TileIndex tile; uint z; -} TileInfo; +}; /* Display Options */ @@ -195,7 +195,7 @@ enum { NUM_PRICES = 49, }; -typedef struct Prices { +struct Prices { int32 station_value; int32 build_rail; int32 build_road; @@ -243,11 +243,11 @@ typedef struct Prices { int32 roadveh_running; int32 ship_running; int32 build_industry; -} Prices; +}; #define GAME_DIFFICULTY_NUM 18 -typedef struct GameDifficulty { +struct GameDifficulty { int max_no_competitors; int competitor_start_time; int number_towns; @@ -266,7 +266,7 @@ typedef struct GameDifficulty { int line_reverse_mode; int disasters; int town_council_tolerance; // minimum required town ratings to be allowed to demolish stuff -} GameDifficulty; +}; enum { // Temperate @@ -317,18 +317,18 @@ enum { typedef uint AcceptedCargo[NUM_CARGO]; -typedef struct TileDesc { +struct TileDesc { StringID str; Owner owner; Date build_date; uint32 dparam[2]; -} TileDesc; +}; -typedef struct { +struct ViewportSign { int32 left; int32 top; byte width_1, width_2; -} ViewportSign; +}; typedef void DrawTileProc(TileInfo *ti); @@ -365,7 +365,7 @@ typedef void ChangeTileOwnerProc(TileIndex tile, PlayerID old_player, PlayerID n typedef uint32 VehicleEnterTileProc(Vehicle *v, TileIndex tile, int x, int y); typedef Slope GetSlopeTilehProc(TileIndex, Slope tileh); -typedef struct { +struct TileTypeProcs { DrawTileProc *draw_tile_proc; GetSlopeZProc *get_slope_z_proc; ClearTileProc *clear_tile_proc; @@ -379,7 +379,7 @@ typedef struct { GetProducedCargoProc *get_produced_cargo_proc; VehicleEnterTileProc *vehicle_enter_tile_proc; GetSlopeTilehProc *get_slope_tileh_proc; -} TileTypeProcs; +}; enum WindowClass { @@ -575,11 +575,11 @@ VARDEF byte _no_scroll; /** 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 */ -typedef enum ThreadMsgs { +enum ThreadMsg { MSG_OTTD_NO_MESSAGE, MSG_OTTD_SAVETHREAD_DONE, MSG_OTTD_SAVETHREAD_ERROR, -} ThreadMsg; +}; void OTTD_SendThreadMessage(ThreadMsg msg); diff --git a/src/order.h b/src/order.h index 44c7347b87..b996fb9d6f 100644 --- a/src/order.h +++ b/src/order.h @@ -88,8 +88,8 @@ enum { * - Vehicle -> current_order * - REF_SHEDULE (all REFs are currently limited to 16 bits!!) */ -typedef struct Order { - struct Order *next; ///< Pointer to next order. If NULL, end of list +struct Order { + Order *next; ///< Pointer to next order. If NULL, end of list OrderTypeByte type; uint8 flags; @@ -99,17 +99,17 @@ typedef struct Order { CargoID refit_cargo; // Refit CargoID byte refit_subtype; // Refit subtype -} Order; +}; #define MAX_BACKUP_ORDER_COUNT 40 -typedef struct { +struct BackuppedOrders { VehicleID clone; VehicleOrderID orderindex; Order order[MAX_BACKUP_ORDER_COUNT + 1]; uint16 service_interval; char name[32]; -} BackuppedOrders; +}; VARDEF TileIndex _backup_orders_tile; VARDEF BackuppedOrders _backup_orders_data[1]; diff --git a/src/pathfind.cpp b/src/pathfind.cpp index 431acd3171..169682c921 100644 --- a/src/pathfind.cpp +++ b/src/pathfind.cpp @@ -423,7 +423,7 @@ void FollowTrack(TileIndex tile, uint16 flags, DiagDirection direction, TPFEnumP after_proc(&tpf); } -typedef struct { +struct StackedItem { TileIndex tile; uint16 cur_length; // This is the current length to this tile. uint16 priority; // This is the current length + estimated length to the goal. @@ -431,7 +431,7 @@ typedef struct { byte depth; byte state; byte first_track; -} StackedItem; +}; static const Trackdir _new_trackdir[6][4] = { {TRACKDIR_X_NE, INVALID_TRACKDIR, TRACKDIR_X_SW, INVALID_TRACKDIR,}, @@ -442,13 +442,13 @@ static const Trackdir _new_trackdir[6][4] = { {INVALID_TRACKDIR, INVALID_TRACKDIR, TRACKDIR_RIGHT_S, TRACKDIR_RIGHT_N,}, }; -typedef struct HashLink { +struct HashLink { TileIndex tile; uint16 typelength; uint16 next; -} HashLink; +}; -typedef struct { +struct NewTrackPathFinder { NTPEnumProc *enum_proc; void *userdata; TileIndex dest; @@ -468,7 +468,7 @@ typedef struct { HashLink links[0x400]; // hash links -} NewTrackPathFinder; +}; #define NTP_GET_LINK_OFFS(tpf, link) ((byte*)(link) - (byte*)tpf->links) #define NTP_GET_LINK_PTR(tpf, link_offs) (HashLink*)((byte*)tpf->links + (link_offs)) diff --git a/src/pathfind.h b/src/pathfind.h index 6c0dccad1d..bbd9f83f5d 100644 --- a/src/pathfind.h +++ b/src/pathfind.h @@ -14,7 +14,7 @@ enum { //#define PF_BENCH // perform simple benchmarks on the train pathfinder (not //supported on all archs) -typedef struct TrackPathFinder TrackPathFinder; +struct TrackPathFinder; typedef bool TPFEnumProc(TileIndex tile, void *data, Trackdir trackdir, uint length, byte *state); typedef void TPFAfterProc(TrackPathFinder *tpf); @@ -30,17 +30,17 @@ typedef bool NTPEnumProc(TileIndex tile, void *data, int track, uint length); */ #define PATHFIND_HASH_TILE(tile) (TileX(tile) & 0x1F) + ((TileY(tile) & 0x1F) << 5) -typedef struct TrackPathFinderLink { +struct TrackPathFinderLink { TileIndex tile; uint16 flags; uint16 next; -} TrackPathFinderLink; +}; -typedef struct RememberData { +struct RememberData { uint16 cur_length; byte depth; byte pft_var6; -} RememberData; +}; struct TrackPathFinder { int num_links_left; @@ -67,10 +67,10 @@ struct TrackPathFinder { void FollowTrack(TileIndex tile, uint16 flags, DiagDirection direction, TPFEnumProc* enum_proc, TPFAfterProc* after_proc, void* data); -typedef struct { +struct FindLengthOfTunnelResult { TileIndex tile; int length; -} FindLengthOfTunnelResult; +}; FindLengthOfTunnelResult FindLengthOfTunnel(TileIndex tile, DiagDirection direction); void NewTrainPathfind(TileIndex tile, TileIndex dest, RailTypeMask railtypes, DiagDirection direction, NTPEnumProc* enum_proc, void* data); diff --git a/src/player.h b/src/player.h index 2f1d482595..70234dd93d 100644 --- a/src/player.h +++ b/src/player.h @@ -9,15 +9,15 @@ #include "engine.h" #include "livery.h" -typedef struct PlayerEconomyEntry { +struct PlayerEconomyEntry { int32 income; int32 expenses; int32 delivered_cargo; int32 performance_history; // player score (scale 0-1000) int64 company_value; -} PlayerEconomyEntry; +}; -typedef struct AiBuildRec { +struct AiBuildRec { TileIndex spec_tile; TileIndex use_tile; byte rand_rng; @@ -28,9 +28,9 @@ typedef struct AiBuildRec { byte buildcmd_b; byte direction; CargoID cargo; -} AiBuildRec; +}; -typedef struct PlayerAI { +struct PlayerAI { byte state; byte tick; // Used to determine how often to move uint32 state_counter; // Can hold tile index! @@ -68,9 +68,9 @@ typedef struct PlayerAI { TileIndex banned_tiles[16]; byte banned_val[16]; -} PlayerAI; +}; -typedef struct Ai_PathFinderInfo { +struct Ai_PathFinderInfo { TileIndex start_tile_tl; // tl = top-left TileIndex start_tile_br; // br = bottom-right TileIndex end_tile_tl; // tl = top-left @@ -84,17 +84,17 @@ typedef struct Ai_PathFinderInfo { int position; // Current position in the build-path, needed to build the path bool rail_or_road; // true = rail, false = road -} Ai_PathFinderInfo; +}; // The amount of memory reserved for the AI-special-vehicles #define AI_MAX_SPECIAL_VEHICLES 100 -typedef struct Ai_SpecialVehicle { +struct Ai_SpecialVehicle { VehicleID veh_id; uint32 flag; -} Ai_SpecialVehicle; +}; -typedef struct PlayerAiNew { +struct PlayerAiNew { uint8 state; uint tick; uint idle; @@ -144,12 +144,12 @@ typedef struct PlayerAiNew { int to_ic; byte to_type; -} PlayerAiNew; +}; typedef uint32 PlayerFace; -typedef struct Player { +struct Player { uint32 name_2; uint16 name_1; @@ -198,7 +198,7 @@ typedef struct Player { int16 engine_renew_months; uint32 engine_renew_money; uint16 num_engines[TOTAL_NUM_ENGINES]; // caches the number of engines of each type the player owns (no need to save this) -} Player; +}; uint16 GetDrawStringPlayerColor(PlayerID player); @@ -282,11 +282,11 @@ static inline RailType GetBestRailtype(const Player* p) return RAILTYPE_RAIL; } -typedef struct HighScore { +struct HighScore { char company[100]; StringID title; // NO_SAVE, has troubles with changing string-numbers. uint16 score; // do NOT change type, will break hs.dat -} HighScore; +}; VARDEF HighScore _highscore_table[5][5]; // 4 difficulty-settings (+ network); top 5 void SaveToHighScore(); diff --git a/src/player_gui.cpp b/src/player_gui.cpp index 8696e77347..b7a1f941ac 100644 --- a/src/player_gui.cpp +++ b/src/player_gui.cpp @@ -286,10 +286,10 @@ static const byte livery_height[] = { 3, }; -typedef struct livery_d { +struct livery_d { uint32 sel; LiveryClass livery_class; -} livery_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(livery_d)); static void ShowColourDropDownMenu(Window *w, uint32 widget) diff --git a/src/queue.h b/src/queue.h index d65dee4661..6698531f20 100644 --- a/src/queue.h +++ b/src/queue.h @@ -9,21 +9,19 @@ //#define HASH_STATS -typedef struct Queue Queue; +struct Queue; typedef bool Queue_PushProc(Queue* q, void* item, int priority); typedef void* Queue_PopProc(Queue* q); typedef bool Queue_DeleteProc(Queue* q, void* item, int priority); typedef void Queue_ClearProc(Queue* q, bool free_values); typedef void Queue_FreeProc(Queue* q, bool free_values); -typedef struct InsSortNode InsSortNode; struct InsSortNode { void* item; int priority; InsSortNode* next; }; -typedef struct BinaryHeapNode BinaryHeapNode; struct BinaryHeapNode { void* item; int priority; @@ -99,7 +97,6 @@ void init_BinaryHeap(Queue* q, uint max_size); /* * Hash */ -typedef struct HashNode HashNode; struct HashNode { uint key1; uint key2; @@ -111,7 +108,7 @@ struct HashNode { * the resulting range is clearly defined. */ typedef uint Hash_HashProc(uint key1, uint key2); -typedef struct Hash { +struct Hash { /* The hash function used */ Hash_HashProc* hash; /* The amount of items in the hash */ @@ -123,7 +120,7 @@ typedef struct Hash { /* A pointer to an array of numbuckets booleans, which will be true if * there are any Nodes in the bucket */ bool* buckets_in_use; -} Hash; +}; /* Call these function to manipulate a hash */ diff --git a/src/rail.h b/src/rail.h index d995fcfa9b..20cc15ce3a 100644 --- a/src/rail.h +++ b/src/rail.h @@ -9,7 +9,7 @@ #include "direction.h" #include "tile.h" -typedef enum RailTypes { +enum RailType { RAILTYPE_BEGIN = 0, RAILTYPE_RAIL = 0, RAILTYPE_ELECTRIC = 1, @@ -17,7 +17,7 @@ typedef enum RailTypes { RAILTYPE_MAGLEV = 3, RAILTYPE_END, INVALID_RAILTYPE = 0xFF -} RailType; +}; typedef byte RailTypeMask; @@ -30,7 +30,7 @@ typedef TinyEnumT RailTypeByte; /** These are used to specify a single track. * Can be translated to a trackbit with TrackToTrackbit */ -typedef enum Track { +enum Track { TRACK_BEGIN = 0, TRACK_X = 0, TRACK_Y = 1, @@ -40,7 +40,7 @@ typedef enum Track { TRACK_RIGHT = 5, TRACK_END, INVALID_TRACK = 0xFF -} Track; +}; /** Allow incrementing of Track variables */ DECLARE_POSTFIX_INCREMENT(Track); @@ -61,7 +61,7 @@ static inline Track AxisToTrack(Axis a) /** Bitfield corresponding to Track */ -typedef enum TrackBits { +enum TrackBits { TRACK_BIT_NONE = 0U, TRACK_BIT_X = 1U << TRACK_X, TRACK_BIT_Y = 1U << TRACK_Y, @@ -81,7 +81,7 @@ typedef enum TrackBits { TRACK_BIT_WORMHOLE = 0x40U, TRACK_BIT_DEPOT = 0x80U, INVALID_TRACK_BIT = 0xFF -} TrackBits; +}; /** Define basic enum properties */ template <> struct EnumPropsT : MakeEnumPropsT {}; @@ -110,7 +110,7 @@ static inline TrackBits AxisToTrackBits(Axis a) * reversing track dirs are not considered to be 'valid' except in a small * corner in the road vehicle controller. */ -typedef enum Trackdirs { +enum Trackdir { TRACKDIR_BEGIN = 0, TRACKDIR_X_NE = 0, TRACKDIR_Y_SE = 1, @@ -130,7 +130,7 @@ typedef enum Trackdirs { TRACKDIR_RVREV_NW = 15, TRACKDIR_END, INVALID_TRACKDIR = 0xFF, -} Trackdir; +}; /** Define basic enum properties */ template <> struct EnumPropsT : MakeEnumPropsT {}; @@ -138,7 +138,7 @@ typedef TinyEnumT TrackdirByte; /** These are a combination of tracks and directions. Values are 0-5 in one * direction (corresponding to the Track enum) and 8-13 in the other direction. */ -typedef enum TrackdirBits { +enum TrackdirBits { TRACKDIR_BIT_NONE = 0x0000, TRACKDIR_BIT_X_NE = 0x0001, TRACKDIR_BIT_Y_SE = 0x0002, @@ -155,7 +155,7 @@ typedef enum TrackdirBits { TRACKDIR_BIT_RIGHT_N = 0x2000, TRACKDIR_BIT_MASK = 0x3F3F, INVALID_TRACKDIR_BIT = 0xFFFF, -} TrackdirBits; +}; /** Define basic enum properties */ template <> struct EnumPropsT : MakeEnumPropsT {}; @@ -164,7 +164,7 @@ DECLARE_ENUM_AS_BIT_SET(TrackdirBits); /** This struct contains all the info that is needed to draw and construct tracks. */ -typedef struct RailtypeInfo { +struct RailtypeInfo { /** Struct containing the main sprites. @note not all sprites are listed, but only * the ones used directly in the code */ struct { @@ -237,7 +237,7 @@ typedef struct RailtypeInfo { * Offset to add to ground sprite when drawing custom waypoints / stations */ byte custom_ground_offset; -} RailtypeInfo; +}; // these are the maximums used for updating signal blocks, and checking if a depot is in a pbs block diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index 8e6a0f0573..6f4143f033 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -1417,7 +1417,7 @@ void DrawDefaultWaypointSprite(int x, int y, RailType railtype) DrawTileSequence(x, y, dts->ground_sprite + offset, dts->seq, 0); } -typedef struct SetSignalsData { +struct SetSignalsData { int cur; int cur_stack; bool stop; @@ -1435,7 +1435,7 @@ typedef struct SetSignalsData { TileIndex next_tile[NUM_SSD_STACK]; DiagDirectionByte next_dir[NUM_SSD_STACK]; -} SetSignalsData; +}; static bool SetSignalsEnumProc(TileIndex tile, void* data, Trackdir trackdir, uint length, byte* state) { @@ -1473,10 +1473,10 @@ static bool SetSignalsEnumProc(TileIndex tile, void* data, Trackdir trackdir, ui } /* Struct to parse data from VehicleFromPos to SignalVehicleCheckProc */ -typedef struct SignalVehicleCheckStruct { +struct SignalVehicleCheckStruct { TileIndex tile; uint track; -} SignalVehicleCheckStruct; +}; static void *SignalVehicleCheckProc(Vehicle *v, void *data) { diff --git a/src/rail_map.h b/src/rail_map.h index 5406432533..230bb0348b 100644 --- a/src/rail_map.h +++ b/src/rail_map.h @@ -8,12 +8,12 @@ #include "tile.h" -typedef enum RailTileType { +enum RailTileType { RAIL_TILE_NORMAL = 0, RAIL_TILE_SIGNALS = 1, RAIL_TILE_WAYPOINT = 2, RAIL_TILE_DEPOT = 3, -} RailTileType; +}; static inline RailTileType GetRailTileType(TileIndex t) { @@ -118,12 +118,12 @@ static inline WaypointID GetWaypointIndex(TileIndex t) return (WaypointID)_m[t].m2; } -typedef enum SignalType { +enum SignalType { SIGTYPE_NORMAL = 0, // normal signal SIGTYPE_ENTRY = 1, // presignal block entry SIGTYPE_EXIT = 2, // presignal block exit SIGTYPE_COMBO = 3 // presignal inter-block -} SignalType; +}; static inline SignalType GetSignalType(TileIndex t) { @@ -159,10 +159,10 @@ static inline void CycleSignalSide(TileIndex t, Track track) } -typedef enum SignalVariant { +enum SignalVariant { SIG_ELECTRIC = 0, SIG_SEMAPHORE = 1 -} SignalVariant; +}; static inline SignalVariant GetSignalVariant(TileIndex t) { @@ -183,10 +183,10 @@ static inline bool IsSignalPresent(TileIndex t, byte signalbit) * simple boolean logic will do. But do try to compare to this enum instead of * normal boolean evaluation, since that will make future additions easier. */ -typedef enum SignalStates { +enum SignalState { SIGNAL_STATE_RED = 0, SIGNAL_STATE_GREEN = 1, -} SignalState; +}; static inline SignalState GetSingleSignalState(TileIndex t, byte signalbit) { @@ -242,7 +242,7 @@ static inline SignalState GetSignalStateByTrackdir(TileIndex tile, Trackdir trac RailType GetTileRailType(TileIndex tile); -typedef enum RailGroundType { +enum RailGroundType { RAIL_GROUND_BARREN = 0, RAIL_GROUND_GRASS = 1, RAIL_GROUND_FENCE_NW = 2, @@ -256,7 +256,7 @@ typedef enum RailGroundType { RAIL_GROUND_FENCE_HORIZ1 = 10, RAIL_GROUND_FENCE_HORIZ2 = 11, RAIL_GROUND_ICE_DESERT = 12, -} RailGroundType; +}; static inline void SetRailGroundType(TileIndex t, RailGroundType rgt) { diff --git a/src/road.h b/src/road.h index 0f1967f427..249c8f7882 100644 --- a/src/road.h +++ b/src/road.h @@ -5,7 +5,7 @@ #include "helpers.hpp" -typedef enum RoadBits { +enum RoadBits { ROAD_NONE = 0U, ROAD_NW = 1U, ROAD_SW = 2U, @@ -14,7 +14,7 @@ typedef enum RoadBits { ROAD_X = ROAD_SW | ROAD_NE, ROAD_Y = ROAD_NW | ROAD_SE, ROAD_ALL = ROAD_X | ROAD_Y -} RoadBits; +}; DECLARE_ENUM_AS_BIT_SET(RoadBits); diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 3d9327950e..b2ff51e5af 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -599,11 +599,11 @@ static int32 ClearTile_Road(TileIndex tile, byte flags) } -typedef struct DrawRoadTileStruct { +struct DrawRoadTileStruct { uint16 image; byte subcoord_x; byte subcoord_y; -} DrawRoadTileStruct; +}; #include "table/road_land.h" diff --git a/src/road_map.h b/src/road_map.h index 59da6be0e1..6cc6faed0b 100644 --- a/src/road_map.h +++ b/src/road_map.h @@ -9,11 +9,11 @@ #include "tile.h" -typedef enum RoadTileType { +enum RoadTileType { ROAD_TILE_NORMAL, ROAD_TILE_CROSSING, ROAD_TILE_DEPOT -} RoadTileType; +}; static inline RoadTileType GetRoadTileType(TileIndex t) { @@ -105,7 +105,7 @@ static inline void ToggleSnow(TileIndex t) } -typedef enum Roadside { +enum Roadside { ROADSIDE_BARREN = 0, ROADSIDE_GRASS = 1, ROADSIDE_PAVED = 2, @@ -113,7 +113,7 @@ typedef enum Roadside { ROADSIDE_TREES = 5, ROADSIDE_GRASS_ROAD_WORKS = 6, ROADSIDE_PAVED_ROAD_WORKS = 7 -} Roadside; +}; static inline Roadside GetRoadside(TileIndex tile) { diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index d938f44617..e4e95f21f4 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -306,11 +306,11 @@ int32 CmdSellRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) return -(int32)v->value; } -typedef struct RoadFindDepotData { +struct RoadFindDepotData { uint best_length; TileIndex tile; OwnerByte owner; -} RoadFindDepotData; +}; static const DiagDirection _road_pf_directions[] = { DIAGDIR_NE, DIAGDIR_SE, DIAGDIR_NE, DIAGDIR_SE, DIAGDIR_SW, DIAGDIR_SE, INVALID_DIAGDIR, INVALID_DIAGDIR, @@ -785,12 +785,12 @@ static void StartRoadVehSound(const Vehicle* v) } } -typedef struct RoadVehFindData { +struct RoadVehFindData { int x; int y; const Vehicle* veh; Direction dir; -} RoadVehFindData; +}; static void* EnumCheckRoadVehClose(Vehicle *v, void* data) { @@ -933,12 +933,12 @@ static Direction RoadVehGetSlidingDirection(const Vehicle* v, int x, int y) return ChangeDir(old_dir, delta); } -typedef struct OvertakeData { +struct OvertakeData { const Vehicle* u; const Vehicle* v; TileIndex tile; byte tilebits; -} OvertakeData; +}; static void* EnumFindVehToOvertake(Vehicle* v, void* data) { @@ -1030,11 +1030,11 @@ static int PickRandomBit(uint bits) return i; } -typedef struct { +struct FindRoadToChooseData { TileIndex dest; uint maxtracklen; uint mindist; -} FindRoadToChooseData; +}; static bool EnumRoadTrackFindDist(TileIndex tile, void* data, Trackdir trackdir, uint length, byte* state) { @@ -1256,9 +1256,9 @@ enum { RVC_DRIVE_THROUGH_STOP_FRAME = 7 }; -typedef struct RoadDriveEntry { - byte x,y; -} RoadDriveEntry; +struct RoadDriveEntry { + byte x, y; +}; #include "table/roadveh.h" diff --git a/src/saveload.cpp b/src/saveload.cpp index 9c52e8e300..43c76d6090 100644 --- a/src/saveload.cpp +++ b/src/saveload.cpp @@ -1045,12 +1045,12 @@ static void UninitNoComp() #include "gfx.h" #include "gui.h" -typedef struct ThreadedSave { +struct ThreadedSave { uint count; byte ff_state; bool saveinprogress; CursorID cursor; -} ThreadedSave; +}; /* A maximum size of of 128K * 500 = 64.000KB savegames */ STATIC_OLD_POOL(Savegame, byte, 17, 500, NULL, NULL) @@ -1326,7 +1326,7 @@ static void *IntToReference(uint index, SLRefType rt) } /** The format for a reader/writer type of a savegame */ -typedef struct { +struct SaveLoadFormat { const char *name; ///< name of the compressor/decompressor (debug-only) uint32 tag; ///< the 4-letter tag by which it is identified in the savegame @@ -1337,7 +1337,7 @@ typedef struct { bool (*init_write)(); ///< function executed upon intialization of the saver WriterProc *writer; ///< function that saves the data to the file void (*uninit_write)(); ///< function executed when writing is done -} SaveLoadFormat; +}; static const SaveLoadFormat _saveload_formats[] = { {"memory", 0, NULL, NULL, NULL, InitMem, WriteMem, UnInitMem}, diff --git a/src/saveload.h b/src/saveload.h index 2cfe72adea..f5bf824898 100644 --- a/src/saveload.h +++ b/src/saveload.h @@ -9,20 +9,20 @@ #define SIZE_MAX ((size_t)-1) -typedef enum SaveOrLoadResult { +enum SaveOrLoadResult { SL_OK = 0, // completed successfully SL_ERROR = 1, // error that was caught before internal structures were modified SL_REINIT = 2, // error that was caught in the middle of updating game state, need to clear it. (can only happen during load) -} SaveOrLoadResult; +}; -typedef enum SaveOrLoadMode { +enum SaveOrLoadMode { SL_INVALID = -1, SL_LOAD = 0, SL_SAVE = 1, SL_OLD_LOAD = 2, SL_PNG = 3, SL_BMP = 4, -} SaveOrLoadMode; +}; SaveOrLoadResult SaveOrLoad(const char *filename, int mode); void WaitTillSaved(); @@ -32,18 +32,18 @@ void DoExitSave(); typedef void ChunkSaveLoadProc(); typedef void AutolengthProc(void *arg); -typedef struct { +struct ChunkHandler { uint32 id; ChunkSaveLoadProc *save_proc; ChunkSaveLoadProc *load_proc; uint32 flags; -} ChunkHandler; +}; -typedef struct { +struct NullStruct { byte null; -} NullStruct; +}; -typedef enum SLRefType { +enum SLRefType { REF_ORDER = 0, REF_VEHICLE = 1, REF_STATION = 2, @@ -51,7 +51,7 @@ typedef enum SLRefType { REF_VEHICLE_OLD = 4, REF_ROADSTOPS = 5, REF_ENGINE_RENEWS = 6, -} SLRefType; +}; #define SL_MAX_VERSION 255 @@ -166,7 +166,7 @@ enum SaveLoadTypes { typedef byte SaveLoadType; /** SaveLoad type struct. Do NOT use this directly but use the SLE_ macros defined just below! */ -typedef struct SaveLoad { +struct SaveLoad { SaveLoadType cmd; ///< the action to take with the saved/loaded type, All types need different action VarType conv; ///< type of the variable to be saved, int uint16 length; ///< (conditional) length of the variable (eg. arrays) (max array size is 65536 elements) @@ -177,7 +177,7 @@ typedef struct SaveLoad { * during runtime. Decision on which one to use is controlled by the function * that is called to save it. address: SlGlobList, offset: SlObject */ void *address; ///< address of variable OR offset of variable in the struct (max offset is 65536) -} SaveLoad; +}; /* Same as SaveLoad but global variables are used (for better readability); */ typedef SaveLoad SaveLoadGlobVarList; diff --git a/src/screenshot.cpp b/src/screenshot.cpp index 55faab1166..7e2671c6dc 100644 --- a/src/screenshot.cpp +++ b/src/screenshot.cpp @@ -24,11 +24,11 @@ ScreenshotType current_screenshot_type; typedef void ScreenshotCallback(void *userdata, Pixel *buf, uint y, uint pitch, uint n); typedef bool ScreenshotHandlerProc(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette); -typedef struct { +struct ScreenshotFormat { const char *name; const char *extension; ScreenshotHandlerProc *proc; -} ScreenshotFormat; +}; //************************************************ //*** SCREENSHOT CODE FOR WINDOWS BITMAP (.BMP) @@ -37,29 +37,29 @@ typedef struct { #pragma pack(push, 1) #endif -typedef struct BitmapFileHeader { +struct BitmapFileHeader { uint16 type; uint32 size; uint32 reserved; uint32 off_bits; -} GCC_PACK BitmapFileHeader; +} GCC_PACK; assert_compile(sizeof(BitmapFileHeader) == 14); #if defined(_MSC_VER) || defined(__WATCOMC__) #pragma pack(pop) #endif -typedef struct BitmapInfoHeader { +struct BitmapInfoHeader { uint32 size; int32 width, height; uint16 planes, bitcount; uint32 compression, sizeimage, xpels, ypels, clrused, clrimp; -} BitmapInfoHeader; +}; assert_compile(sizeof(BitmapInfoHeader) == 40); -typedef struct RgbQuad { +struct RgbQuad { byte blue, green, red, reserved; -} RgbQuad; +}; assert_compile(sizeof(RgbQuad) == 4); // generic .BMP writer @@ -260,7 +260,7 @@ static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *user //*** SCREENSHOT CODE FOR ZSOFT PAINTBRUSH (.PCX) //************************************************ -typedef struct { +struct PcxHeader { byte manufacturer; byte version; byte rle; @@ -276,7 +276,7 @@ typedef struct { uint16 width; uint16 height; byte filler[54]; -} PcxHeader; +}; assert_compile(sizeof(PcxHeader) == 128); static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette) diff --git a/src/screenshot.h b/src/screenshot.h index d8eb8b175e..be1e09e6e7 100644 --- a/src/screenshot.h +++ b/src/screenshot.h @@ -8,11 +8,11 @@ void InitializeScreenshotFormats(); const char *GetScreenshotFormatDesc(int i); void SetScreenshotFormat(int i); -typedef enum ScreenshotType { +enum ScreenshotType { SC_NONE, SC_VIEWPORT, SC_WORLD -} ScreenshotType; +}; bool MakeScreenshot(); void SetScreenshotType(ScreenshotType t); diff --git a/src/sdl.h b/src/sdl.h index 38e7f551bf..06549336d4 100644 --- a/src/sdl.h +++ b/src/sdl.h @@ -13,7 +13,7 @@ void SdlClose(uint32 x); #ifdef DYNAMICALLY_LOADED_SDL #include - typedef struct SDLProcs { + struct SDLProcs { int (SDLCALL *SDL_Init)(Uint32); int (SDLCALL *SDL_InitSubSystem)(Uint32); char *(SDLCALL *SDL_GetError)(); @@ -46,7 +46,7 @@ void SdlClose(uint32 x); int (SDLCALL *SDL_SetColorKey)(SDL_Surface *, Uint32, Uint32); void (SDLCALL *SDL_WM_SetIcon)(SDL_Surface *, Uint8 *); Uint32 (SDLCALL *SDL_MapRGB)(SDL_PixelFormat *, Uint8, Uint8, Uint8); - } SDLProcs; + }; extern SDLProcs sdl_proc; diff --git a/src/settings.cpp b/src/settings.cpp index 69c5654bae..3f251551b1 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -49,10 +49,10 @@ /** The patch values that are used for new games and/or modified in config file */ Patches _patches_newgame; -typedef struct IniFile IniFile; -typedef struct IniItem IniItem; -typedef struct IniGroup IniGroup; -typedef struct SettingsMemoryPool SettingsMemoryPool; +struct IniFile; +struct IniItem; +struct IniGroup; +struct SettingsMemoryPool; typedef const char *SettingListCallbackProc(const IniItem *item, uint index); typedef void SettingDescProc(IniFile *ini, const SettingDesc *desc, const char *grpname, void *object); diff --git a/src/settings.h b/src/settings.h index 79e0e3b62d..3a7523e183 100644 --- a/src/settings.h +++ b/src/settings.h @@ -46,7 +46,7 @@ typedef TinyEnumT SettingGuiFlag; typedef int32 OnChange(int32 var); -typedef struct SettingDescBase { +struct SettingDescBase { const char *name; ///< name of the setting. Used in configuration file and for console const void *def; ///< default value given when none is present SettingDescType cmd; ///< various flags for the variable @@ -56,12 +56,12 @@ typedef struct SettingDescBase { const char *many; ///< ONE/MANY_OF_MANY: string of possible values for this type StringID str; ///< (translated) string with descriptive text; gui and console OnChange *proc; ///< callback procedure for when the value is changed -} SettingDescBase; +}; -typedef struct SettingDesc { +struct SettingDesc { SettingDescBase desc; ///< Settings structure (going to configuration file) SaveLoad save; ///< Internal structure (going to savegame, parts to config) -} SettingDesc; +}; /* NOTE: The only difference between SettingDesc and SettingDescGlob is * that one uses global variables as a source and the other offsets @@ -72,10 +72,10 @@ typedef struct SettingDesc { * offset in a certain struct */ typedef SettingDesc SettingDescGlobVarList; -typedef enum { +enum IniGroupType { IGT_VARIABLES = 0, ///< values of the form "landscape = hilly" IGT_LIST = 1, ///< a list of values, seperated by \n and terminated by the next group block -} IniGroupType; +}; /** The patch values that are used for new games and/or modified in config file */ extern Patches _patches_newgame; diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index dda60f48f7..7d6da06004 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -295,12 +295,12 @@ void ShowGameOptions() AllocateWindowDesc(&_game_options_desc); } -typedef struct { +struct GameSettingData { int16 min; int16 max; int16 step; StringID str; -} GameSettingData; +}; static const GameSettingData _game_setting_info[] = { { 0, 7, 1, STR_NULL}, @@ -655,16 +655,16 @@ static const char *_patches_vehicles[] = { "freight_trains", }; -typedef struct PatchEntry { +struct PatchEntry { const SettingDesc *setting; uint index; -} PatchEntry; +}; -typedef struct PatchPage { +struct PatchPage { const char **names; PatchEntry *entries; byte num; -} PatchPage; +}; /* PatchPage holds the categories, the number of elements in each category * and (in NULL) a dynamic array of settings based on the string-representations diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index 3ba6d44050..0d7c2d6061 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -447,12 +447,12 @@ static void ShipArrivesAt(const Vehicle* v, Station* st) } } -typedef struct { +struct PathFindShip { TileIndex skiptile; TileIndex dest_coords; uint best_bird_dist; uint best_length; -} PathFindShip; +}; static bool ShipTrackFollower(TileIndex tile, PathFindShip *pfs, int track, uint length, byte *state) { diff --git a/src/signs.h b/src/signs.h index de2917033e..1a897594ba 100644 --- a/src/signs.h +++ b/src/signs.h @@ -5,7 +5,7 @@ #include "oldpool.h" -typedef struct Sign { +struct Sign { StringID str; ViewportSign sign; int32 x; @@ -14,7 +14,7 @@ typedef struct Sign { PlayerByte owner; // placed by this player. Anyone can delete them though. OWNER_NONE for gray signs from old games. SignID index; -} Sign; +}; DECLARE_OLD_POOL(Sign, Sign, 2, 16000) diff --git a/src/slope.h b/src/slope.h index 0708bc5d59..bd5958af86 100644 --- a/src/slope.h +++ b/src/slope.h @@ -3,7 +3,7 @@ #ifndef SLOPE_H #define SLOPE_H -typedef enum Slope { +enum Slope { SLOPE_FLAT = 0x00, SLOPE_W = 0x01, SLOPE_S = 0x02, @@ -25,7 +25,7 @@ typedef enum Slope { SLOPE_STEEP_S = SLOPE_STEEP | SLOPE_WSE, SLOPE_STEEP_E = SLOPE_STEEP | SLOPE_SEN, SLOPE_STEEP_N = SLOPE_STEEP | SLOPE_ENW -} Slope; +}; static inline bool IsSteepSlope(Slope s) { diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index a12cac0367..a5b6cfaae8 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -256,10 +256,10 @@ static const uint32 _map_height_bits[16] = { MKCOLOR(0x27272727), }; -typedef struct AndOr { +struct AndOr { uint32 mor; uint32 mand; -} AndOr; +}; static inline uint32 ApplyMask(uint32 colour, const AndOr *mask) { diff --git a/src/sound.h b/src/sound.h index 3dd4e7accd..5826ab19f8 100644 --- a/src/sound.h +++ b/src/sound.h @@ -5,7 +5,7 @@ #include "helpers.hpp" -typedef struct MusicFileSettings { +struct MusicFileSettings { byte playlist; byte music_vol; byte effect_vol; @@ -14,11 +14,11 @@ typedef struct MusicFileSettings { bool playing; bool shuffle; char extmidi[80]; -} MusicFileSettings; +}; VARDEF MusicFileSettings msf; -typedef struct FileEntry { +struct FileEntry { uint32 file_offset; uint32 file_size; uint16 rate; @@ -26,12 +26,12 @@ typedef struct FileEntry { uint8 channels; uint8 volume; uint8 priority; -} FileEntry; +}; bool SoundInitialize(const char *filename); uint GetNumOriginalSounds(); -typedef enum SoundFx { +enum SoundFx { SND_BEGIN = 0, SND_02_SPLAT = 0, // 0 == 0x00 ! SND_03_FACTORY_WHISTLE, @@ -107,7 +107,7 @@ typedef enum SoundFx { SND_47_MAGLEV_2, SND_48_DISTANT_BIRD, // 72 == 0x48 SND_END -} SoundFx; +}; /** Define basic enum properties */ template <> struct EnumPropsT : MakeEnumPropsT {}; diff --git a/src/sprite.h b/src/sprite.h index ceaf8a7145..91b108d34d 100644 --- a/src/sprite.h +++ b/src/sprite.h @@ -8,7 +8,7 @@ * bounding box. Used especially for various multi-sprite buildings (like * depots or stations): */ -typedef struct DrawTileSeqStruct { +struct DrawTileSeqStruct { int8 delta_x; // 0x80 is sequence terminator int8 delta_y; int8 delta_z; @@ -17,19 +17,19 @@ typedef struct DrawTileSeqStruct { byte size_z; SpriteID image; SpriteID pal; -} DrawTileSeqStruct; +}; -typedef struct DrawTileSprites { +struct DrawTileSprites { SpriteID ground_sprite; SpriteID ground_pal; const DrawTileSeqStruct* seq; -} DrawTileSprites; +}; /** * This structure is the same for both Industries and Houses. * Buildings here reference a general type of construction */ -typedef struct DrawBuildingsTileStruct { +struct DrawBuildingsTileStruct { PalSpriteID ground; PalSpriteID building; byte subtile_x:4; @@ -38,7 +38,7 @@ typedef struct DrawBuildingsTileStruct { byte height:4; byte dz; byte draw_proc; /* this allows to specify a special drawing procedure.*/ -} DrawBuildingsTileStruct; +}; // Iterate through all DrawTileSeqStructs in DrawTileSprites. #define foreach_draw_tile_seq(idx, list) for (idx = list; ((byte) idx->delta_x) != 0x80; idx++) diff --git a/src/spritecache.cpp b/src/spritecache.cpp index 561dbc3c1c..c06d7aa9e2 100644 --- a/src/spritecache.cpp +++ b/src/spritecache.cpp @@ -15,11 +15,11 @@ #endif /* SPRITE_CACHE_SIZE */ -typedef struct SpriteCache { +struct SpriteCache { void *ptr; uint32 file_pos; int16 lru; -} SpriteCache; +}; static uint _spritecache_items = 0; @@ -55,10 +55,10 @@ static SpriteCache *AllocateSpriteCache(uint index) } -typedef struct MemBlock { +struct MemBlock { uint32 size; byte data[VARARRAY_SIZE]; -} MemBlock; +}; static uint _sprite_lru_counter; static MemBlock *_spritecache_ptr; diff --git a/src/spritecache.h b/src/spritecache.h index f44656b017..8fe9772a9c 100644 --- a/src/spritecache.h +++ b/src/spritecache.h @@ -3,14 +3,14 @@ #ifndef SPRITECACHE_H #define SPRITECACHE_H -typedef struct Sprite { +struct Sprite { byte info; byte height; uint16 width; int16 x_offs; int16 y_offs; byte data[VARARRAY_SIZE]; -} Sprite; +}; const void *GetRawSprite(SpriteID sprite); bool SpriteExists(SpriteID sprite); diff --git a/src/station.h b/src/station.h index bf61a448b9..bced6a2be9 100644 --- a/src/station.h +++ b/src/station.h @@ -12,7 +12,7 @@ static const StationID INVALID_STATION = 0xFFFF; -typedef struct GoodsEntry { +struct GoodsEntry { GoodsEntry() : waiting_acceptance(0), unload_pending(0), @@ -35,7 +35,7 @@ typedef struct GoodsEntry { byte last_speed; byte last_age; int32 feeder_profit; -} GoodsEntry; +}; /** A Stop for a Road Vehicle */ struct RoadStop { @@ -79,11 +79,11 @@ protected: static RoadStop *AllocateRaw(); }; -typedef struct StationSpecList { +struct StationSpecList { const StationSpec *spec; uint32 grfid; /// GRF ID of this custom station uint8 localidx; /// Station ID within GRF of station -} StationSpecList; +}; /** StationRect - used to track station spread out rectangle - cheaper than scanning whole map */ struct StationRect : public Rect { @@ -207,13 +207,13 @@ enum { HVOT_BUOY = 1 << 6 }; -typedef enum CatchmentAreas { +enum CatchmentArea { CA_NONE = 0, CA_BUS = 3, CA_TRUCK = 3, CA_TRAIN = 4, CA_DOCK = 5 -} CatchmentArea; +}; void ModifyStationRatingAround(TileIndex tile, PlayerID owner, int amount, uint radius); diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 6b559ecf50..72be450e0c 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -449,12 +449,12 @@ void GetAcceptanceAroundTiles(AcceptedCargo accepts, TileIndex tile, } } -typedef struct ottd_Rectangle { +struct ottd_Rectangle { uint min_x; uint min_y; uint max_x; uint max_y; -} ottd_Rectangle; +}; static inline void MergePoint(ottd_Rectangle* rect, TileIndex tile) { @@ -2071,11 +2071,11 @@ static void TileLoop_Station(TileIndex tile) static void AnimateTile_Station(TileIndex tile) { - typedef struct AnimData { + struct AnimData { StationGfx from; // first sprite StationGfx to; // last sprite byte delay; - } AnimData; + }; static const AnimData data[] = { { GFX_RADAR_LARGE_FIRST, GFX_RADAR_LARGE_LAST, 3 }, diff --git a/src/station_gui.cpp b/src/station_gui.cpp index 8e2deb0e33..38e99f718a 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -153,21 +153,21 @@ static int CDECL StationRatingMaxSorter(const void *a, const void *b) return (_internal_sort_order & 1) ? maxr2 - maxr1 : maxr1 - maxr2; } -typedef enum StationListFlags { +enum StationListFlags { SL_ORDER = 0x01, SL_RESORT = 0x02, SL_REBUILD = 0x04, -} StationListFlags; +}; DECLARE_ENUM_AS_BIT_SET(StationListFlags); -typedef struct plstations_d { +struct plstations_d { const Station** sort_list; uint16 list_length; byte sort_type; StationListFlags flags; uint16 resort_timer; //was byte refresh_counter; -} plstations_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(plstations_d)); void RebuildStationLists() diff --git a/src/station_map.h b/src/station_map.h index f71fd217a6..527a0e5e1c 100644 --- a/src/station_map.h +++ b/src/station_map.h @@ -58,16 +58,16 @@ enum { BUS_SIZE_EXT = GFX_BASE_END - GFX_BUS_BASE_EXT, }; -typedef enum HangarTiles { +enum HangarTile { HANGAR_TILE_0 = 32, HANGAR_TILE_1 = 65, HANGAR_TILE_2 = 86, HANGAR_TILE_3 = 129, // added for west facing hangar HANGAR_TILE_4 = 130, // added for north facing hangar HANGAR_TILE_5 = 131 // added for east facing hangar -} HangarTiles; +}; -typedef enum StationType { +enum StationType { STATION_RAIL, STATION_AIRPORT, STATION_TRUCK, @@ -75,7 +75,7 @@ typedef enum StationType { STATION_OILRIG, STATION_DOCK, STATION_BUOY -} StationType; +}; StationType GetStationType(TileIndex); diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp index 86e964c801..f6193f0c99 100644 --- a/src/strgen/strgen.cpp +++ b/src/strgen/strgen.cpp @@ -31,7 +31,7 @@ typedef void (*ParseCmdProc)(char *buf, int value); -typedef struct LanguagePackHeader { +struct LanguagePackHeader { uint32 ident; uint32 version; // 32-bits of auto generated version info which is basically a hash of strings.h char name[32]; // the international name of this language @@ -40,15 +40,15 @@ typedef struct LanguagePackHeader { uint16 offsets[32]; // the offsets byte plural_form; // plural form index byte pad[3]; // pad header to be a multiple of 4 -} LanguagePackHeader; +}; -typedef struct CmdStruct { +struct CmdStruct { const char *cmd; ParseCmdProc proc; long value; int8 consumes; byte flags; -} CmdStruct; +}; enum { C_DONTCOUNT = 1, @@ -56,11 +56,11 @@ enum { }; -typedef struct Case { +struct Case { int caseidx; char *string; - struct Case *next; -} Case; + Case *next; +}; static bool _masterlang; static bool _translated; @@ -68,7 +68,7 @@ static const char* _file = "(unknown file)"; static int _cur_line; static int _errors, _warnings; -typedef struct LangString { +struct LangString { char *name; // Name of the string char *english; // English text char *translated; // Translated text @@ -77,7 +77,7 @@ typedef struct LangString { int line; // line of string in source-file Case *english_case; // cases for english Case *translated_case; // cases for foreign -} LangString; +}; static LangString *_strings[65536]; @@ -106,16 +106,16 @@ static const byte _plural_form_counts[] = { 2, 1, 2, 3, 3, 3, 3, 3, 4 }; static const char *_cur_ident; -typedef struct CmdPair { +struct CmdPair { const CmdStruct *a; const char *v; -} CmdPair; +}; -typedef struct ParsedCommandStruct { +struct ParsedCommandStruct { int np; CmdPair pairs[32]; const CmdStruct *cmd[32]; // ordered by param # -} ParsedCommandStruct; +}; // Used when generating some advanced commands. static ParsedCommandStruct _cur_pcs; diff --git a/src/string.h b/src/string.h index eba7eff631..2170a30f93 100644 --- a/src/string.h +++ b/src/string.h @@ -37,11 +37,11 @@ void str_strip_colours(char *str); /** * Valid filter types for IsValidChar. */ -typedef enum CharSetFilter { +enum CharSetFilter { CS_ALPHANUMERAL, //! Both numeric and alphabetic and spaces and stuff CS_NUMERAL, //! Only numeric ones CS_ALPHA, //! Only alphabetic values -} CharSetFilter; +}; /** Convert the given string to lowercase, only works with ASCII! */ void strtolower(char *str); diff --git a/src/strings.cpp b/src/strings.cpp index e18dfbe357..0dd6fcad80 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -35,7 +35,7 @@ static char *GetSpecialPlayerNameString(char *buff, int ind, const int32 *argv, static char *FormatString(char *buff, const char *str, const int32 *argv, uint casei, const char* last); -typedef struct LanguagePack { +struct LanguagePack { uint32 ident; uint32 version; // 32-bits of auto generated version info which is basically a hash of strings.h char name[32]; // the international name of this language @@ -45,7 +45,7 @@ typedef struct LanguagePack { byte plural_form; // how to compute plural forms byte pad[3]; // pad header to be a multiple of 4 char data[VARARRAY_SIZE]; -} LanguagePack; +}; static char **_langpack_offs; static LanguagePack *_langpack; @@ -461,7 +461,7 @@ static const char *ParseStringChoice(const char *b, uint form, char *dst, int *d return b + pos; } -typedef struct Units { +struct Units { int s_m; ///< Multiplier for velocity int s_s; ///< Shift for velocity StringID velocity; ///< String for velocity @@ -479,7 +479,7 @@ typedef struct Units { int f_m; ///< Multiplier for force int f_s; ///< Shift for force StringID force; ///< String for force -} Units; +}; /* Unit conversions */ static const Units units[] = { diff --git a/src/table/ai_rail.h b/src/table/ai_rail.h index 218f33f3d4..bbb094728d 100644 --- a/src/table/ai_rail.h +++ b/src/table/ai_rail.h @@ -1,24 +1,24 @@ /* $Id$ */ -typedef struct { +struct AiDefaultBlockData { byte mode; byte attr; TileIndexDiffC tileoffs; -} AiDefaultBlockData; +}; -typedef struct { +struct AiDefaultRailBlock { byte p0; byte p1; byte p2; byte p3; byte dir; const AiDefaultBlockData *data; -} AiDefaultRailBlock; +}; -typedef struct { +struct AiDefaultRoadBlock { byte dir; const AiDefaultBlockData *data; -} AiDefaultRoadBlock; +}; #define MKHDR(a,b,c,d,e) a,b,c,d,e, diff --git a/src/table/build_industry.h b/src/table/build_industry.h index a292a1cf4a..7290139737 100644 --- a/src/table/build_industry.h +++ b/src/table/build_industry.h @@ -1068,7 +1068,7 @@ static const IndustryTileTable * const _tile_table_sugar_mine[] = { /* Procedures that can be run to check whether an industry may * build at location the given to the procedure */ -typedef enum CheckProcs { +enum CheckProc { CHECK_NOTHING = 0, CHECK_FOREST = 1, CHECK_REFINERY = 2, @@ -1079,7 +1079,7 @@ typedef enum CheckProcs { CHECK_BUBBLEGEN = 7, CHECK_OIL_RIG = 8, CHECK_END, -} CheckProc; +}; #define MK(tbl, d, c1, c2, c3, proc, p1, r1, p2, r2, m, a1, a2, a3, pr, clim, in, s1, s2, s3) \ {tbl, lengthof(tbl), d, {c1, c2, c3}, proc, {p1, p2}, {r1, r2}, m, \ diff --git a/src/table/elrail_data.h b/src/table/elrail_data.h index 1ed5751b42..003da906dc 100644 --- a/src/table/elrail_data.h +++ b/src/table/elrail_data.h @@ -7,23 +7,23 @@ /** Tile Location group. * This defines whether the X and or Y coordinate of a tile is even */ -typedef enum TLG { +enum TLG { XEVEN_YEVEN = 0, XEVEN_YODD = 1, XODD_YEVEN = 2, XODD_YODD = 3, TLG_END -} TLG; +}; /** When determining the pylon configuration on the edge, two tiles are taken * into account: the tile being drawn itself (the home tile, the one in * ti->tile), and the neighbouring tile */ -typedef enum { +enum TileSource { TS_HOME = 0, TS_NEIGHBOUR = 1, TS_END -} TileSource; +}; enum { NUM_TRACKS_AT_PCP = 6 @@ -253,7 +253,7 @@ static const SpriteID pylons_bridge[] = { SPR_PYLON_Y_SW }; -typedef struct { +struct SortableSpriteStruct { SpriteID image; int8 x_offset; int8 y_offset; @@ -261,7 +261,7 @@ typedef struct { int8 y_size; int8 z_size; int8 z_offset; -} SortableSpriteStruct; +}; enum { /** Distance between wire and rail */ @@ -351,7 +351,7 @@ static const SortableSpriteStruct CatenarySpriteData_Depot[] = { *
  • Position of the Pylon relative to the track
  • *
  • Position of the Pylon inside the tile
  • */ -typedef enum { +enum CatenarySprite { WIRE_X_FLAT_SW, WIRE_X_FLAT_NE, WIRE_X_FLAT_BOTH, @@ -395,7 +395,7 @@ typedef enum { WIRE_EW_S_E, INVALID_CATENARY = 0xFF -} CatenarySprite; +}; /* Selects a Wire (with white and grey ends) depending on whether: * a) none (should never happen) diff --git a/src/table/industry_land.h b/src/table/industry_land.h index cb8174fa20..b98d9060c6 100644 --- a/src/table/industry_land.h +++ b/src/table/industry_land.h @@ -1,17 +1,17 @@ /* $Id$ */ -typedef struct DrawIndustrySpec1Struct { +struct DrawIndustrySpec1Struct { byte x; byte image_1; byte image_2; byte image_3; -} DrawIndustrySpec1Struct; +}; -typedef struct DrawIndustrySpec4Struct { +struct DrawIndustrySpec4Struct { byte image_1; byte image_2; byte image_3; -} DrawIndustrySpec4Struct; +}; #define M(s1, p1, s2, p2, sx, sy, w, h, dz, p) { { s1, p1 }, { s2, p2 }, sx, sy, w - 1, h - 1, dz, p } diff --git a/src/table/namegen.h b/src/table/namegen.h index 6dea4008ff..99845c8b0f 100644 --- a/src/table/namegen.h +++ b/src/table/namegen.h @@ -1690,7 +1690,7 @@ static const char *name_czech_real[] = { * with cloning this for your own language. */ // Sing., pl. -typedef enum CzechGender { +enum CzechGender { CZG_SMASC, CZG_SFEM, CZG_SNEUT, @@ -1701,12 +1701,14 @@ typedef enum CzechGender { CZG_FREE, // Like CZG_FREE, but disallow CZG_SNEUT. CZG_NFREE -} CzechGender; -typedef enum CzechPattern { +}; + +enum CzechPattern { CZP_JARNI, CZP_MLADY, CZP_PRIVL -} CzechPattern; +}; + /* [CzechGender][CzechPattern] - replaces the last character of the adjective * by this. */ // XXX: [CZG_SMASC][CZP_PRIVL] needs special handling: -ovX -> -uv. @@ -1721,38 +1723,38 @@ static const char *name_czech_patmod[][3] = { // This way the substantives can choose only some adjectives/endings: // At least one of these flags must be satisfied: -typedef enum CzechAllow { +enum CzechAllow { CZA_SHORT = 1, CZA_MIDDLE = 2, CZA_LONG = 4, CZA_ALL = ~0 -} CzechAllow; +}; DECLARE_ENUM_AS_BIT_SET(CzechAllow); // All these flags must be satisfied (in the stem->others direction): -typedef enum CzechChoose { +enum CzechChoose { CZC_NONE = 0, // No requirements. CZC_COLOR = 1, CZC_POSTFIX = 2, // Matched if postfix was inserted. CZC_NOPOSTFIX = 4, // Matched if no postfix was inserted. CZC_ANY = ~0 -} CzechChoose; +}; DECLARE_ENUM_AS_BIT_SET(CzechChoose); -typedef struct CzechNameSubst { +struct CzechNameSubst { CzechGender gender; CzechAllow allow; CzechChoose choose; const char *name; -} CzechNameSubst; +}; -typedef struct CzechNameAdj { +struct CzechNameAdj { CzechPattern pattern; CzechChoose choose; const char *name; -} CzechNameAdj; +}; // Some of items which should be common are doubled. static const CzechNameAdj name_czech_adj[] = { diff --git a/src/table/palettes.h b/src/table/palettes.h index fc931c7c26..dd69085c76 100644 --- a/src/table/palettes.h +++ b/src/table/palettes.h @@ -141,7 +141,7 @@ static const Colour _palettes[][256] = { #define GET_PALETTE(x) _palettes[x] -typedef struct { +struct ExtraPaletteValues { Colour a[15]; // dark blue water Colour ac[15]; // dark blue water Toyland Colour lighthouse[12]; // lighthouse & stadium @@ -149,7 +149,7 @@ typedef struct { Colour e[15]; // ??? Colour b[45]; // glittery water Colour bc[45]; // glittery water Toyland -} ExtraPaletteValues; +}; static const ExtraPaletteValues _extra_palette_values = { { M( 32, 68, 112), M( 36, 72, 116), M( 40, 76, 120), M( 44, 80, 124), @@ -173,10 +173,10 @@ static const ExtraPaletteValues _extra_palette_values = { #undef M // Color table for colors in lang files (e.g. {BLACK}) -typedef struct StringColor { +struct StringColor { byte text; byte shadow; -} StringColor; +}; static const StringColor _string_colormap[] = { { 150, 215 }, // BLUE diff --git a/src/table/sprites.h b/src/table/sprites.h index 014d031300..1ea4f71cf6 100644 --- a/src/table/sprites.h +++ b/src/table/sprites.h @@ -1191,7 +1191,7 @@ enum Sprites { }; /** Cursor sprite numbers */ -typedef enum CursorSprites { +enum CursorSprite { /* Terraform */ /* Cursors */ SPR_CURSOR_MOUSE = 0, @@ -1278,7 +1278,7 @@ typedef enum CursorSprites { SPR_CURSOR_CLONE_ROADVEH = SPR_OPENTTD_BASE + 110, SPR_CURSOR_CLONE_SHIP = SPR_OPENTTD_BASE + 112, SPR_CURSOR_CLONE_AIRPLANE = SPR_OPENTTD_BASE + 114, -} CursorSprite; +}; /// Animation macro in table/animcursors.h (_animcursors[]) enum AnimCursors { diff --git a/src/table/town_land.h b/src/table/town_land.h index caf2b3b2aa..091b8926a6 100644 --- a/src/table/town_land.h +++ b/src/table/town_land.h @@ -2017,9 +2017,9 @@ static const uint16 _housetype_remove_ratingmod[] = { assert_compile(lengthof(_housetype_remove_ratingmod) == HOUSE_MAX); -typedef struct { +struct HousetypeYear { Year min, max; -} HousetypeYear; +}; static const HousetypeYear _housetype_years[] = { { 1963, MAX_YEAR }, diff --git a/src/table/tree_land.h b/src/table/tree_land.h index de9e69e677..2d039de144 100644 --- a/src/table/tree_land.h +++ b/src/table/tree_land.h @@ -13,10 +13,10 @@ static const SpriteID _tree_sprites_1[] = { static const byte _tree_base_by_landscape[4] = {0, 12, 20, 32}; static const byte _tree_count_by_landscape[4] = {12, 8, 12, 9}; -typedef struct TreePos { +struct TreePos { uint8 x; uint8 y; -} TreePos; +}; static const TreePos _tree_layout_xy[][4] = { { { 9, 3 }, { 1, 8 }, { 0, 0 }, { 8, 9 } }, diff --git a/src/table/unicode.h b/src/table/unicode.h index 2bbd6624c8..e94340d553 100644 --- a/src/table/unicode.h +++ b/src/table/unicode.h @@ -1,10 +1,10 @@ /* $Id$ */ -typedef struct DefaultUnicodeMapping { +struct DefaultUnicodeMapping { WChar code; ///< Unicode value byte key; ///< Character index of sprite -} DefaultUnicodeMapping; +}; /* Default unicode mapping table for sprite based glyphs. diff --git a/src/table/unmovable_land.h b/src/table/unmovable_land.h index 9b9f004a70..78585d5a79 100644 --- a/src/table/unmovable_land.h +++ b/src/table/unmovable_land.h @@ -1,6 +1,6 @@ /* $Id$ */ -typedef struct DrawTileUnmovableStruct { +struct DrawTileUnmovableStruct { uint16 image; byte subcoord_x; byte subcoord_y; @@ -8,7 +8,7 @@ typedef struct DrawTileUnmovableStruct { byte height; byte z_size; byte unused; -} DrawTileUnmovableStruct; +}; #define TILE_SEQ_END() { (byte)0x80, 0, 0, 0, 0, 0, 0, 0 } diff --git a/src/table/water_land.h b/src/table/water_land.h index a27eb35104..9562c1d02c 100644 --- a/src/table/water_land.h +++ b/src/table/water_land.h @@ -1,6 +1,6 @@ /* $Id$ */ -typedef struct WaterDrawTileStruct { +struct WaterDrawTileStruct { byte delta_x; byte delta_y; byte delta_z; @@ -8,7 +8,7 @@ typedef struct WaterDrawTileStruct { byte height; byte unk; SpriteID image; -} WaterDrawTileStruct; +}; #define BEGIN(image) { 0, 0, 0, 0, 0, 0, image } #define END(y) { 0x80, y, 0, 0, 0, 0, 0 } diff --git a/src/texteff.cpp b/src/texteff.cpp index ec159be6db..1831dcd764 100644 --- a/src/texteff.cpp +++ b/src/texteff.cpp @@ -23,7 +23,7 @@ enum { MAX_ANIMATED_TILES = 256, }; -typedef struct TextEffect { +struct TextEffect { StringID string_id; int32 x; int32 y; @@ -32,14 +32,14 @@ typedef struct TextEffect { uint16 duration; uint32 params_1; uint32 params_2; -} TextEffect; +}; -typedef struct TextMessage { +struct TextMessage { char message[MAX_TEXTMESSAGE_LENGTH]; uint16 color; Date end_date; -} TextMessage; +}; static TextEffect _text_effect_list[MAX_TEXT_MESSAGES]; static TextMessage _textmsg_list[MAX_CHAT_MESSAGES]; diff --git a/src/tgp.cpp b/src/tgp.cpp index 1b02ce1836..addc3d16fc 100644 --- a/src/tgp.cpp +++ b/src/tgp.cpp @@ -165,14 +165,14 @@ typedef int amplitude_t; static const int amplitude_decimal_bits = 10; /** Height map - allocated array of heights (MapSizeX() + 1) x (MapSizeY() + 1) */ -typedef struct HeightMap +struct HeightMap { height_t *h; //! array of heights uint dim_x; //! height map size_x MapSizeX() + 1 uint total_size; //! height map total size uint size_x; //! MapSizeX() uint size_y; //! MapSizeY() -} HeightMap; +}; /** Global height map instance */ static HeightMap _height_map = {NULL, 0, 0, 0, 0}; diff --git a/src/thread.h b/src/thread.h index 711f78bc4b..1e602bf4ce 100644 --- a/src/thread.h +++ b/src/thread.h @@ -3,7 +3,7 @@ #ifndef THREAD_H #define THREAD_H -typedef struct OTTDThread OTTDThread; +struct OTTDThread; typedef void* (*OTTDThreadFunc)(void*); diff --git a/src/tile.h b/src/tile.h index ac7eb93a77..7894bb5147 100644 --- a/src/tile.h +++ b/src/tile.h @@ -8,7 +8,7 @@ #include "map.h" #include "slope.h" -typedef enum TileTypes { +enum TileType { MP_CLEAR, MP_RAILWAY, MP_STREET, @@ -20,13 +20,13 @@ typedef enum TileTypes { MP_INDUSTRY, MP_TUNNELBRIDGE, MP_UNMOVABLE, -} TileType; +}; -typedef enum TropicZones { +enum TropicZone { TROPICZONE_INVALID = 0, TROPICZONE_DESERT = 1, TROPICZONE_RAINFOREST = 2, -} TropicZone; +}; Slope GetTileSlope(TileIndex tile, uint *h); uint GetTileZ(TileIndex tile); diff --git a/src/train.h b/src/train.h index a1cd9fb361..31282c6192 100644 --- a/src/train.h +++ b/src/train.h @@ -13,14 +13,14 @@ * This is an enum to tell what bit to access as it is a bitmask */ -typedef enum TrainSubtypes { +enum TrainSubtype { Train_Front = 0, // Leading engine of a train Train_Articulated_Part = 1, // Articulated part of an engine Train_Wagon = 2, // Wagon Train_Engine = 3, // Engine, that can be front engines, but might be placed behind another engine Train_Free_Wagon = 4, // First in a wagon chain (in depot) Train_Multiheaded = 5, // Engine is a multiheaded -} TrainSubtype; +}; /** Check if a vehicle is front engine diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 847a567ab6..4938915674 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1822,7 +1822,7 @@ int32 CmdRefitRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) return cost; } -typedef struct TrainFindDepotData { +struct TrainFindDepotData { uint best_length; TileIndex tile; PlayerID owner; @@ -1831,7 +1831,7 @@ typedef struct TrainFindDepotData { * This value is unused when new depot finding and NPF are both disabled */ bool reverse; -} TrainFindDepotData; +}; static bool NtpCallbFindDepot(TileIndex tile, TrainFindDepotData *tfdd, int track, uint length) { @@ -2134,13 +2134,13 @@ static bool CheckTrainStayInDepot(Vehicle *v) } /* Check for station tiles */ -typedef struct TrainTrackFollowerData { +struct TrainTrackFollowerData { TileIndex dest_coords; StationID station_index; // station index we're heading for uint best_bird_dist; uint best_track_dist; TrackdirByte best_track; -} TrainTrackFollowerData; +}; static bool NtpCallbFindStation(TileIndex tile, TrainTrackFollowerData *ttfd, Trackdir track, uint length) { @@ -2712,11 +2712,11 @@ static bool CheckCompatibleRail(const Vehicle *v, TileIndex tile) ); } -typedef struct { +struct RailtypeSlowdownParams { byte small_turn, large_turn; byte z_up; // fraction to remove when moving up byte z_down; // fraction to remove when moving down -} RailtypeSlowdownParams; +}; static const RailtypeSlowdownParams _railtype_slowdown[] = { // normal accel @@ -2768,10 +2768,10 @@ static void TrainMovedChangeSignals(TileIndex tile, DiagDirection dir) } -typedef struct TrainCollideChecker { +struct TrainCollideChecker { const Vehicle *v; const Vehicle *v_skip; -} TrainCollideChecker; +}; static void *FindTrainCollideEnum(Vehicle *v, void *data) { @@ -2861,10 +2861,10 @@ static void CheckTrainCollision(Vehicle *v) SndPlayVehicleFx(SND_13_BIG_CRASH, v); } -typedef struct VehicleAtSignalData { +struct VehicleAtSignalData { TileIndex tile; Direction direction; -} VehicleAtSignalData; +}; static void *CheckVehicleAtSignal(Vehicle *v, void *data) { diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index 5344c70d1d..ca1af6788e 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -310,11 +310,11 @@ int32 CmdPlantTree(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) } } -typedef struct TreeListEnt { +struct TreeListEnt { SpriteID image; SpriteID pal; byte x,y; -} TreeListEnt; +}; static void DrawTile_Trees(TileInfo *ti) { diff --git a/src/tree_map.h b/src/tree_map.h index 47da5eb25c..e3a56272a0 100644 --- a/src/tree_map.h +++ b/src/tree_map.h @@ -5,7 +5,7 @@ #include "macros.h" -typedef enum TreeType { +enum TreeType { TREE_INVALID = -1, TREE_TEMPERATE = 0, TREE_SUB_ARCTIC = 12, @@ -13,7 +13,7 @@ typedef enum TreeType { TREE_CACTUS = 27, TREE_SUB_TROPICAL = 28, TREE_TOYLAND = 32 -} TreeType; +}; enum { TREE_COUNT_TEMPERATE = TREE_SUB_ARCTIC - TREE_TEMPERATE, @@ -25,11 +25,11 @@ enum { /* ground type, m2 bits 4...5 * valid densities (bits 6...7) in comments after the enum */ -typedef enum TreeGround { +enum TreeGround { TREE_GROUND_GRASS = 0, // 0 TREE_GROUND_ROUGH = 1, // 0 TREE_GROUND_SNOW_DESERT = 2 // 0-3 for snow, 3 for desert -} TreeGround; +}; static inline TreeType GetTreeType(TileIndex t) diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index 4b7e49f3cd..da6105d8b0 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -77,7 +77,7 @@ int CalcBridgeLenCostFactor(int x) } #define M(x) (1 << (x)) -typedef enum BridgeFoundations{ +enum BridgeFoundation { // foundation, whole tile is leveled up --> 3 corners raised BRIDGE_FULL_LEVELED_FOUNDATION = M(SLOPE_WSE) | M(SLOPE_NWS) | M(SLOPE_ENW) | M(SLOPE_SEN), // foundation, tile is partly leveled up --> 1 corner raised @@ -85,7 +85,7 @@ typedef enum BridgeFoundations{ // no foundations (X,Y direction) BRIDGE_NO_FOUNDATION = M(SLOPE_FLAT) | M(SLOPE_SW) | M(SLOPE_SE) | M(SLOPE_NW) | M(SLOPE_NE), BRIDGE_HORZ_RAMP = (BRIDGE_PARTLY_LEVELED_FOUNDATION | BRIDGE_NO_FOUNDATION) & ~M(SLOPE_FLAT) -} BridgeFoundataion; +}; #undef M static inline const PalSpriteID *GetBridgeSpriteTable(int index, byte table) diff --git a/src/unmovable_map.h b/src/unmovable_map.h index 2e9ecfb9d8..b31c932e95 100644 --- a/src/unmovable_map.h +++ b/src/unmovable_map.h @@ -8,7 +8,7 @@ enum { HQ_NUM_SIZE = 5 }; -typedef enum UnmovableType { +enum UnmovableType { UNMOVABLE_TRANSMITTER = 0, UNMOVABLE_LIGHTHOUSE = 1, UNMOVABLE_STATUE = 2, @@ -19,7 +19,7 @@ typedef enum UnmovableType { UNMOVABLE_HQ_SOUTH = 0x83, UNMOVABLE_HQ_END = UNMOVABLE_HQ_NORTH + HQ_NUM_SIZE * HQ_NUM_TILE -} UnmovableType; +}; diff --git a/src/variables.h b/src/variables.h index 37da4c4fca..4607947d13 100644 --- a/src/variables.h +++ b/src/variables.h @@ -19,7 +19,7 @@ VARDEF uint16 _price_frac[NUM_PRICES]; VARDEF uint32 _cargo_payment_rates[NUM_CARGO]; VARDEF uint16 _cargo_payment_rates_frac[NUM_CARGO]; -typedef struct { +struct GameOptions { GameDifficulty diff; byte diff_level; byte currency; @@ -29,7 +29,7 @@ typedef struct { byte snow_line; byte autosave; byte road_side; -} GameOptions; +}; /* These are the options for the current game * either ingame, or loaded. Also used for networking games */ @@ -80,7 +80,7 @@ VARDEF byte _saved_scrollpos_zoom; // ********* END OF SAVE REGION -typedef struct Patches { +struct Patches { bool modified_catchment; // different-size catchment areas bool vehicle_speed; // show vehicle speed bool build_on_slopes; // allow building on slopes @@ -221,22 +221,22 @@ typedef struct Patches { /** YAPF settings */ YapfSettings yapf; -} Patches; +}; VARDEF Patches _patches; -typedef struct Cheat { +struct Cheat { bool been_used; // has this cheat been used before? bool value; // tells if the bool cheat is active or not -} Cheat; +}; // WARNING! Do _not_ remove entries in Cheats struct or change the order // of the existing ones! Would break downward compatibility. // Only add new entries at the end of the struct! -typedef struct Cheats { +struct Cheats { Cheat magic_bulldozer; // dynamite industries, unmovables Cheat switch_player; // change to another player Cheat money; // get rich @@ -247,11 +247,11 @@ typedef struct Cheats { Cheat change_date; // changes date ingame Cheat setup_prod; // setup raw-material production in game Cheat dummy; // empty cheat (enable running el-engines on normal rail) -} Cheats; +}; VARDEF Cheats _cheats; -typedef struct Paths { +struct Paths { char *personal_dir; // includes cfg file and save folder char *game_data_dir; // includes data, gm, lang char *data_dir; @@ -262,7 +262,7 @@ typedef struct Paths { char *scenario_dir; char *heightmap_dir; char *second_data_dir; -} Paths; +}; VARDEF Paths _paths; @@ -296,11 +296,11 @@ VARDEF TileIndex _build_tunnel_endtile; VARDEF bool _generating_world; // Deals with the type of the savegame, independent of extension -typedef struct { +struct SmallFiosItem { int mode; // savegame/scenario type (old, new) char name[MAX_PATH]; // name char title[255]; // internal name of the game -} SmallFiosItem; +}; // Used when switching from the intro menu. VARDEF byte _switch_mode; @@ -314,7 +314,7 @@ VARDEF Vehicle *_place_clicked_vehicle; VARDEF char _ini_videodriver[32], _ini_musicdriver[32], _ini_sounddriver[32]; // Used for dynamic language support -typedef struct { +struct DynamicLanguages { int num; // number of languages int curr; // currently selected language index char curr_file[MAX_LANG]; // currently selected language file @@ -323,7 +323,7 @@ typedef struct { char *name; char *file; } ent[MAX_LANG]; -} DynamicLanguages; +}; VARDEF DynamicLanguages _dynlang; diff --git a/src/vehicle.cpp b/src/vehicle.cpp index d050d32a1f..ec1f7b74b9 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1098,11 +1098,11 @@ static void BulldozerInit(Vehicle *v) v->u.special.unk2 = 0; } -typedef struct BulldozerMovement { +struct BulldozerMovement { byte direction:2; byte image:2; byte duration:3; -} BulldozerMovement; +}; static const BulldozerMovement _bulldozer_movement[] = { { 0, 0, 4 }, @@ -1172,12 +1172,12 @@ static void BubbleInit(Vehicle *v) v->progress = 0; } -typedef struct BubbleMovement { +struct BubbleMovement { int8 x:4; int8 y:4; int8 z:4; byte image:4; -} BubbleMovement; +}; #define MK(x, y, z, i) { x, y, z, i } #define ME(i) { i, 4, 0, 0 } diff --git a/src/vehicle.h b/src/vehicle.h index 1f697ad0c2..790343a8b6 100644 --- a/src/vehicle.h +++ b/src/vehicle.h @@ -90,7 +90,7 @@ enum VehicleFlags { }; /* Effect vehicle types */ -typedef enum EffectVehicle { +enum EffectVehicle { EV_CHIMNEY_SMOKE = 0, EV_STEAM_SMOKE = 1, EV_DIESEL_SMOKE = 2, @@ -101,9 +101,9 @@ typedef enum EffectVehicle { EV_EXPLOSION_SMALL = 7, EV_BULLDOZER = 8, EV_BUBBLE = 9 -} EffectVehicle; +}; -typedef struct VehicleRail { +struct VehicleRail { uint16 last_speed; // NOSAVE: only used in UI uint16 crash_anim_pos; uint16 days_since_order_progr; @@ -140,7 +140,7 @@ typedef struct VehicleRail { // Link between the two ends of a multiheaded engine Vehicle *other_multiheaded_part; -} VehicleRail; +}; enum { VRF_REVERSING = 0, @@ -162,15 +162,15 @@ enum { VRF_EL_ENGINE_ALLOWED_NORMAL_RAIL = 6, }; -typedef struct VehicleAir { +struct VehicleAir { uint16 crashed_counter; byte pos; byte previous_pos; StationID targetairport; byte state; -} VehicleAir; +}; -typedef struct VehicleRoad { +struct VehicleRoad { byte state; /// @see RoadVehicleStates byte frame; uint16 blocked_ctr; @@ -180,21 +180,21 @@ typedef struct VehicleRoad { byte reverse_ctr; struct RoadStop *slot; byte slot_age; -} VehicleRoad; +}; -typedef struct VehicleSpecial { +struct VehicleSpecial { uint16 unk0; byte unk2; -} VehicleSpecial; +}; -typedef struct VehicleDisaster { +struct VehicleDisaster { uint16 image_override; uint16 unk2; -} VehicleDisaster; +}; -typedef struct VehicleShip { +struct VehicleShip { TrackBitsByte state; -} VehicleShip; +}; struct Vehicle { @@ -409,11 +409,11 @@ enum { DEPOT_LOCATE_HANGAR = (1 << 3), // Find another airport if the target one lacks a hangar }; -typedef struct GetNewVehiclePosResult { +struct GetNewVehiclePosResult { int x,y; TileIndex old_tile; TileIndex new_tile; -} GetNewVehiclePosResult; +}; /** * Returns the Trackdir on which the vehicle is currently located. diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index ba6ef419ad..c4f5a66f37 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -30,22 +30,22 @@ #include "helpers.hpp" #include "cargotype.h" -typedef struct Sorting { +struct Sorting { Listing aircraft; Listing roadveh; Listing ship; Listing train; -} Sorting; +}; static Sorting _sorting; -typedef struct vehiclelist_d { +struct vehiclelist_d { const Vehicle** sort_list; // List of vehicles (sorted) Listing *_sorting; // pointer to the appropiate subcategory of _sorting uint16 length_of_sort_list; // Keeps track of how many vehicle pointers sort list got space for byte vehicle_type; // The vehicle type that is sorted list_d l; // General list struct -} vehiclelist_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vehiclelist_d)); static bool _internal_sort_order; // descending/ascending @@ -180,17 +180,17 @@ void DrawVehicleProfitButton(const Vehicle *v, int x, int y) DrawSprite(SPR_BLOT, pal, x, y); } -typedef struct RefitOption { +struct RefitOption { CargoID cargo; byte subtype; uint16 value; EngineID engine; -} RefitOption; +}; -typedef struct RefitList { +struct RefitList { uint num_lines; RefitOption *items; -} RefitList; +}; static RefitList *BuildRefitList(const Vehicle *v) { diff --git a/src/video/cocoa_v.mm b/src/video/cocoa_v.mm index 698f48e428..e7531edbf4 100644 --- a/src/video/cocoa_v.mm +++ b/src/video/cocoa_v.mm @@ -31,10 +31,10 @@ /* Portions of CPS.h */ -typedef struct CPSProcessSerNum { +struct CPSProcessSerNum { UInt32 lo; UInt32 hi; -} CPSProcessSerNum; +}; extern "C" OSErr CPSGetCurrentProcess(CPSProcessSerNum* psn); extern "C" OSErr CPSEnableForegroundOperation(CPSProcessSerNum* psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5); @@ -103,11 +103,11 @@ extern bool _dbg_screen_rect; */ #define QZ_GAMMA_TABLE_SIZE 256 -typedef struct { +struct OTTD_QuartzGammaTable { CGGammaValue red[QZ_GAMMA_TABLE_SIZE]; CGGammaValue green[QZ_GAMMA_TABLE_SIZE]; CGGammaValue blue[QZ_GAMMA_TABLE_SIZE]; -} OTTD_QuartzGammaTable; +}; /* Add methods to get at private members of NSScreen. * Since there is a bug in Apple's screen switching code that does not update @@ -210,10 +210,10 @@ static void QZ_CheckPaletteAnim() -typedef struct VkMapping { +struct VkMapping { unsigned short vk_from; byte map_to; -} VkMapping; +}; #define AS(x, z) {x, z} diff --git a/src/video/sdl_v.cpp b/src/video/sdl_v.cpp index 226c54c636..668d993b48 100644 --- a/src/video/sdl_v.cpp +++ b/src/video/sdl_v.cpp @@ -209,11 +209,11 @@ static bool CreateMainSurface(int w, int h) return true; } -typedef struct VkMapping { +struct VkMapping { uint16 vk_from; byte vk_count; byte map_to; -} VkMapping; +}; #define AS(x, z) {x, 0, z} #define AM(x, y, z, w) {x, y - x, z} diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index e8111dc8b8..4e9f43236f 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -73,11 +73,11 @@ static void UpdatePalette(HDC dc, uint start, uint count) SetDIBColorTable(dc, start, count, rgb); } -typedef struct { +struct VkMapping { byte vk_from; byte vk_count; byte map_to; -} VkMapping; +}; #define AS(x, z) {x, 0, z} #define AM(x, y, z, w) {x, y - x, z} diff --git a/src/viewport.cpp b/src/viewport.cpp index 2855c112df..ab3e087b40 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -47,34 +47,34 @@ static bool _offset_ground_sprites; * X < > Y * */ -typedef struct StringSpriteToDraw { +struct StringSpriteToDraw { uint16 string; uint16 color; - struct StringSpriteToDraw *next; + StringSpriteToDraw *next; int32 x; int32 y; uint32 params[2]; uint16 width; -} StringSpriteToDraw; +}; -typedef struct TileSpriteToDraw { +struct TileSpriteToDraw { SpriteID image; SpriteID pal; - struct TileSpriteToDraw *next; + TileSpriteToDraw *next; int32 x; int32 y; byte z; -} TileSpriteToDraw; +}; -typedef struct ChildScreenSpriteToDraw { +struct ChildScreenSpriteToDraw { SpriteID image; SpriteID pal; int32 x; int32 y; - struct ChildScreenSpriteToDraw *next; -} ChildScreenSpriteToDraw; + ChildScreenSpriteToDraw *next; +}; -typedef struct ParentSpriteToDraw { +struct ParentSpriteToDraw { SpriteID image; SpriteID pal; int32 left; @@ -89,13 +89,13 @@ typedef struct ParentSpriteToDraw { byte unk16; byte zmin; byte zmax; -} ParentSpriteToDraw; +}; // Quick hack to know how much memory to reserve when allocating from the spritelist // to prevent a buffer overflow. #define LARGEST_SPRITELIST_STRUCT ParentSpriteToDraw -typedef struct ViewportDrawer { +struct ViewportDrawer { DrawPixelInfo dpi; byte *spritelist_mem; @@ -112,7 +112,7 @@ typedef struct ViewportDrawer { byte combine_sprites; int offs_x, offs_y; // used when drawing ground sprites relative -} ViewportDrawer; +}; static ViewportDrawer *_cur_vd; diff --git a/src/viewport.h b/src/viewport.h index 62a61370d6..4d19ab6c4a 100644 --- a/src/viewport.h +++ b/src/viewport.h @@ -109,7 +109,7 @@ enum HighLightStyles { HT_DIR_MASK = 0x7 ///< masks the drag-direction }; -typedef struct TileHighlightData { +struct TileHighlightData { Point size; Point outersize; Point pos; @@ -135,7 +135,7 @@ typedef struct TileHighlightData { int userdata; TileIndex redsq; -} TileHighlightData; +}; // common button handler diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index f5df72e4c4..ed4b2d726a 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -401,11 +401,11 @@ void DrawCanalWater(TileIndex tile) } } -typedef struct LocksDrawTileStruct { +struct LocksDrawTileStruct { int8 delta_x, delta_y, delta_z; byte width, height, depth; SpriteID image; -} LocksDrawTileStruct; +}; #include "table/water_land.h" diff --git a/src/water_map.h b/src/water_map.h index 26bd92f2bc..1f769c9aff 100644 --- a/src/water_map.h +++ b/src/water_map.h @@ -3,25 +3,25 @@ #ifndef WATER_MAP_H #define WATER_MAP_H -typedef enum WaterTileType { +enum WaterTileType { WATER_TILE_CLEAR, WATER_TILE_COAST, WATER_TILE_LOCK, WATER_TILE_DEPOT, -} WaterTileType; +}; -typedef enum DepotPart { +enum DepotPart { DEPOT_NORTH = 0x80, DEPOT_SOUTH = 0x81, DEPOT_END = 0x84, -} DepotPart; +}; -typedef enum LockPart { +enum LockPart { LOCK_MIDDLE = 0x10, LOCK_LOWER = 0x14, LOCK_UPPER = 0x18, LOCK_END = 0x1C -} LockPart; +}; static inline WaterTileType GetWaterTileType(TileIndex t) { diff --git a/src/win32.cpp b/src/win32.cpp index 0c0e961391..63f1b26ae9 100644 --- a/src/win32.cpp +++ b/src/win32.cpp @@ -100,11 +100,11 @@ static bool _expanded; static bool _did_emerg_save; static int _ident; -typedef struct DebugFileInfo { +struct DebugFileInfo { uint32 size; uint32 crc32; SYSTEMTIME file_time; -} DebugFileInfo; +}; static uint32 *_crc_table; @@ -230,14 +230,14 @@ static bool EmergencySave() /* Disable the crash-save submit code as it's not used */ #if 0 -typedef struct { +struct WinInetProcs { HINTERNET (WINAPI *InternetOpen)(LPCTSTR,DWORD, LPCTSTR, LPCTSTR, DWORD); HINTERNET (WINAPI *InternetConnect)(HINTERNET, LPCTSTR, INTERNET_PORT, LPCTSTR, LPCTSTR, DWORD, DWORD, DWORD); HINTERNET (WINAPI *HttpOpenRequest)(HINTERNET, LPCTSTR, LPCTSTR, LPCTSTR, LPCTSTR, LPCTSTR *, DWORD, DWORD); BOOL (WINAPI *HttpSendRequest)(HINTERNET, LPCTSTR, DWORD, LPVOID, DWORD); BOOL (WINAPI *InternetCloseHandle)(HINTERNET); BOOL (WINAPI *HttpQueryInfo)(HINTERNET, DWORD, LPVOID, LPDWORD, LPDWORD); -} WinInetProcs; +}; #define M(x) x "\0" #if defined(UNICODE) diff --git a/src/window.cpp b/src/window.cpp index 7e607bc3a4..9e26bee1d4 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -665,9 +665,9 @@ Window *AllocateWindow( return LocalAllocateWindow(x, y, width, height, proc, cls, widget, 0); } -typedef struct SizeRect { +struct SizeRect { int left,top,width,height; -} SizeRect; +}; static SizeRect _awap_r; diff --git a/src/window.h b/src/window.h index 3c2e2f2710..0ed84b2ac6 100644 --- a/src/window.h +++ b/src/window.h @@ -11,7 +11,7 @@ #include "rail.h" #include "airport.h" -typedef struct WindowEvent WindowEvent; +struct WindowEvent; typedef void WindowProc(Window *w, WindowEvent *e); @@ -42,7 +42,7 @@ typedef void WindowProc(Window *w, WindowEvent *e); w->resize.width or w->resize.height. That was all.. good luck, and enjoy :) -- TrueLight */ -typedef enum ResizeFlags { +enum ResizeFlag { RESIZE_NONE = 0, ///< no resize required RESIZE_LEFT = 1, ///< left resize flag @@ -64,28 +64,28 @@ typedef enum ResizeFlags { WIDG_DISABLED = 4, ///< widget is greyed out, not available WIDG_HIDDEN = 5, ///< widget is made invisible WIDG_LOWERED = 6, ///< widget is paint lowered, a pressed button in fact -} ResizeFlag; +}; enum { WIDGET_LIST_END = -1, ///< indicate the end of widgets' list for vararg functions }; -typedef struct Widget { +struct Widget { byte type; ///< Widget type, see WindowWidgetTypes byte display_flags; ///< Resize direction, alignment, etc. during resizing, see ResizeFlags byte color; ///< Widget colour, see docs/ottd-colourtext-palette.png int16 left, right, top, bottom; ///< The position offsets inside the window uint16 data; ///< The String/Image or special code (list-matrixes) of a widget StringID tooltips; ///< Tooltips that are shown when rightclicking on a widget -} Widget; +}; -typedef enum FrameFlags { +enum FrameFlags { FR_NONE = 0x00, FR_TRANSPARENT = 0x01, ///< Makes the background transparent if set FR_BORDERONLY = 0x10, ///< Draw border only, no background FR_LOWERED = 0x20, ///< If set the frame is lowered and the background color brighter (ie. buttons when pressed) FR_DARKENED = 0x40, ///< If set the background is darker, allows for lowered frames with normal background color when used with FR_LOWERED (ie. dropdown boxes) -} FrameFlags; +}; DECLARE_ENUM_AS_BIT_SET(FrameFlags); @@ -186,14 +186,14 @@ struct WindowEvent { } we; }; -typedef struct WindowDesc { +struct WindowDesc { int16 left, top, width, height; WindowClass cls; WindowClass parent_cls; uint32 flags; const Widget *widgets; WindowProc *proc; -} WindowDesc; +}; enum WindowDefaultFlag { WDF_STD_TOOLTIPS = 1, ///< use standard routine when displaying tooltips @@ -214,14 +214,14 @@ enum WindowDefaultPosition { WDP_ALIGN_TBL = -4, ///< Align the left side of the window with the left side of the main toolbar }; -typedef struct Textbuf { +struct Textbuf { char *buf; ///< buffer in which text is saved uint16 maxlength, maxwidth; ///< the maximum size of the buffer. Maxwidth specifies screensize in pixels, maxlength is in bytes uint16 length, width; ///< the current size of the string. Width specifies screensize in pixels, length is in bytes bool caret; ///< is the caret ("_") visible or not uint16 caretpos; ///< the current position of the caret in the buffer, in bytes uint16 caretxoffs; ///< the current position of the caret in pixels -} Textbuf; +}; #define WP(ptr,str) (*(str*)(ptr)->custom) /* You cannot 100% reliably calculate the biggest custom struct as @@ -229,22 +229,22 @@ typedef struct Textbuf { * 96 is the largest window-size for 64-bit machines currently */ #define WINDOW_CUSTOM_SIZE 96 -typedef struct Scrollbar { +struct Scrollbar { uint16 count, cap, pos; -} Scrollbar; +}; -typedef struct ResizeInfo { +struct ResizeInfo { uint width; ///< Minimum width and height uint height; uint step_width; ///< In how big steps the width and height go uint step_height; -} ResizeInfo; +}; -typedef struct WindowMessage { - int msg; - int wparam; - int lparam; -} WindowMessage; +struct WindowMessage { + int msg; + int wparam; + int lparam; +}; struct Window { uint16 flags4; @@ -271,16 +271,16 @@ struct Window { byte custom[WINDOW_CUSTOM_SIZE]; }; -typedef struct querystr_d { +struct querystr_d { StringID caption; Textbuf text; const char *orig; CharSetFilter afilter; bool handled; -} querystr_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(querystr_d)); -typedef struct { +struct menu_d { byte item_count; ///< follow_vehicle byte sel_index; ///< scrollpos_x byte main_button; ///< scrollpos_y @@ -288,36 +288,36 @@ typedef struct { StringID string_id; ///< unk30 uint16 checked_items; ///< unk32 byte disabled_items; -} menu_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(menu_d)); -typedef struct { +struct def_d { int16 data_1, data_2, data_3; int16 data_4, data_5; bool close; byte byte_1; -} def_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(def_d)); -typedef struct { +struct void_d { void *data; -} void_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(void_d)); -typedef struct { +struct tree_d { uint16 base; uint16 count; -} tree_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tree_d)); -typedef struct { +struct tooltips_d { StringID string_id; byte paramcount; uint32 params[5]; -} tooltips_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tooltips_d)); -typedef struct { +struct buildvehicle_d { byte vehicle_type; union { RailTypeByte railtype; @@ -330,10 +330,10 @@ typedef struct { EngineID sel_engine; EngineID rename_engine; EngineList eng_list; -} buildvehicle_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(buildvehicle_d)); -typedef struct { +struct replaceveh_d { byte sel_index[2]; EngineID sel_engine[2]; uint16 count[2]; @@ -342,10 +342,10 @@ typedef struct { bool update_left; bool update_right; bool init_lists; -} replaceveh_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(replaceveh_d)); -typedef struct { +struct depot_d { VehicleID sel; byte type; bool generate_list; @@ -355,110 +355,110 @@ typedef struct { uint16 wagon_count; Vehicle **vehicle_list; Vehicle **wagon_list; -} depot_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(depot_d)); -typedef struct { +struct order_d { int sel; -} order_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(order_d)); -typedef struct { +struct traindetails_d { byte tab; -} traindetails_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(traindetails_d)); -typedef struct { +struct smallmap_d { int32 scroll_x; int32 scroll_y; int32 subscroll; -} smallmap_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(smallmap_d)); -typedef struct { +struct facesel_d { uint32 face; byte gender; -} facesel_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(facesel_d)); -typedef struct { +struct refit_d { int sel; struct RefitOption *cargo; struct RefitList *list; uint length; VehicleOrderID order; -} refit_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(refit_d)); -typedef struct { +struct vp_d { VehicleID follow_vehicle; int32 scrollpos_x; int32 scrollpos_y; -} vp_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp_d)); /* vp2_d is the same as vp_d, except for the data_# values.. */ -typedef struct { +struct vp2_d { VehicleID follow_vehicle; int32 scrollpos_x; int32 scrollpos_y; byte data_1; byte data_2; byte data_3; -} vp2_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp2_d)); -typedef struct { +struct news_d { uint16 follow_vehicle; int32 scrollpos_x; int32 scrollpos_y; NewsItem *ni; -} news_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(news_d)); -typedef struct { +struct highscore_d { uint32 background_img; int8 rank; -} highscore_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(highscore_d)); -typedef struct { +struct scroller_d { int height; uint16 counter; -} scroller_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(scroller_d)); -typedef enum SortListFlags { +enum SortListFlags { VL_NONE = 0x00, ///< no sort VL_DESC = 0x01, ///< sort descending or ascending VL_RESORT = 0x02, ///< instruct the code to resort the list in the next loop VL_REBUILD = 0x04, ///< create sort-listing to use for qsort and friends VL_END = 0x08 -} SortListFlags; +}; DECLARE_ENUM_AS_BIT_SET(SortListFlags); -typedef struct Listing { +struct Listing { bool order; ///< Ascending/descending byte criteria; ///< Sorting criteria -} Listing; +}; -typedef struct list_d { +struct list_d { uint16 list_length; ///< length of the list being sorted byte sort_type; ///< what criteria to sort on SortListFlags flags; ///< used to control sorting/resorting/etc. uint16 resort_timer; ///< resort list after a given amount of ticks if set -} list_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(list_d)); -typedef struct message_d { +struct message_d { int msg; int wparam; int lparam; -} message_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(message_d)); -typedef struct dropdown_d { +struct dropdown_d { uint32 disabled_state; uint32 hidden_state; WindowClass parent_wnd_class; @@ -469,7 +469,7 @@ typedef struct dropdown_d { const StringID *items; byte click_delay; bool drag_mode; -} dropdown_d; +}; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(dropdown_d)); diff --git a/src/yapf/yapf.h b/src/yapf/yapf.h index eb6fa96ef9..cafd5df7ee 100644 --- a/src/yapf/yapf.h +++ b/src/yapf/yapf.h @@ -88,7 +88,7 @@ extern int _aystar_stats_closed_size; */ /** Base struct for track followers. */ -typedef struct FollowTrack_t +struct FollowTrack_t { const Vehicle* m_veh; ///< moving vehicle TileIndex m_old_tile; ///< the origin (vehicle moved from) before move @@ -100,7 +100,7 @@ typedef struct FollowTrack_t bool m_is_bridge; ///< last turn passed bridge ramp bool m_is_station; ///< last turn passed station int m_tiles_skipped; ///< number of skipped tunnel or station tiles -} FollowTrack_t; +}; /** Initializes FollowTrack_t structure */ void FollowTrackInit(FollowTrack_t *This, const Vehicle* v); diff --git a/src/yapf/yapf_settings.h b/src/yapf/yapf_settings.h index aea5094410..0d840721df 100644 --- a/src/yapf/yapf_settings.h +++ b/src/yapf/yapf_settings.h @@ -11,17 +11,17 @@ # ifndef YS_DEF /* * if YS_DEF is not defined, we will only do following declaration: - * typedef struct YapfSettings { + * struct YapfSettings { * bool disable_node_optimization; * uint32 max_search_nodes; * .... all other yapf related settings ... - * } YapfSettings; + * }; * * otherwise we will just expand YS_DEF_xx macros and then #undef them */ -# define YS_DEF_BEGIN typedef struct YapfSettings { +# define YS_DEF_BEGIN struct YapfSettings { # define YS_DEF(type, name) type name; -# define YS_DEF_END } YapfSettings; +# define YS_DEF_END }; # endif /* !YS_DEF */