From c00258237e0fd63d23fb2015c78c070b72b2e9d9 Mon Sep 17 00:00:00 2001 From: tron Date: Fri, 3 Dec 2004 07:43:00 +0000 Subject: (svn r907) Sprinkle holy ANSI water: - "inline" must before the return type (and after "static") - Initialise all struct members, not just some of them - Remove (one) spurious semicolon --- ai.c | 8 ++++---- functions.h | 13 ++++++++++--- newgrf.c | 4 ++-- order_gui.c | 2 +- pathfind.c | 4 ++-- saveload.c | 8 ++++---- settings_gui.c | 2 +- station_cmd.c | 4 ++-- stdafx.h | 10 +++++----- table/ai_rail.h | 6 +++--- table/station_land.h | 2 +- table/unmovable_land.h | 6 +++--- 12 files changed, 38 insertions(+), 31 deletions(-) diff --git a/ai.c b/ai.c index afed9d234..9bdd373b1 100644 --- a/ai.c +++ b/ai.c @@ -1936,7 +1936,7 @@ static bool AiCheckRailPathBetter(AiRailFinder *arf, const byte *p) return better; } -static void FORCEINLINE AiCheckBuildRailBridgeHere(AiRailFinder *arf, TileIndex tile, const byte *p) +static inline void AiCheckBuildRailBridgeHere(AiRailFinder *arf, TileIndex tile, const byte *p) { TileIndex tile_new; bool flag; @@ -1976,7 +1976,7 @@ static void FORCEINLINE AiCheckBuildRailBridgeHere(AiRailFinder *arf, TileIndex } } -static void FORCEINLINE AiCheckBuildRailTunnelHere(AiRailFinder *arf, TileIndex tile, const byte *p) +static inline void AiCheckBuildRailTunnelHere(AiRailFinder *arf, TileIndex tile, const byte *p) { FindLandscapeHeightByTile(&arf->ti, tile); @@ -2813,7 +2813,7 @@ static bool AiBuildRoadHelper(uint tile, int flags, int type) return DoCommandByTile(tile, _road_bits[type], 0, flags, CMD_BUILD_ROAD) != CMD_ERROR; } -static void FORCEINLINE AiCheckBuildRoadBridgeHere(AiRoadFinder *arf, TileIndex tile, const byte *p) +static inline void AiCheckBuildRoadBridgeHere(AiRoadFinder *arf, TileIndex tile, const byte *p) { TileIndex tile_new; bool flag; @@ -2853,7 +2853,7 @@ static void FORCEINLINE AiCheckBuildRoadBridgeHere(AiRoadFinder *arf, TileIndex } } -static void FORCEINLINE AiCheckBuildRoadTunnelHere(AiRoadFinder *arf, TileIndex tile, const byte *p) +static inline void AiCheckBuildRoadTunnelHere(AiRoadFinder *arf, TileIndex tile, const byte *p) { FindLandscapeHeightByTile(&arf->ti, tile); diff --git a/functions.h b/functions.h index a78b1f7ed..54c2904dc 100644 --- a/functions.h +++ b/functions.h @@ -37,13 +37,20 @@ enum { bool IsValidTile(uint tile); +static inline Point RemapCoords(int x, int y, int z) +{ #if !defined(NEW_ROTATION) -static Point FORCEINLINE RemapCoords(int x, int y, int z) { Point pt = { (y-x)*2, y + x -z }; return pt; } + Point pt = { (y - x) * 2, y + x - z }; #else -static Point FORCEINLINE RemapCoords(int x, int y, int z) { Point pt = { (x + y)*2, x - y -z }; return pt; } + Point pt = { (x + y) * 2, x - y - z }; #endif + return pt; +} -static Point FORCEINLINE RemapCoords2(int x, int y) { return RemapCoords(x, y, GetSlopeZ(x, y)); } +static inline Point RemapCoords2(int x, int y) +{ + return RemapCoords(x, y, GetSlopeZ(x, y)); +} /* game.c */ byte *GetString(byte *buffr, uint16 string); diff --git a/newgrf.c b/newgrf.c index 841a4e73b..ac3c2eee4 100644 --- a/newgrf.c +++ b/newgrf.c @@ -728,7 +728,7 @@ static bool StationChangeInfo(uint stid, int numinfo, int prop, byte **bufp, int dts->ground_sprite = grf_load_dword(&buf); if (!dts->ground_sprite) { - static const DrawTileSeqStruct empty = {0x80}; + static const DrawTileSeqStruct empty = {0x80, 0, 0, 0, 0, 0, 0}; dts->seq = ∅ continue; } @@ -771,7 +771,7 @@ static bool StationChangeInfo(uint stid, int numinfo, int prop, byte **bufp, int dts->ground_sprite = sdts->ground_sprite; if (!dts->ground_sprite) { - static const DrawTileSeqStruct empty = {0x80}; + static const DrawTileSeqStruct empty = {0x80, 0, 0, 0, 0, 0, 0}; dts->seq = ∅ continue; } diff --git a/order_gui.c b/order_gui.c index 956a1cecc..de58f3306 100644 --- a/order_gui.c +++ b/order_gui.c @@ -154,7 +154,7 @@ static void *FindVehicleCallb(Vehicle *v, FindVehS *f) Vehicle *GetVehicleOnTile(TileIndex tile, byte owner) { - FindVehS fs = {tile, owner}; + FindVehS fs = {tile, owner, 0}; return VehicleFromPos(tile, &fs, (VehicleFromPosProc*)FindVehicleCallb); } diff --git a/pathfind.c b/pathfind.c index 122b79ad9..775fe9818 100644 --- a/pathfind.c +++ b/pathfind.c @@ -434,7 +434,7 @@ typedef struct { // called after a new element was added in the queue at the last index. // move it down to the proper position -static void inline HeapifyUp(NewTrackPathFinder *tpf) +static inline void HeapifyUp(NewTrackPathFinder *tpf) { StackedItem si; int i = ++tpf->nstack; @@ -448,7 +448,7 @@ static void inline HeapifyUp(NewTrackPathFinder *tpf) } // called after the element 0 was eaten. fill it with a new element -static void inline HeapifyDown(NewTrackPathFinder *tpf) +static inline void HeapifyDown(NewTrackPathFinder *tpf) { StackedItem si; int i = 1, j; diff --git a/saveload.c b/saveload.c index b4ab2982d..299890f2c 100644 --- a/saveload.c +++ b/saveload.c @@ -173,22 +173,22 @@ static uint SlGetGammaLength(uint i) { return (i>=0x80) ? 2 : 1; } -int inline SlReadSparseIndex() +inline int SlReadSparseIndex() { return SlReadSimpleGamma(); } -void inline SlWriteSparseIndex(uint index) +inline void SlWriteSparseIndex(uint index) { SlWriteSimpleGamma(index); } -int inline SlReadArrayLength() +inline int SlReadArrayLength() { return SlReadSimpleGamma(); } -void inline SlWriteArrayLength(uint length) +inline void SlWriteArrayLength(uint length) { SlWriteSimpleGamma(length); } diff --git a/settings_gui.c b/settings_gui.c index 362576e54..7d053840c 100644 --- a/settings_gui.c +++ b/settings_gui.c @@ -288,7 +288,7 @@ static const GameSettingData _game_setting_info[] = { {0,2,1,STR_6839_PERMISSIVE}, }; -static bool FORCEINLINE GetBitAndShift(uint32 *b) +static inline bool GetBitAndShift(uint32 *b) { uint32 x = *b; *b >>= 1; diff --git a/station_cmd.c b/station_cmd.c index 9c1329191..c8c119e0f 100644 --- a/station_cmd.c +++ b/station_cmd.c @@ -682,7 +682,7 @@ static bool CanExpandRailroadStation(Station *st, uint *fin, int direction) return true; } -static byte FORCEINLINE *CreateSingle(byte *layout, int n) +static inline byte *CreateSingle(byte *layout, int n) { int i = n; do *layout++ = 0; while (--i); @@ -690,7 +690,7 @@ static byte FORCEINLINE *CreateSingle(byte *layout, int n) return layout; } -static byte FORCEINLINE *CreateMulti(byte *layout, int n, byte b) +static inline byte *CreateMulti(byte *layout, int n, byte b) { int i = n; do *layout++ = b; while (--i); diff --git a/stdafx.h b/stdafx.h index 94524f6f5..abc6222a5 100644 --- a/stdafx.h +++ b/stdafx.h @@ -127,10 +127,10 @@ static inline uint16 FROM_LE16(uint16 x) { return BSWAP16(x); } #else -static uint32 FORCEINLINE TO_BE32(uint32 x) { return BSWAP32(x); } -static uint16 FORCEINLINE TO_BE16(uint16 x) { return BSWAP16(x); } -static uint32 FORCEINLINE FROM_BE32(uint32 x) { return BSWAP32(x); } -static uint16 FORCEINLINE FROM_BE16(uint16 x) { return BSWAP16(x); } +static inline uint32 TO_BE32(uint32 x) { return BSWAP32(x); } +static inline uint16 TO_BE16(uint16 x) { return BSWAP16(x); } +static inline uint32 FROM_BE32(uint32 x) { return BSWAP32(x); } +static inline uint16 FROM_BE16(uint16 x) { return BSWAP16(x); } #define TO_LE32(x) x #define TO_LE16(x) x #define TO_BE32X(x) BSWAP32(x) @@ -157,7 +157,7 @@ enum { #endif // Compile time assertions -#define assert_compile(expr) void __ct_assert__(int a[1 - 2 * !(expr)]); +#define assert_compile(expr) void __ct_assert__(int a[1 - 2 * !(expr)]) assert_compile(sizeof(uint32) == 4); assert_compile(sizeof(uint16) == 2); diff --git a/table/ai_rail.h b/table/ai_rail.h index daf70fe44..23fa20b44 100644 --- a/table/ai_rail.h +++ b/table/ai_rail.h @@ -24,7 +24,7 @@ typedef struct { #define MKSTATION(a,b) {1,a,b} #define MKRAIL(a,b) {2,a,b} #define MKCLRRAIL(a,b) {3,a,b} -#define MKEND {4}} +#define MKEND {4, 0, 0}} static const AiDefaultRailBlock _raildata_ai_0 = { MKHDR(1,2,1,0,1) @@ -463,12 +463,12 @@ static const AiDefaultRoadBlock * const _road_default_block_data[] = { static const AiDefaultBlockData _airportdata_ai_0[] = { MKAIR(1, 0), - {1}, + {1, 0, 0}, }; static const AiDefaultBlockData _airportdata_ai_1[] = { MKAIR(0, 0), - {1} + {1, 0, 0} }; static const AiDefaultBlockData * const _airport_default_block_data[] = { diff --git a/table/station_land.h b/table/station_land.h index 8beaf141e..14b70ec25 100644 --- a/table/station_land.h +++ b/table/station_land.h @@ -1,4 +1,4 @@ -#define TILE_SEQ_END() { 0x80 } +#define TILE_SEQ_END() { 0x80, 0, 0, 0, 0, 0, 0 } static const DrawTileSeqStruct _station_display_datas_0[] = { { 0, 0, 0, 16, 5, 2, 0x842E }, diff --git a/table/unmovable_land.h b/table/unmovable_land.h index 7cedafbf3..b29f0da6d 100644 --- a/table/unmovable_land.h +++ b/table/unmovable_land.h @@ -1,8 +1,8 @@ -#define TILE_SEQ_END() { 0x80 } +#define TILE_SEQ_END() { 0x80, 0, 0, 0, 0, 0, 0 } static const DrawTileUnmovableStruct _draw_tile_unmovable_data[] = { - {0xA29, 7,7, 2,2, 70}, - {0xA2A, 4,4, 7,7, 61}, + {0xA29, 7,7, 2,2, 70, 0}, + {0xA2A, 4,4, 7,7, 61, 0}, }; -- cgit v1.2.3-70-g09d2