Mercurial > hg > openttd
changeset 18792:c99e695378ce draft
(svn r23640) -Fix: stop using FORCEINLINE (1/3rd of the instances were, the others were still regular inline), but make sure inline is always a 'forced' inline (I am looking at you MSVC)
line wrap: on
line diff
--- a/src/3rdparty/squirrel/include/squirrel.h +++ b/src/3rdparty/squirrel/include/squirrel.h @@ -35,6 +35,10 @@ extern "C" { #endif +#if defined(_MSC_VER) +# define inline __forceinline +#endif /* _MSC_VER */ + #if defined(_MSC_VER) && _MSC_VER >= 1400 // MSVC 2005 safety checks # pragma warning(disable: 4996) // '_wfopen' was declared deprecated # define _CRT_SECURE_NO_DEPRECATE // all deprecated 'unsafe string functions
--- a/src/aircraft.h +++ b/src/aircraft.h @@ -90,7 +90,7 @@ * @return Returns true if the aircraft is a helicopter/airplane and * false if it is a shadow or a rotor */ - FORCEINLINE bool IsNormalAircraft() const + inline bool IsNormalAircraft() const { /* To be fully correct the commented out functionality is the proper one, * but since value can only be 0 or 2, it is sufficient to only check <= 2
--- a/src/base_station_base.h +++ b/src/base_station_base.h @@ -139,7 +139,7 @@ * @param tile The tile to get the base station from. * @return the station associated with that tile. */ - static FORCEINLINE BaseStation *GetByTile(TileIndex tile) + static inline BaseStation *GetByTile(TileIndex tile) { return BaseStation::Get(GetStationIndex(tile)); } @@ -150,7 +150,7 @@ * facilities left. * @return true if still in use */ - FORCEINLINE bool IsInUse() const + inline bool IsInUse() const { return (this->facilities & ~FACIL_WAYPOINT) != 0; } @@ -172,7 +172,7 @@ * Set station type correctly * @param tile The base tile of the station. */ - FORCEINLINE SpecializedStation<T, Tis_waypoint>(TileIndex tile) : + inline SpecializedStation<T, Tis_waypoint>(TileIndex tile) : BaseStation(tile) { this->facilities = EXPECTED_FACIL; @@ -183,7 +183,7 @@ * @param st the station to check. * @return true if the station is the type we expect it to be. */ - static FORCEINLINE bool IsExpected(const BaseStation *st) + static inline bool IsExpected(const BaseStation *st) { return (st->facilities & FACIL_WAYPOINT) == EXPECTED_FACIL; } @@ -193,7 +193,7 @@ * @param index tested index * @return is this index valid index of T? */ - static FORCEINLINE bool IsValidID(size_t index) + static inline bool IsValidID(size_t index) { return BaseStation::IsValidID(index) && IsExpected(BaseStation::Get(index)); } @@ -202,7 +202,7 @@ * Gets station with given index * @return pointer to station with given index casted to T * */ - static FORCEINLINE T *Get(size_t index) + static inline T *Get(size_t index) { return (T *)BaseStation::Get(index); } @@ -211,7 +211,7 @@ * Returns station if the index is a valid index for this station type * @return pointer to station with given index if it's a station of this type */ - static FORCEINLINE T *GetIfValid(size_t index) + static inline T *GetIfValid(size_t index) { return IsValidID(index) ? Get(index) : NULL; } @@ -221,7 +221,7 @@ * @param tile The tile to get the station from. * @return the station associated with that tile. */ - static FORCEINLINE T *GetByTile(TileIndex tile) + static inline T *GetByTile(TileIndex tile) { return GetIfValid(GetStationIndex(tile)); } @@ -231,7 +231,7 @@ * @param st BaseStation pointer * @return pointer to SpecializedStation */ - static FORCEINLINE T *From(BaseStation *st) + static inline T *From(BaseStation *st) { assert(IsExpected(st)); return (T *)st; @@ -242,7 +242,7 @@ * @param st BaseStation pointer * @return pointer to SpecializedStation */ - static FORCEINLINE const T *From(const BaseStation *st) + static inline const T *From(const BaseStation *st) { assert(IsExpected(st)); return (const T *)st;
--- a/src/cargo_type.h +++ b/src/cargo_type.h @@ -77,13 +77,13 @@ public: /** Default constructor. */ - FORCEINLINE CargoArray() + inline CargoArray() { this->Clear(); } /** Reset all entries. */ - FORCEINLINE void Clear() + inline void Clear() { memset(this->amount, 0, sizeof(this->amount)); } @@ -92,7 +92,7 @@ * Read/write access to an amount of a specific cargo type. * @param cargo Cargo type to access. */ - FORCEINLINE uint &operator[](CargoID cargo) + inline uint &operator[](CargoID cargo) { return this->amount[cargo]; } @@ -101,7 +101,7 @@ * Read-only access to an amount of a specific cargo type. * @param cargo Cargo type to access. */ - FORCEINLINE const uint &operator[](CargoID cargo) const + inline const uint &operator[](CargoID cargo) const { return this->amount[cargo]; }
--- a/src/cargopacket.cpp +++ b/src/cargopacket.cpp @@ -82,7 +82,7 @@ * @param new_size Size of the remaining part. * @return Split off part, or NULL if no packet could be allocated! */ -FORCEINLINE CargoPacket *CargoPacket::Split(uint new_size) +inline CargoPacket *CargoPacket::Split(uint new_size) { if (!CargoPacket::CanAllocateItem()) return NULL; @@ -97,7 +97,7 @@ * Merge another packet into this one. * @param cp Packet to be merged in. */ -FORCEINLINE void CargoPacket::Merge(CargoPacket *cp) +inline void CargoPacket::Merge(CargoPacket *cp) { this->count += cp->count; this->feeder_share += cp->feeder_share;
--- a/src/cargopacket.h +++ b/src/cargopacket.h @@ -69,7 +69,7 @@ * Gets the number of 'items' in this packet. * @return Item count. */ - FORCEINLINE uint16 Count() const + inline uint16 Count() const { return this->count; } @@ -79,7 +79,7 @@ * the feeder chain. * @return Feeder share. */ - FORCEINLINE Money FeederShare() const + inline Money FeederShare() const { return this->feeder_share; } @@ -90,7 +90,7 @@ * it is capped at 255. * @return Length this cargo has been in transit. */ - FORCEINLINE byte DaysInTransit() const + inline byte DaysInTransit() const { return this->days_in_transit; } @@ -99,7 +99,7 @@ * Gets the type of the cargo's source. industry, town or head quarter. * @return Source type. */ - FORCEINLINE SourceType SourceSubsidyType() const + inline SourceType SourceSubsidyType() const { return this->source_type; } @@ -108,7 +108,7 @@ * Gets the ID of the cargo's source. An IndustryID, TownID or CompanyID. * @return Source ID. */ - FORCEINLINE SourceID SourceSubsidyID() const + inline SourceID SourceSubsidyID() const { return this->source_id; } @@ -117,7 +117,7 @@ * Gets the ID of the station where the cargo was loaded for the first time. * @return StationID. */ - FORCEINLINE SourceID SourceStation() const + inline SourceID SourceStation() const { return this->source; } @@ -126,7 +126,7 @@ * Gets the coordinates of the cargo's source station. * @return Source station's coordinates. */ - FORCEINLINE TileIndex SourceStationXY() const + inline TileIndex SourceStationXY() const { return this->source_xy; } @@ -135,7 +135,7 @@ * Gets the coordinates of the cargo's last loading station. * @return Last loading station's coordinates. */ - FORCEINLINE TileIndex LoadedAtXY() const + inline TileIndex LoadedAtXY() const { return this->loaded_at_xy; } @@ -203,7 +203,7 @@ * Returns a pointer to the cargo packet list (so you can iterate over it etc). * @return Pointer to the packet list. */ - FORCEINLINE const List *Packets() const + inline const List *Packets() const { return &this->packets; } @@ -212,7 +212,7 @@ * Checks whether this list is empty. * @return True if and only if the list is empty. */ - FORCEINLINE bool Empty() const + inline bool Empty() const { return this->count == 0; } @@ -221,7 +221,7 @@ * Returns the number of cargo entities in this list. * @return The before mentioned number. */ - FORCEINLINE uint Count() const + inline uint Count() const { return this->count; } @@ -230,7 +230,7 @@ * Returns source of the first cargo packet in this list. * @return The before mentioned source. */ - FORCEINLINE StationID Source() const + inline StationID Source() const { return this->Empty() ? INVALID_STATION : this->packets.front()->source; } @@ -239,7 +239,7 @@ * Returns average number of days in transit for a cargo entity. * @return The before mentioned number. */ - FORCEINLINE uint DaysInTransit() const + inline uint DaysInTransit() const { return this->count == 0 ? 0 : this->cargo_days_in_transit / this->count; } @@ -277,7 +277,7 @@ * Returns total sum of the feeder share for all packets. * @return The before mentioned number. */ - FORCEINLINE Money FeederShare() const + inline Money FeederShare() const { return this->feeder_share; }
--- a/src/cargotype.h +++ b/src/cargotype.h @@ -85,7 +85,7 @@ * Determines index of this cargospec * @return index (in the CargoSpec::array array) */ - FORCEINLINE CargoID Index() const + inline CargoID Index() const { return this - CargoSpec::array; } @@ -95,7 +95,7 @@ * @return is this cargospec valid? * @note assert(cs->IsValid()) can be triggered when GRF config is modified */ - FORCEINLINE bool IsValid() const + inline bool IsValid() const { return this->bitnum != INVALID_CARGO; } @@ -104,7 +104,7 @@ * Total number of cargospecs, both valid and invalid * @return length of CargoSpec::array */ - static FORCEINLINE size_t GetArraySize() + static inline size_t GetArraySize() { return lengthof(CargoSpec::array); } @@ -114,7 +114,7 @@ * @param index ID of cargo * @pre index is a valid cargo ID */ - static FORCEINLINE CargoSpec *Get(size_t index) + static inline CargoSpec *Get(size_t index) { assert(index < lengthof(CargoSpec::array)); return &CargoSpec::array[index];
--- a/src/command_type.h +++ b/src/command_type.h @@ -58,7 +58,7 @@ * Adds the given cost to the cost of the command. * @param cost the cost to add */ - FORCEINLINE void AddCost(const Money &cost) + inline void AddCost(const Money &cost) { this->cost += cost; } @@ -69,7 +69,7 @@ * Multiplies the cost of the command by the given factor. * @param factor factor to multiply the costs with */ - FORCEINLINE void MultiplyCost(int factor) + inline void MultiplyCost(int factor) { this->cost *= factor; } @@ -78,7 +78,7 @@ * The costs as made up to this moment * @return the costs */ - FORCEINLINE Money GetCost() const + inline Money GetCost() const { return this->cost; } @@ -87,7 +87,7 @@ * The expense type of the cost * @return the expense type */ - FORCEINLINE ExpensesType GetExpensesType() const + inline ExpensesType GetExpensesType() const { return this->expense_type; } @@ -137,7 +137,7 @@ * Did this command succeed? * @return true if and only if it succeeded */ - FORCEINLINE bool Succeeded() const + inline bool Succeeded() const { return this->success; } @@ -146,7 +146,7 @@ * Did this command fail? * @return true if and only if it failed */ - FORCEINLINE bool Failed() const + inline bool Failed() const { return !this->success; }
--- a/src/company_base.h +++ b/src/company_base.h @@ -124,7 +124,7 @@ * @param index Index in the pool. * @return \c true if it is a valid, computer controlled company, else \c false. */ - static FORCEINLINE bool IsValidAiID(size_t index) + static inline bool IsValidAiID(size_t index) { const Company *c = Company::GetIfValid(index); return c != NULL && c->is_ai; @@ -136,7 +136,7 @@ * @return \c true if it is a valid, human controlled company, else \c false. * @note If you know that \a index refers to a valid company, you can use #IsHumanID() instead. */ - static FORCEINLINE bool IsValidHumanID(size_t index) + static inline bool IsValidHumanID(size_t index) { const Company *c = Company::GetIfValid(index); return c != NULL && !c->is_ai; @@ -149,7 +149,7 @@ * @pre \a index must be a valid CompanyID. * @note If you don't know whether \a index refers to a valid company, you should use #IsValidHumanID() instead. */ - static FORCEINLINE bool IsHumanID(size_t index) + static inline bool IsHumanID(size_t index) { return !Company::Get(index)->is_ai; }
--- a/src/core/alloc_func.hpp +++ b/src/core/alloc_func.hpp @@ -56,7 +56,7 @@ * @return NULL when num_elements == 0, non-NULL otherwise. */ template <typename T> -static FORCEINLINE T *MallocT(size_t num_elements) +static inline T *MallocT(size_t num_elements) { /* * MorphOS cannot handle 0 elements allocations, or rather that always @@ -84,7 +84,7 @@ * @return NULL when num_elements == 0, non-NULL otherwise. */ template <typename T> -static FORCEINLINE T *CallocT(size_t num_elements) +static inline T *CallocT(size_t num_elements) { /* * MorphOS cannot handle 0 elements allocations, or rather that always @@ -110,7 +110,7 @@ * @return NULL when num_elements == 0, non-NULL otherwise. */ template <typename T> -static FORCEINLINE T *ReallocT(T *t_ptr, size_t num_elements) +static inline T *ReallocT(T *t_ptr, size_t num_elements) { /* * MorphOS cannot handle 0 elements allocations, or rather that always
--- a/src/core/alloc_type.hpp +++ b/src/core/alloc_type.hpp @@ -48,7 +48,7 @@ * Gets a pointer to the data stored in this wrapper. * @return the pointer. */ - FORCEINLINE operator T *() + inline operator T *() { return data; } @@ -57,7 +57,7 @@ * Gets a pointer to the data stored in this wrapper. * @return the pointer. */ - FORCEINLINE T *operator -> () + inline T *operator -> () { return data; } @@ -67,7 +67,7 @@ * @note needed because endof does not work properly for pointers. * @return the 'endof' pointer. */ - FORCEINLINE T *EndOf() + inline T *EndOf() { #if !defined(__NDS__) return endof(data); @@ -137,7 +137,7 @@ * Get the currently allocated buffer. * @return the buffer */ - FORCEINLINE const T *GetBuffer() const + inline const T *GetBuffer() const { return this->buffer; } @@ -158,26 +158,26 @@ * @param size the amount of bytes to allocate. * @return the given amounts of bytes zeroed. */ - FORCEINLINE void *operator new(size_t size) { return CallocT<byte>(size); } + inline void *operator new(size_t size) { return CallocT<byte>(size); } /** * Memory allocator for an array of class instances. * @param size the amount of bytes to allocate. * @return the given amounts of bytes zeroed. */ - FORCEINLINE void *operator new[](size_t size) { return CallocT<byte>(size); } + inline void *operator new[](size_t size) { return CallocT<byte>(size); } /** * Memory release for a single class instance. * @param ptr the memory to free. */ - FORCEINLINE void operator delete(void *ptr) { free(ptr); } + inline void operator delete(void *ptr) { free(ptr); } /** * Memory release for an array of class instances. * @param ptr the memory to free. */ - FORCEINLINE void operator delete[](void *ptr) { free(ptr); } + inline void operator delete[](void *ptr) { free(ptr); } }; #endif /* ALLOC_TYPE_HPP */
--- a/src/core/bitmath_func.hpp +++ b/src/core/bitmath_func.hpp @@ -29,7 +29,7 @@ * @return The selected bits, aligned to a LSB. */ template <typename T> -static FORCEINLINE uint GB(const T x, const uint8 s, const uint8 n) +static inline uint GB(const T x, const uint8 s, const uint8 n) { return (x >> s) & (((T)1U << n) - 1); } @@ -53,7 +53,7 @@ * @return The new value of \a x */ template <typename T, typename U> -static FORCEINLINE T SB(T &x, const uint8 s, const uint8 n, const U d) +static inline T SB(T &x, const uint8 s, const uint8 n, const U d) { x &= (T)(~((((T)1U << n) - 1) << s)); x |= (T)(d << s); @@ -76,7 +76,7 @@ * @return The new value of x */ template <typename T, typename U> -static FORCEINLINE T AB(T &x, const uint8 s, const uint8 n, const U i) +static inline T AB(T &x, const uint8 s, const uint8 n, const U i) { const T mask = ((((T)1U << n) - 1) << s); x = (T)((x & ~mask) | ((x + (i << s)) & mask)); @@ -95,7 +95,7 @@ * @return True if the bit is set, false else. */ template <typename T> -static FORCEINLINE bool HasBit(const T x, const uint8 y) +static inline bool HasBit(const T x, const uint8 y) { return (x & ((T)1U << y)) != 0; } @@ -112,7 +112,7 @@ * @return The new value of the old value with the bit set */ template <typename T> -static FORCEINLINE T SetBit(T &x, const uint8 y) +static inline T SetBit(T &x, const uint8 y) { return x = (T)(x | ((T)1U << y)); } @@ -141,7 +141,7 @@ * @return The new value of the old value with the bit cleared */ template <typename T> -static FORCEINLINE T ClrBit(T &x, const uint8 y) +static inline T ClrBit(T &x, const uint8 y) { return x = (T)(x & ~((T)1U << y)); } @@ -170,7 +170,7 @@ * @return The new value of the old value with the bit toggled */ template <typename T> -static FORCEINLINE T ToggleBit(T &x, const uint8 y) +static inline T ToggleBit(T &x, const uint8 y) { return x = (T)(x ^ ((T)1U << y)); } @@ -205,7 +205,7 @@ * @return The position of the first bit which is set * @see FIND_FIRST_BIT */ -static FORCEINLINE uint8 FindFirstBit2x64(const int value) +static inline uint8 FindFirstBit2x64(const int value) { if ((value & 0xFF) == 0) { return FIND_FIRST_BIT((value >> 8) & 0x3F) + 8; @@ -228,7 +228,7 @@ * @return The new value with the first bit cleared */ template <typename T> -static FORCEINLINE T KillFirstBit(T value) +static inline T KillFirstBit(T value) { return value &= (T)(value - 1); } @@ -263,7 +263,7 @@ * @return does \a value have exactly 1 bit set? */ template <typename T> -static FORCEINLINE bool HasExactlyOneBit(T value) +static inline bool HasExactlyOneBit(T value) { return value != 0 && (value & (value - 1)) == 0; } @@ -275,7 +275,7 @@ * @return does \a value have at most 1 bit set? */ template <typename T> -static FORCEINLINE bool HasAtMostOneBit(T value) +static inline bool HasAtMostOneBit(T value) { return (value & (value - 1)) == 0; } @@ -289,7 +289,7 @@ * @return A bit rotated number */ template <typename T> -static FORCEINLINE T ROL(const T x, const uint8 n) +static inline T ROL(const T x, const uint8 n) { return (T)(x << n | x >> (sizeof(x) * 8 - n)); } @@ -303,7 +303,7 @@ * @return A bit rotated number */ template <typename T> -static FORCEINLINE T ROR(const T x, const uint8 n) +static inline T ROR(const T x, const uint8 n) { return (T)(x >> n | x << (sizeof(x) * 8 - n)); } @@ -365,7 +365,7 @@ * @param x the variable to bitswap * @return the bitswapped value. */ - static FORCEINLINE uint32 BSWAP32(uint32 x) + static inline uint32 BSWAP32(uint32 x) { #if !defined(__ICC) && defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ >= 3)) /* GCC >= 4.3 provides a builtin, resulting in faster code */ @@ -380,7 +380,7 @@ * @param x the variable to bitswap * @return the bitswapped value. */ - static FORCEINLINE uint16 BSWAP16(uint16 x) + static inline uint16 BSWAP16(uint16 x) { return (x >> 8) | (x << 8); }
--- a/src/core/endian_func.hpp +++ b/src/core/endian_func.hpp @@ -40,12 +40,12 @@ #define TO_LE32X(x) (x) #endif /* TTD_ENDIAN == TTD_BIG_ENDIAN */ -static FORCEINLINE uint16 ReadLE16Aligned(const void *x) +static inline uint16 ReadLE16Aligned(const void *x) { return FROM_LE16(*(const uint16*)x); } -static FORCEINLINE uint16 ReadLE16Unaligned(const void *x) +static inline uint16 ReadLE16Unaligned(const void *x) { #if OTTD_ALIGNMENT == 1 return ((const byte*)x)[0] | ((const byte*)x)[1] << 8;
--- a/src/core/enum_type.hpp +++ b/src/core/enum_type.hpp @@ -14,13 +14,13 @@ /** Some enums need to have allowed incrementing (i.e. StationClassID) */ #define DECLARE_POSTFIX_INCREMENT(type) \ - FORCEINLINE type operator ++(type& e, int) \ + inline type operator ++(type& e, int) \ { \ type e_org = e; \ e = (type)((int)e + 1); \ return e_org; \ } \ - FORCEINLINE type operator --(type& e, int) \ + inline type operator --(type& e, int) \ { \ type e_org = e; \ e = (type)((int)e - 1); \ @@ -31,13 +31,13 @@ /** Operators to allow to work with enum as with type safe bit set in C++ */ # define DECLARE_ENUM_AS_BIT_SET(mask_t) \ - FORCEINLINE mask_t operator | (mask_t m1, mask_t m2) {return (mask_t)((int)m1 | m2);} \ - FORCEINLINE mask_t operator & (mask_t m1, mask_t m2) {return (mask_t)((int)m1 & m2);} \ - FORCEINLINE mask_t operator ^ (mask_t m1, mask_t m2) {return (mask_t)((int)m1 ^ m2);} \ - FORCEINLINE mask_t& operator |= (mask_t& m1, mask_t m2) {m1 = m1 | m2; return m1;} \ - FORCEINLINE mask_t& operator &= (mask_t& m1, mask_t m2) {m1 = m1 & m2; return m1;} \ - FORCEINLINE mask_t& operator ^= (mask_t& m1, mask_t m2) {m1 = m1 ^ m2; return m1;} \ - FORCEINLINE mask_t operator ~(mask_t m) {return (mask_t)(~(int)m);} + inline mask_t operator | (mask_t m1, mask_t m2) {return (mask_t)((int)m1 | m2);} \ + inline mask_t operator & (mask_t m1, mask_t m2) {return (mask_t)((int)m1 & m2);} \ + inline mask_t operator ^ (mask_t m1, mask_t m2) {return (mask_t)((int)m1 ^ m2);} \ + inline mask_t& operator |= (mask_t& m1, mask_t m2) {m1 = m1 | m2; return m1;} \ + inline mask_t& operator &= (mask_t& m1, mask_t m2) {m1 = m1 & m2; return m1;} \ + inline mask_t& operator ^= (mask_t& m1, mask_t m2) {m1 = m1 ^ m2; return m1;} \ + inline mask_t operator ~(mask_t m) {return (mask_t)(~(int)m);} /** @@ -98,27 +98,27 @@ storage_type m_val; ///< here we hold the actual value in small (i.e. byte) form /** Cast operator - invoked then the value is assigned to the Tenum_t type */ - FORCEINLINE operator enum_type () const + inline operator enum_type () const { return (enum_type)m_val; } /** Assignment operator (from Tenum_t type) */ - FORCEINLINE TinyEnumT& operator = (enum_type e) + inline TinyEnumT& operator = (enum_type e) { m_val = (storage_type)e; return *this; } /** Assignment operator (from Tenum_t type) */ - FORCEINLINE TinyEnumT& operator = (uint u) + inline TinyEnumT& operator = (uint u) { m_val = (storage_type)u; return *this; } /** postfix ++ operator on tiny type */ - FORCEINLINE TinyEnumT operator ++ (int) + inline TinyEnumT operator ++ (int) { TinyEnumT org = *this; if (++m_val >= end) m_val -= (storage_type)(end - begin); @@ -126,7 +126,7 @@ } /** prefix ++ operator on tiny type */ - FORCEINLINE TinyEnumT& operator ++ () + inline TinyEnumT& operator ++ () { if (++m_val >= end) m_val -= (storage_type)(end - begin); return *this; @@ -140,34 +140,34 @@ storage_type m_val; ///< here we hold the actual value in small (i.e. byte) form /** Cast operator - invoked then the value is assigned to the storage_type */ - FORCEINLINE operator enum_type () const + inline operator enum_type () const { return (enum_type)this->m_val; } /** Assignment operator (from enum_type) */ - FORCEINLINE SimpleTinyEnumT &operator = (enum_type e) + inline SimpleTinyEnumT &operator = (enum_type e) { this->m_val = (storage_type)e; return *this; } /** Assignment operator (from general uint) */ - FORCEINLINE SimpleTinyEnumT &operator = (uint u) + inline SimpleTinyEnumT &operator = (uint u) { this->m_val = (storage_type)u; return *this; } /** Bit math (or) assignment operator (from enum_type) */ - FORCEINLINE SimpleTinyEnumT &operator |= (enum_type e) + inline SimpleTinyEnumT &operator |= (enum_type e) { this->m_val = (storage_type)((enum_type)this->m_val | e); return *this; } /** Bit math (and) assignment operator (from enum_type) */ - FORCEINLINE SimpleTinyEnumT &operator &= (enum_type e) + inline SimpleTinyEnumT &operator &= (enum_type e) { this->m_val = (storage_type)((enum_type)this->m_val & e); return *this;
--- a/src/core/math_func.hpp +++ b/src/core/math_func.hpp @@ -35,7 +35,7 @@ * @return The greater value or a if equals */ template <typename T> -static FORCEINLINE T max(const T a, const T b) +static inline T max(const T a, const T b) { return (a >= b) ? a : b; } @@ -51,7 +51,7 @@ * @return The smaller value or b if equals */ template <typename T> -static FORCEINLINE T min(const T a, const T b) +static inline T min(const T a, const T b) { return (a < b) ? a : b; } @@ -65,7 +65,7 @@ * @param b The second integer * @return The smaller value */ -static FORCEINLINE int min(const int a, const int b) +static inline int min(const int a, const int b) { return min<int>(a, b); } @@ -79,7 +79,7 @@ * @param b The second unsigned integer * @return The smaller value */ -static FORCEINLINE uint minu(const uint a, const uint b) +static inline uint minu(const uint a, const uint b) { return min<uint>(a, b); } @@ -92,7 +92,7 @@ * @return The unsigned value */ template <typename T> -static FORCEINLINE T abs(const T a) +static inline T abs(const T a) { return (a < (T)0) ? -a : a; } @@ -106,7 +106,7 @@ * @return The smallest multiple of n equal or greater than x */ template <typename T> -static FORCEINLINE T Align(const T x, uint n) +static inline T Align(const T x, uint n) { assert((n & (n - 1)) == 0 && n != 0); n--; @@ -124,7 +124,7 @@ * @see Align() */ template <typename T> -static FORCEINLINE T *AlignPtr(T *x, uint n) +static inline T *AlignPtr(T *x, uint n) { assert_compile(sizeof(size_t) == sizeof(void *)); return (T *)Align((size_t)x, n); @@ -148,7 +148,7 @@ * @see Clamp(int, int, int) */ template <typename T> -static FORCEINLINE T Clamp(const T a, const T min, const T max) +static inline T Clamp(const T a, const T min, const T max) { assert(min <= max); if (a <= min) return min; @@ -172,7 +172,7 @@ * @returns A value between min and max which is closest to a. * @see ClampU(uint, uint, uint) */ -static FORCEINLINE int Clamp(const int a, const int min, const int max) +static inline int Clamp(const int a, const int min, const int max) { return Clamp<int>(a, min, max); } @@ -193,7 +193,7 @@ * @returns A value between min and max which is closest to a. * @see Clamp(int, int, int) */ -static FORCEINLINE uint ClampU(const uint a, const uint min, const uint max) +static inline uint ClampU(const uint a, const uint min, const uint max) { return Clamp<uint>(a, min, max); } @@ -212,7 +212,7 @@ * @return The 64-bit value reduced to a 32-bit value * @see Clamp(int, int, int) */ -static FORCEINLINE int32 ClampToI32(const int64 a) +static inline int32 ClampToI32(const int64 a) { return (int32)Clamp<int64>(a, INT32_MIN, INT32_MAX); } @@ -224,7 +224,7 @@ * @return The 64-bit value reduced to a 16-bit value * @see ClampU(uint, uint, uint) */ -static FORCEINLINE uint16 ClampToU16(const uint64 a) +static inline uint16 ClampToU16(const uint64 a) { /* MSVC thinks, in its infinite wisdom, that int min(int, int) is a better * match for min(uint64, uint) than uint64 min(uint64, uint64). As such we @@ -241,7 +241,7 @@ * @return The absolute difference between the given scalars */ template <typename T> -static FORCEINLINE T Delta(const T a, const T b) +static inline T Delta(const T a, const T b) { return (a < b) ? b - a : a - b; } @@ -259,7 +259,7 @@ * @return True if the value is in the interval, false else. */ template <typename T> -static FORCEINLINE bool IsInsideBS(const T x, const uint base, const uint size) +static inline bool IsInsideBS(const T x, const uint base, const uint size) { return (uint)(x - base) < size; } @@ -275,7 +275,7 @@ * @see IsInsideBS() */ template <typename T> -static FORCEINLINE bool IsInsideMM(const T x, const uint min, const uint max) +static inline bool IsInsideMM(const T x, const uint min, const uint max) { return (uint)(x - min) < (max - min); } @@ -286,7 +286,7 @@ * @param b variable to swap with a */ template <typename T> -static FORCEINLINE void Swap(T &a, T &b) +static inline void Swap(T &a, T &b) { T t = a; a = b; @@ -298,7 +298,7 @@ * @param i value to convert, range 0..255 * @return value in range 0..100 */ -static FORCEINLINE uint ToPercent8(uint i) +static inline uint ToPercent8(uint i) { assert(i < 256); return i * 101 >> 8; @@ -309,7 +309,7 @@ * @param i value to convert, range 0..65535 * @return value in range 0..100 */ -static FORCEINLINE uint ToPercent16(uint i) +static inline uint ToPercent16(uint i) { assert(i < 65536); return i * 101 >> 16; @@ -324,7 +324,7 @@ * @param b Denominator * @return Quotient, rounded up */ -static FORCEINLINE uint CeilDiv(uint a, uint b) +static inline uint CeilDiv(uint a, uint b) { return (a + b - 1) / b; } @@ -335,7 +335,7 @@ * @param b Denominator * @return a rounded up to the nearest multiple of b. */ -static FORCEINLINE uint Ceil(uint a, uint b) +static inline uint Ceil(uint a, uint b) { return CeilDiv(a, b) * b; } @@ -346,7 +346,7 @@ * @param b Denominator * @return Quotient, rounded to nearest */ -static FORCEINLINE int RoundDivSU(int a, uint b) +static inline int RoundDivSU(int a, uint b) { if (a > 0) { /* 0.5 is rounded to 1 */
--- a/src/core/mem_func.hpp +++ b/src/core/mem_func.hpp @@ -22,7 +22,7 @@ * @param num number of items to be copied. (!not number of bytes!) */ template <typename T> -static FORCEINLINE void MemCpyT(T *destination, const T *source, size_t num = 1) +static inline void MemCpyT(T *destination, const T *source, size_t num = 1) { memcpy(destination, source, num * sizeof(T)); } @@ -35,7 +35,7 @@ * @param num number of items to be copied. (!not number of bytes!) */ template <typename T> -static FORCEINLINE void MemMoveT(T *destination, const T *source, size_t num = 1) +static inline void MemMoveT(T *destination, const T *source, size_t num = 1) { memmove(destination, source, num * sizeof(T)); } @@ -48,7 +48,7 @@ * @param num number of items to be set (!not number of bytes!) */ template <typename T> -static FORCEINLINE void MemSetT(T *ptr, byte value, size_t num = 1) +static inline void MemSetT(T *ptr, byte value, size_t num = 1) { memset(ptr, value, num * sizeof(T)); } @@ -62,7 +62,7 @@ * @return an int value indicating the relationship between the content of the two buffers */ template <typename T> -static FORCEINLINE int MemCmpT(const T *ptr1, const T *ptr2, size_t num = 1) +static inline int MemCmpT(const T *ptr1, const T *ptr2, size_t num = 1) { return memcmp(ptr1, ptr2, num * sizeof(T)); } @@ -76,7 +76,7 @@ * @param ptr2 End-pointer to the block of memory. */ template <typename T> -static FORCEINLINE void MemReverseT(T *ptr1, T *ptr2) +static inline void MemReverseT(T *ptr1, T *ptr2) { assert(ptr1 != NULL && ptr2 != NULL); assert(ptr1 < ptr2); @@ -93,7 +93,7 @@ * @param num The number of items we want to reverse. */ template <typename T> -static FORCEINLINE void MemReverseT(T *ptr, size_t num) +static inline void MemReverseT(T *ptr, size_t num) { assert(ptr != NULL);
--- a/src/core/overflowsafe_type.hpp +++ b/src/core/overflowsafe_type.hpp @@ -33,9 +33,9 @@ OverflowSafeInt(const OverflowSafeInt& other) { this->m_value = other.m_value; } OverflowSafeInt(const int64 int_) { this->m_value = int_; } - FORCEINLINE OverflowSafeInt& operator = (const OverflowSafeInt& other) { this->m_value = other.m_value; return *this; } + inline OverflowSafeInt& operator = (const OverflowSafeInt& other) { this->m_value = other.m_value; return *this; } - FORCEINLINE OverflowSafeInt operator - () const { return OverflowSafeInt(-this->m_value); } + inline OverflowSafeInt operator - () const { return OverflowSafeInt(-this->m_value); } /** * Safe implementation of addition. @@ -43,7 +43,7 @@ * @note when the addition would yield more than T_MAX (or less than T_MIN), * it will be T_MAX (respectively T_MIN). */ - FORCEINLINE OverflowSafeInt& operator += (const OverflowSafeInt& other) + inline OverflowSafeInt& operator += (const OverflowSafeInt& other) { if ((T_MAX - abs(other.m_value)) < abs(this->m_value) && (this->m_value < 0) == (other.m_value < 0)) { @@ -55,18 +55,18 @@ } /* Operators for addition and substraction */ - FORCEINLINE OverflowSafeInt operator + (const OverflowSafeInt& other) const { OverflowSafeInt result = *this; result += other; return result; } - FORCEINLINE OverflowSafeInt operator + (const int other) const { OverflowSafeInt result = *this; result += (int64)other; return result; } - FORCEINLINE OverflowSafeInt operator + (const uint other) const { OverflowSafeInt result = *this; result += (int64)other; return result; } - FORCEINLINE OverflowSafeInt& operator -= (const OverflowSafeInt& other) { return *this += (-other); } - FORCEINLINE OverflowSafeInt operator - (const OverflowSafeInt& other) const { OverflowSafeInt result = *this; result -= other; return result; } - FORCEINLINE OverflowSafeInt operator - (const int other) const { OverflowSafeInt result = *this; result -= (int64)other; return result; } - FORCEINLINE OverflowSafeInt operator - (const uint other) const { OverflowSafeInt result = *this; result -= (int64)other; return result; } + inline OverflowSafeInt operator + (const OverflowSafeInt& other) const { OverflowSafeInt result = *this; result += other; return result; } + inline OverflowSafeInt operator + (const int other) const { OverflowSafeInt result = *this; result += (int64)other; return result; } + inline OverflowSafeInt operator + (const uint other) const { OverflowSafeInt result = *this; result += (int64)other; return result; } + inline OverflowSafeInt& operator -= (const OverflowSafeInt& other) { return *this += (-other); } + inline OverflowSafeInt operator - (const OverflowSafeInt& other) const { OverflowSafeInt result = *this; result -= other; return result; } + inline OverflowSafeInt operator - (const int other) const { OverflowSafeInt result = *this; result -= (int64)other; return result; } + inline OverflowSafeInt operator - (const uint other) const { OverflowSafeInt result = *this; result -= (int64)other; return result; } - FORCEINLINE OverflowSafeInt& operator ++ () { return *this += 1; } - FORCEINLINE OverflowSafeInt& operator -- () { return *this += -1; } - FORCEINLINE OverflowSafeInt operator ++ (int) { OverflowSafeInt org = *this; *this += 1; return org; } - FORCEINLINE OverflowSafeInt operator -- (int) { OverflowSafeInt org = *this; *this += -1; return org; } + inline OverflowSafeInt& operator ++ () { return *this += 1; } + inline OverflowSafeInt& operator -- () { return *this += -1; } + inline OverflowSafeInt operator ++ (int) { OverflowSafeInt org = *this; *this += 1; return org; } + inline OverflowSafeInt operator -- (int) { OverflowSafeInt org = *this; *this += -1; return org; } /** * Safe implementation of multiplication. @@ -74,7 +74,7 @@ * @note when the multiplication would yield more than T_MAX (or less than T_MIN), * it will be T_MAX (respectively T_MIN). */ - FORCEINLINE OverflowSafeInt& operator *= (const int factor) + inline OverflowSafeInt& operator *= (const int factor) { if (factor != 0 && (T_MAX / abs(factor)) < abs(this->m_value)) { this->m_value = ((this->m_value < 0) == (factor < 0)) ? T_MAX : T_MIN ; @@ -85,70 +85,70 @@ } /* Operators for multiplication */ - FORCEINLINE OverflowSafeInt operator * (const int64 factor) const { OverflowSafeInt result = *this; result *= factor; return result; } - FORCEINLINE OverflowSafeInt operator * (const int factor) const { OverflowSafeInt result = *this; result *= (int64)factor; return result; } - FORCEINLINE OverflowSafeInt operator * (const uint factor) const { OverflowSafeInt result = *this; result *= (int64)factor; return result; } - FORCEINLINE OverflowSafeInt operator * (const uint16 factor) const { OverflowSafeInt result = *this; result *= (int64)factor; return result; } - FORCEINLINE OverflowSafeInt operator * (const byte factor) const { OverflowSafeInt result = *this; result *= (int64)factor; return result; } + inline OverflowSafeInt operator * (const int64 factor) const { OverflowSafeInt result = *this; result *= factor; return result; } + inline OverflowSafeInt operator * (const int factor) const { OverflowSafeInt result = *this; result *= (int64)factor; return result; } + inline OverflowSafeInt operator * (const uint factor) const { OverflowSafeInt result = *this; result *= (int64)factor; return result; } + inline OverflowSafeInt operator * (const uint16 factor) const { OverflowSafeInt result = *this; result *= (int64)factor; return result; } + inline OverflowSafeInt operator * (const byte factor) const { OverflowSafeInt result = *this; result *= (int64)factor; return result; } /* Operators for division */ - FORCEINLINE OverflowSafeInt& operator /= (const int64 divisor) { this->m_value /= divisor; return *this; } - FORCEINLINE OverflowSafeInt operator / (const OverflowSafeInt& divisor) const { OverflowSafeInt result = *this; result /= divisor.m_value; return result; } - FORCEINLINE OverflowSafeInt operator / (const int divisor) const { OverflowSafeInt result = *this; result /= divisor; return result; } - FORCEINLINE OverflowSafeInt operator / (const uint divisor) const { OverflowSafeInt result = *this; result /= (int)divisor; return result; } + inline OverflowSafeInt& operator /= (const int64 divisor) { this->m_value /= divisor; return *this; } + inline OverflowSafeInt operator / (const OverflowSafeInt& divisor) const { OverflowSafeInt result = *this; result /= divisor.m_value; return result; } + inline OverflowSafeInt operator / (const int divisor) const { OverflowSafeInt result = *this; result /= divisor; return result; } + inline OverflowSafeInt operator / (const uint divisor) const { OverflowSafeInt result = *this; result /= (int)divisor; return result; } /* Operators for modulo */ - FORCEINLINE OverflowSafeInt& operator %= (const int divisor) { this->m_value %= divisor; return *this; } - FORCEINLINE OverflowSafeInt operator % (const int divisor) const { OverflowSafeInt result = *this; result %= divisor; return result; } + inline OverflowSafeInt& operator %= (const int divisor) { this->m_value %= divisor; return *this; } + inline OverflowSafeInt operator % (const int divisor) const { OverflowSafeInt result = *this; result %= divisor; return result; } /* Operators for shifting */ - FORCEINLINE OverflowSafeInt& operator <<= (const int shift) { this->m_value <<= shift; return *this; } - FORCEINLINE OverflowSafeInt operator << (const int shift) const { OverflowSafeInt result = *this; result <<= shift; return result; } - FORCEINLINE OverflowSafeInt& operator >>= (const int shift) { this->m_value >>= shift; return *this; } - FORCEINLINE OverflowSafeInt operator >> (const int shift) const { OverflowSafeInt result = *this; result >>= shift; return result; } + inline OverflowSafeInt& operator <<= (const int shift) { this->m_value <<= shift; return *this; } + inline OverflowSafeInt operator << (const int shift) const { OverflowSafeInt result = *this; result <<= shift; return result; } + inline OverflowSafeInt& operator >>= (const int shift) { this->m_value >>= shift; return *this; } + inline OverflowSafeInt operator >> (const int shift) const { OverflowSafeInt result = *this; result >>= shift; return result; } /* Operators for (in)equality when comparing overflow safe ints */ - FORCEINLINE bool operator == (const OverflowSafeInt& other) const { return this->m_value == other.m_value; } - FORCEINLINE bool operator != (const OverflowSafeInt& other) const { return !(*this == other); } - FORCEINLINE bool operator > (const OverflowSafeInt& other) const { return this->m_value > other.m_value; } - FORCEINLINE bool operator >= (const OverflowSafeInt& other) const { return this->m_value >= other.m_value; } - FORCEINLINE bool operator < (const OverflowSafeInt& other) const { return !(*this >= other); } - FORCEINLINE bool operator <= (const OverflowSafeInt& other) const { return !(*this > other); } + inline bool operator == (const OverflowSafeInt& other) const { return this->m_value == other.m_value; } + inline bool operator != (const OverflowSafeInt& other) const { return !(*this == other); } + inline bool operator > (const OverflowSafeInt& other) const { return this->m_value > other.m_value; } + inline bool operator >= (const OverflowSafeInt& other) const { return this->m_value >= other.m_value; } + inline bool operator < (const OverflowSafeInt& other) const { return !(*this >= other); } + inline bool operator <= (const OverflowSafeInt& other) const { return !(*this > other); } /* Operators for (in)equality when comparing non-overflow safe ints */ - FORCEINLINE bool operator == (const int other) const { return this->m_value == other; } - FORCEINLINE bool operator != (const int other) const { return !(*this == other); } - FORCEINLINE bool operator > (const int other) const { return this->m_value > other; } - FORCEINLINE bool operator >= (const int other) const { return this->m_value >= other; } - FORCEINLINE bool operator < (const int other) const { return !(*this >= other); } - FORCEINLINE bool operator <= (const int other) const { return !(*this > other); } + inline bool operator == (const int other) const { return this->m_value == other; } + inline bool operator != (const int other) const { return !(*this == other); } + inline bool operator > (const int other) const { return this->m_value > other; } + inline bool operator >= (const int other) const { return this->m_value >= other; } + inline bool operator < (const int other) const { return !(*this >= other); } + inline bool operator <= (const int other) const { return !(*this > other); } - FORCEINLINE operator int64 () const { return this->m_value; } + inline operator int64 () const { return this->m_value; } }; /* Sometimes we got int64 operator OverflowSafeInt instead of vice versa. Handle that properly */ -template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator + (int64 a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b + a; } -template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator - (int64 a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return -b + a; } -template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator * (int64 a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b * a; } -template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator / (int64 a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return (OverflowSafeInt<T, T_MAX, T_MIN>)a / (int)b; } +template <class T, int64 T_MAX, int64 T_MIN> inline OverflowSafeInt<T, T_MAX, T_MIN> operator + (int64 a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b + a; } +template <class T, int64 T_MAX, int64 T_MIN> inline OverflowSafeInt<T, T_MAX, T_MIN> operator - (int64 a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return -b + a; } +template <class T, int64 T_MAX, int64 T_MIN> inline OverflowSafeInt<T, T_MAX, T_MIN> operator * (int64 a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b * a; } +template <class T, int64 T_MAX, int64 T_MIN> inline OverflowSafeInt<T, T_MAX, T_MIN> operator / (int64 a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return (OverflowSafeInt<T, T_MAX, T_MIN>)a / (int)b; } /* Sometimes we got int operator OverflowSafeInt instead of vice versa. Handle that properly */ -template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator + (int a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b + a; } -template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator - (int a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return -b + a; } -template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator * (int a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b * a; } -template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator / (int a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return (OverflowSafeInt<T, T_MAX, T_MIN>)a / (int)b; } +template <class T, int64 T_MAX, int64 T_MIN> inline OverflowSafeInt<T, T_MAX, T_MIN> operator + (int a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b + a; } +template <class T, int64 T_MAX, int64 T_MIN> inline OverflowSafeInt<T, T_MAX, T_MIN> operator - (int a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return -b + a; } +template <class T, int64 T_MAX, int64 T_MIN> inline OverflowSafeInt<T, T_MAX, T_MIN> operator * (int a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b * a; } +template <class T, int64 T_MAX, int64 T_MIN> inline OverflowSafeInt<T, T_MAX, T_MIN> operator / (int a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return (OverflowSafeInt<T, T_MAX, T_MIN>)a / (int)b; } /* Sometimes we got uint operator OverflowSafeInt instead of vice versa. Handle that properly */ -template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator + (uint a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b + a; } -template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator - (uint a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return -b + a; } -template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator * (uint a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b * a; } -template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator / (uint a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return (OverflowSafeInt<T, T_MAX, T_MIN>)a / (int)b; } +template <class T, int64 T_MAX, int64 T_MIN> inline OverflowSafeInt<T, T_MAX, T_MIN> operator + (uint a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b + a; } +template <class T, int64 T_MAX, int64 T_MIN> inline OverflowSafeInt<T, T_MAX, T_MIN> operator - (uint a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return -b + a; } +template <class T, int64 T_MAX, int64 T_MIN> inline OverflowSafeInt<T, T_MAX, T_MIN> operator * (uint a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b * a; } +template <class T, int64 T_MAX, int64 T_MIN> inline OverflowSafeInt<T, T_MAX, T_MIN> operator / (uint a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return (OverflowSafeInt<T, T_MAX, T_MIN>)a / (int)b; } /* Sometimes we got byte operator OverflowSafeInt instead of vice versa. Handle that properly */ -template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator + (byte a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b + (uint)a; } -template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator - (byte a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return -b + (uint)a; } -template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator * (byte a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b * (uint)a; } -template <class T, int64 T_MAX, int64 T_MIN> FORCEINLINE OverflowSafeInt<T, T_MAX, T_MIN> operator / (byte a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return (OverflowSafeInt<T, T_MAX, T_MIN>)a / (int)b; } +template <class T, int64 T_MAX, int64 T_MIN> inline OverflowSafeInt<T, T_MAX, T_MIN> operator + (byte a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b + (uint)a; } +template <class T, int64 T_MAX, int64 T_MIN> inline OverflowSafeInt<T, T_MAX, T_MIN> operator - (byte a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return -b + (uint)a; } +template <class T, int64 T_MAX, int64 T_MIN> inline OverflowSafeInt<T, T_MAX, T_MIN> operator * (byte a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return b * (uint)a; } +template <class T, int64 T_MAX, int64 T_MIN> inline OverflowSafeInt<T, T_MAX, T_MIN> operator / (byte a, OverflowSafeInt<T, T_MAX, T_MIN> b) { return (OverflowSafeInt<T, T_MAX, T_MIN>)a / (int)b; } typedef OverflowSafeInt<int64, INT64_MAX, INT64_MIN> OverflowSafeInt64;
--- a/src/core/pool_type.hpp +++ b/src/core/pool_type.hpp @@ -98,7 +98,7 @@ * @return pointer to Titem * @pre index < this->first_unused */ - FORCEINLINE Titem *Get(size_t index) + inline Titem *Get(size_t index) { assert(index < this->first_unused); return this->data[index]; @@ -109,7 +109,7 @@ * @param index index to examine * @return true if PoolItem::Get(index) will return non-NULL pointer */ - FORCEINLINE bool IsValidID(size_t index) + inline bool IsValidID(size_t index) { return index < this->first_unused && this->Get(index) != NULL; } @@ -119,7 +119,7 @@ * @param n number of items we want to allocate * @return true if 'n' items can be allocated */ - FORCEINLINE bool CanAllocate(size_t n = 1) + inline bool CanAllocate(size_t n = 1) { bool ret = this->items <= Tmax_size - n; #ifdef OTTD_ASSERT @@ -142,7 +142,7 @@ * @return pointer to allocated memory * @note can never fail (return NULL), use CanAllocate() to check first! */ - FORCEINLINE void *operator new(size_t size) + inline void *operator new(size_t size) { return Tpool->GetNew(size); } @@ -152,7 +152,7 @@ * @param p memory to free * @note the item has to be allocated in the pool! */ - FORCEINLINE void operator delete(void *p) + inline void operator delete(void *p) { Titem *pn = (Titem *)p; assert(pn == Tpool->Get(pn->index)); @@ -167,7 +167,7 @@ * @note can never fail (return NULL), use CanAllocate() to check first! * @pre index has to be unused! Else it will crash */ - FORCEINLINE void *operator new(size_t size, size_t index) + inline void *operator new(size_t size, size_t index) { return Tpool->GetNew(size, index); } @@ -180,7 +180,7 @@ * @note use of this is strongly discouraged * @pre the memory must not be allocated in the Pool! */ - FORCEINLINE void *operator new(size_t size, void *ptr) + inline void *operator new(size_t size, void *ptr) { for (size_t i = 0; i < Tpool->first_unused; i++) { /* Don't allow creating new objects over existing. @@ -202,7 +202,7 @@ * @param n number of items we want to allocate * @return true if 'n' items can be allocated */ - static FORCEINLINE bool CanAllocateItem(size_t n = 1) + static inline bool CanAllocateItem(size_t n = 1) { return Tpool->CanAllocate(n); } @@ -211,7 +211,7 @@ * Returns current state of pool cleaning - yes or no * @return true iff we are cleaning the pool now */ - static FORCEINLINE bool CleaningPool() + static inline bool CleaningPool() { return Tpool->cleaning; } @@ -221,7 +221,7 @@ * @param index index to examine * @return true if PoolItem::Get(index) will return non-NULL pointer */ - static FORCEINLINE bool IsValidID(size_t index) + static inline bool IsValidID(size_t index) { return Tpool->IsValidID(index); } @@ -232,7 +232,7 @@ * @return pointer to Titem * @pre index < this->first_unused */ - static FORCEINLINE Titem *Get(size_t index) + static inline Titem *Get(size_t index) { return Tpool->Get(index); } @@ -243,7 +243,7 @@ * @return pointer to Titem * @note returns NULL for invalid index */ - static FORCEINLINE Titem *GetIfValid(size_t index) + static inline Titem *GetIfValid(size_t index) { return index < Tpool->first_unused ? Tpool->Get(index) : NULL; } @@ -253,7 +253,7 @@ * all pool items. * @return first unused index */ - static FORCEINLINE size_t GetPoolSize() + static inline size_t GetPoolSize() { return Tpool->first_unused; } @@ -262,7 +262,7 @@ * Returns number of valid items in the pool * @return number of valid items in the pool */ - static FORCEINLINE size_t GetNumItems() + static inline size_t GetNumItems() { return Tpool->items; } @@ -274,7 +274,7 @@ * @note when this function is called, PoolItem::Get(index) == NULL. * @note it's called only when !CleaningPool() */ - static FORCEINLINE void PostDestructor(size_t index) { } + static inline void PostDestructor(size_t index) { } }; private:
--- a/src/core/random_func.hpp +++ b/src/core/random_func.hpp @@ -81,23 +81,23 @@ #define RandomRange(max) DoRandomRange(max, __LINE__, __FILE__) uint32 DoRandomRange(uint32 max, int line, const char *file); #else - static FORCEINLINE uint32 Random() + static inline uint32 Random() { return _random.Next(); } - static FORCEINLINE uint32 RandomRange(uint32 max) + static inline uint32 RandomRange(uint32 max) { return _random.Next(max); } #endif -static FORCEINLINE uint32 InteractiveRandom() +static inline uint32 InteractiveRandom() { return _interactive_random.Next(); } -static FORCEINLINE uint32 InteractiveRandomRange(uint32 max) +static inline uint32 InteractiveRandomRange(uint32 max) { return _interactive_random.Next(max); } @@ -117,7 +117,7 @@ * @param r The given randomize-number * @return True if the probability given by r is less or equal to (a/b) */ -static FORCEINLINE bool Chance16I(const uint a, const uint b, const uint32 r) +static inline bool Chance16I(const uint a, const uint b, const uint32 r) { assert(b != 0); return (((uint16)r * b + b / 2) >> 16) < a; @@ -136,7 +136,7 @@ #ifdef RANDOM_DEBUG #define Chance16(a, b) Chance16I(a, b, DoRandom(__LINE__, __FILE__)) #else -static FORCEINLINE bool Chance16(const uint a, const uint b) +static inline bool Chance16(const uint a, const uint b) { return Chance16I(a, b, Random()); } @@ -160,7 +160,7 @@ #ifdef RANDOM_DEBUG #define Chance16R(a, b, r) (r = DoRandom(__LINE__, __FILE__), Chance16I(a, b, r)) #else -static FORCEINLINE bool Chance16R(const uint a, const uint b, uint32 &r) +static inline bool Chance16R(const uint a, const uint b, uint32 &r) { r = Random(); return Chance16I(a, b, r);
--- a/src/core/smallmap_type.hpp +++ b/src/core/smallmap_type.hpp @@ -26,7 +26,7 @@ U second; /** Initializes this Pair with data */ - FORCEINLINE SmallPair(const T &first, const U &second) : first(first), second(second) { } + inline SmallPair(const T &first, const U &second) : first(first), second(second) { } }; /** @@ -45,16 +45,16 @@ typedef const Pair *const_iterator; /** Creates new SmallMap. Data are initialized in SmallVector constructor */ - FORCEINLINE SmallMap() { } + inline SmallMap() { } /** Data are freed in SmallVector destructor */ - FORCEINLINE ~SmallMap() { } + inline ~SmallMap() { } /** * Finds given key in this map * @param key key to find * @return &Pair(key, data) if found, this->End() if not */ - FORCEINLINE Pair *Find(const T &key) + inline Pair *Find(const T &key) { for (uint i = 0; i < this->items; i++) { if (key == this->data[i].first) return &this->data[i]; @@ -67,7 +67,7 @@ * @param key key to test * @return true iff the item is present */ - FORCEINLINE bool Contains(const T &key) + inline bool Contains(const T &key) { return this->Find(key) != this->End(); } @@ -77,7 +77,7 @@ * @param pair pair to remove * @note it has to be pointer to pair in this map. It is overwritten by the last item. */ - FORCEINLINE void Erase(Pair *pair) + inline void Erase(Pair *pair) { assert(pair >= this->Begin() && pair < this->End()); *pair = this->data[--this->items]; @@ -89,7 +89,7 @@ * @return true iff the key was found * @note last item is moved to its place, so don't increase your iterator if true is returned! */ - FORCEINLINE bool Erase(const T &key) + inline bool Erase(const T &key) { for (uint i = 0; i < this->items; i++) { if (key == this->data[i].first) { @@ -106,7 +106,7 @@ * @param data data * @return true iff the key wasn't already present */ - FORCEINLINE bool Insert(const T &key, const U &data) + inline bool Insert(const T &key, const U &data) { if (this->Contains(key)) return false; Pair *n = this->Append(); @@ -121,7 +121,7 @@ * @return data belonging to this key * @note if this key wasn't present, new entry is created */ - FORCEINLINE U &operator[](const T &key) + inline U &operator[](const T &key) { for (uint i = 0; i < this->items; i++) { if (key == this->data[i].first) return this->data[i].second; @@ -131,7 +131,7 @@ return n->second; } - FORCEINLINE void SortByKey() + inline void SortByKey() { QSortT(this->Begin(), this->items, KeySorter); }
--- a/src/core/smallvec_type.hpp +++ b/src/core/smallvec_type.hpp @@ -65,7 +65,7 @@ /** * Remove all items from the list. */ - FORCEINLINE void Clear() + inline void Clear() { /* In fact we just reset the item counter avoiding the need to * probably reallocate the same amount of memory the list was @@ -76,7 +76,7 @@ /** * Remove all items from the list and free allocated memory. */ - FORCEINLINE void Reset() + inline void Reset() { this->items = 0; this->capacity = 0; @@ -87,7 +87,7 @@ /** * Compact the list down to the smallest block size boundary. */ - FORCEINLINE void Compact() + inline void Compact() { uint capacity = Align(this->items, S); if (capacity >= this->capacity) return; @@ -101,7 +101,7 @@ * @param to_add the number of items to append * @return pointer to newly allocated item */ - FORCEINLINE T *Append(uint to_add = 1) + inline T *Append(uint to_add = 1) { uint begin = this->items; this->items += to_add; @@ -120,7 +120,7 @@ * @param item Item to search for * @return The position of the item, or End() when not present */ - FORCEINLINE const T *Find(const T &item) const + inline const T *Find(const T &item) const { const T *pos = this->Begin(); const T *end = this->End(); @@ -134,7 +134,7 @@ * @param item Item to search for * @return The position of the item, or End() when not present */ - FORCEINLINE T *Find(const T &item) + inline T *Find(const T &item) { T *pos = this->Begin(); const T *end = this->End(); @@ -148,7 +148,7 @@ * @param item Item to search for * @return The position of the item, or -1 when not present */ - FORCEINLINE int FindIndex(const T &item) + inline int FindIndex(const T &item) { int index = 0; T *pos = this->Begin(); @@ -166,7 +166,7 @@ * @param item Item to test for * @return true iff the item is present */ - FORCEINLINE bool Contains(const T &item) const + inline bool Contains(const T &item) const { return this->Find(item) != this->End(); } @@ -176,7 +176,7 @@ * @param item item to remove * @note it has to be pointer to item in this map. It is overwritten by the last item. */ - FORCEINLINE void Erase(T *item) + inline void Erase(T *item) { assert(item >= this->Begin() && item < this->End()); *item = this->data[--this->items]; @@ -188,7 +188,7 @@ * @param item Item to test for * @return true iff the item is was already present */ - FORCEINLINE bool Include(const T &item) + inline bool Include(const T &item) { bool is_member = this->Contains(item); if (!is_member) *this->Append() = item; @@ -198,7 +198,7 @@ /** * Get the number of items in the list. */ - FORCEINLINE uint Length() const + inline uint Length() const { return this->items; } @@ -208,7 +208,7 @@ * * @return the pointer to the first item */ - FORCEINLINE const T *Begin() const + inline const T *Begin() const { return this->data; } @@ -218,7 +218,7 @@ * * @return the pointer to the first item */ - FORCEINLINE T *Begin() + inline T *Begin() { return this->data; } @@ -228,7 +228,7 @@ * * @return the pointer behind the last valid item */ - FORCEINLINE const T *End() const + inline const T *End() const { return &this->data[this->items]; } @@ -238,7 +238,7 @@ * * @return the pointer behind the last valid item */ - FORCEINLINE T *End() + inline T *End() { return &this->data[this->items]; } @@ -249,7 +249,7 @@ * @param index the position of the item * @return the pointer to the item */ - FORCEINLINE const T *Get(uint index) const + inline const T *Get(uint index) const { /* Allow access to the 'first invalid' item */ assert(index <= this->items); @@ -262,7 +262,7 @@ * @param index the position of the item * @return the pointer to the item */ - FORCEINLINE T *Get(uint index) + inline T *Get(uint index) { /* Allow access to the 'first invalid' item */ assert(index <= this->items); @@ -275,7 +275,7 @@ * @param index the position of the item * @return the item */ - FORCEINLINE const T &operator[](uint index) const + inline const T &operator[](uint index) const { assert(index < this->items); return this->data[index]; @@ -287,7 +287,7 @@ * @param index the position of the item * @return the item */ - FORCEINLINE T &operator[](uint index) + inline T &operator[](uint index) { assert(index < this->items); return this->data[index]; @@ -316,7 +316,7 @@ /** * Remove all items from the list. */ - FORCEINLINE void Clear() + inline void Clear() { for (uint i = 0; i < this->items; i++) { free(this->data[i]); @@ -347,7 +347,7 @@ /** * Remove all items from the list. */ - FORCEINLINE void Clear() + inline void Clear() { for (uint i = 0; i < this->items; i++) { delete this->data[i];
--- a/src/core/sort_func.hpp +++ b/src/core/sort_func.hpp @@ -25,7 +25,7 @@ * @param desc Sort descending. */ template <typename T> -static FORCEINLINE void QSortT(T *base, uint num, int (CDECL *comparator)(const T*, const T*), bool desc = false) +static inline void QSortT(T *base, uint num, int (CDECL *comparator)(const T*, const T*), bool desc = false) { if (num < 2) return;
--- a/src/depot_base.h +++ b/src/depot_base.h @@ -29,7 +29,7 @@ Depot(TileIndex xy = INVALID_TILE) : xy(xy) {} ~Depot(); - static FORCEINLINE Depot *GetByTile(TileIndex tile) + static inline Depot *GetByTile(TileIndex tile) { return Depot::Get(GetDepotIndex(tile)); } @@ -40,7 +40,7 @@ * @param d The depot to compare to. * @return true iff their types are equal. */ - FORCEINLINE bool IsOfType(const Depot *d) const + inline bool IsOfType(const Depot *d) const { return GetTileType(d->xy) == GetTileType(this->xy); }
--- a/src/engine_base.h +++ b/src/engine_base.h @@ -116,7 +116,7 @@ * Check if the engine is a ground vehicle. * @return True iff the engine is a train or a road vehicle. */ - FORCEINLINE bool IsGroundVehicle() const + inline bool IsGroundVehicle() const { return this->type == VEH_TRAIN || this->type == VEH_ROAD; }
--- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -69,7 +69,7 @@ * Switch to new colour \a c. * @param c New colour to use. */ - FORCEINLINE void SetColour(TextColour c) + inline void SetColour(TextColour c) { assert(c >= TC_BLUE && c <= TC_BLACK); this->prev_colour = this->cur_colour; @@ -77,7 +77,7 @@ } /** Switch to previous colour. */ - FORCEINLINE void SetPreviousColour() + inline void SetPreviousColour() { Swap(this->cur_colour, this->prev_colour); } @@ -86,7 +86,7 @@ * Switch to using a new font \a f. * @param f New font to use. */ - FORCEINLINE void SetFontSize(FontSize f) + inline void SetFontSize(FontSize f) { this->fontsize = f; }
--- a/src/goal_base.h +++ b/src/goal_base.h @@ -30,12 +30,12 @@ /** * We need an (empty) constructor so struct isn't zeroed (as C++ standard states) */ - FORCEINLINE Goal() { } + inline Goal() { } /** * (Empty) destructor has to be defined else operator delete might be called with NULL parameter */ - FORCEINLINE ~Goal() { free(this->text); } + inline ~Goal() { free(this->text); } }; #define FOR_ALL_GOALS_FROM(var, start) FOR_ALL_ITEMS_FROM(Goal, goal_index, var, start)
--- a/src/ground_vehicle.hpp +++ b/src/ground_vehicle.hpp @@ -111,7 +111,7 @@ * Calculates the total slope resistance for this vehicle. * @return Slope resistance. */ - FORCEINLINE int32 GetSlopeResistance() const + inline int32 GetSlopeResistance() const { int32 incl = 0; @@ -132,7 +132,7 @@ * @pre The vehicle has to be at (or near to) a border of the tile, * directed towards tile centre */ - FORCEINLINE void UpdateZPositionAndInclination() + inline void UpdateZPositionAndInclination() { this->z_pos = GetSlopePixelZ(this->x_pos, this->y_pos); ClrBit(this->gv_flags, GVF_GOINGUP_BIT); @@ -157,7 +157,7 @@ * The faster code is used for trains and road vehicles unless they are * reversing on a sloped tile. */ - FORCEINLINE void UpdateZPosition() + inline void UpdateZPosition() { #if 0 /* The following code does this: */ @@ -229,7 +229,7 @@ * @param turned Indicates if the vehicle has turned. * @return Old height of the vehicle. */ - FORCEINLINE byte UpdateInclination(bool new_tile, bool turned) + inline byte UpdateInclination(bool new_tile, bool turned) { byte old_z = this->z_pos; @@ -246,99 +246,99 @@ /** * Set front engine state. */ - FORCEINLINE void SetFrontEngine() { SetBit(this->subtype, GVSF_FRONT); } + inline void SetFrontEngine() { SetBit(this->subtype, GVSF_FRONT); } /** * Remove the front engine state. */ - FORCEINLINE void ClearFrontEngine() { ClrBit(this->subtype, GVSF_FRONT); } + inline void ClearFrontEngine() { ClrBit(this->subtype, GVSF_FRONT); } /** * Set a vehicle to be an articulated part. */ - FORCEINLINE void SetArticulatedPart() { SetBit(this->subtype, GVSF_ARTICULATED_PART); } + inline void SetArticulatedPart() { SetBit(this->subtype, GVSF_ARTICULATED_PART); } /** * Clear a vehicle from being an articulated part. */ - FORCEINLINE void ClearArticulatedPart() { ClrBit(this->subtype, GVSF_ARTICULATED_PART); } + inline void ClearArticulatedPart() { ClrBit(this->subtype, GVSF_ARTICULATED_PART); } /** * Set a vehicle to be a wagon. */ - FORCEINLINE void SetWagon() { SetBit(this->subtype, GVSF_WAGON); } + inline void SetWagon() { SetBit(this->subtype, GVSF_WAGON); } /** * Clear wagon property. */ - FORCEINLINE void ClearWagon() { ClrBit(this->subtype, GVSF_WAGON); } + inline void ClearWagon() { ClrBit(this->subtype, GVSF_WAGON); } /** * Set engine status. */ - FORCEINLINE void SetEngine() { SetBit(this->subtype, GVSF_ENGINE); } + inline void SetEngine() { SetBit(this->subtype, GVSF_ENGINE); } /** * Clear engine status. */ - FORCEINLINE void ClearEngine() { ClrBit(this->subtype, GVSF_ENGINE); } + inline void ClearEngine() { ClrBit(this->subtype, GVSF_ENGINE); } /** * Set a vehicle as a free wagon. */ - FORCEINLINE void SetFreeWagon() { SetBit(this->subtype, GVSF_FREE_WAGON); } + inline void SetFreeWagon() { SetBit(this->subtype, GVSF_FREE_WAGON); } /** * Clear a vehicle from being a free wagon. */ - FORCEINLINE void ClearFreeWagon() { ClrBit(this->subtype, GVSF_FREE_WAGON); } + inline void ClearFreeWagon() { ClrBit(this->subtype, GVSF_FREE_WAGON); } /** * Set a vehicle as a multiheaded engine. */ - FORCEINLINE void SetMultiheaded() { SetBit(this->subtype, GVSF_MULTIHEADED); } + inline void SetMultiheaded() { SetBit(this->subtype, GVSF_MULTIHEADED); } /** * Clear multiheaded engine property. */ - FORCEINLINE void ClearMultiheaded() { ClrBit(this->subtype, GVSF_MULTIHEADED); } + inline void ClearMultiheaded() { ClrBit(this->subtype, GVSF_MULTIHEADED); } /** * Check if the vehicle is a free wagon (got no engine in front of it). * @return Returns true if the vehicle is a free wagon. */ - FORCEINLINE bool IsFreeWagon() const { return HasBit(this->subtype, GVSF_FREE_WAGON); } + inline bool IsFreeWagon() const { return HasBit(this->subtype, GVSF_FREE_WAGON); } /** * Check if a vehicle is an engine (can be first in a consist). * @return Returns true if vehicle is an engine. */ - FORCEINLINE bool IsEngine() const { return HasBit(this->subtype, GVSF_ENGINE); } + inline bool IsEngine() const { return HasBit(this->subtype, GVSF_ENGINE); } /** * Check if a vehicle is a wagon. * @return Returns true if vehicle is a wagon. */ - FORCEINLINE bool IsWagon() const { return HasBit(this->subtype, GVSF_WAGON); } + inline bool IsWagon() const { return HasBit(this->subtype, GVSF_WAGON); } /** * Check if the vehicle is a multiheaded engine. * @return Returns true if the vehicle is a multiheaded engine. */ - FORCEINLINE bool IsMultiheaded() const { return HasBit(this->subtype, GVSF_MULTIHEADED); } + inline bool IsMultiheaded() const { return HasBit(this->subtype, GVSF_MULTIHEADED); } /** * Tell if we are dealing with the rear end of a multiheaded engine. * @return True if the engine is the rear part of a dualheaded engine. */ - FORCEINLINE bool IsRearDualheaded() const { return this->IsMultiheaded() && !this->IsEngine(); } + inline bool IsRearDualheaded() const { return this->IsMultiheaded() && !this->IsEngine(); } /** * Update the GUI variant of the current speed of the vehicle. * Also mark the widget dirty when that is needed, i.e. when * the speed of this vehicle has changed. */ - FORCEINLINE void SetLastSpeed() + inline void SetLastSpeed() { if (this->cur_speed != this->gcache.last_speed) { SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, WID_VV_START_STOP); @@ -360,7 +360,7 @@ * @param max_speed The maximum speed here, in vehicle specific units. * @return Distance to drive. */ - FORCEINLINE uint DoUpdateSpeed(uint accel, int min_speed, int max_speed) + inline uint DoUpdateSpeed(uint accel, int min_speed, int max_speed) { uint spd = this->subspeed + accel; this->subspeed = (byte)spd;
--- a/src/house.h +++ b/src/house.h @@ -124,7 +124,7 @@ Money GetRemovalCost() const; - static FORCEINLINE HouseSpec *Get(size_t house_id) + static inline HouseSpec *Get(size_t house_id) { assert(house_id < HOUSE_MAX); extern HouseSpec _house_specs[];
--- a/src/industry.h +++ b/src/industry.h @@ -93,7 +93,7 @@ * @pre IsTileType(t, MP_INDUSTRY) * @return the industry */ - static FORCEINLINE Industry *GetByTile(TileIndex tile) + static inline Industry *GetByTile(TileIndex tile) { return Industry::Get(GetIndustryIndex(tile)); }
--- a/src/misc/array.hpp +++ b/src/misc/array.hpp @@ -30,7 +30,7 @@ SuperArray data; ///< array of arrays of items /** return first sub-array with free space for new item */ - FORCEINLINE SubArray& FirstFreeSubArray() + inline SubArray& FirstFreeSubArray() { uint super_size = data.Length(); if (super_size > 0) { @@ -42,11 +42,11 @@ public: /** implicit constructor */ - FORCEINLINE SmallArray() { } + inline SmallArray() { } /** Clear (destroy) all items */ - FORCEINLINE void Clear() {data.Clear();} + inline void Clear() {data.Clear();} /** Return actual number of items */ - FORCEINLINE uint Length() const + inline uint Length() const { uint super_size = data.Length(); if (super_size == 0) return 0; @@ -54,22 +54,22 @@ return (super_size - 1) * B + sub_size; } /** return true if array is empty */ - FORCEINLINE bool IsEmpty() { return data.IsEmpty(); } + inline bool IsEmpty() { return data.IsEmpty(); } /** return true if array is full */ - FORCEINLINE bool IsFull() { return data.IsFull() && data[N - 1].IsFull(); } + inline bool IsFull() { return data.IsFull() && data[N - 1].IsFull(); } /** allocate but not construct new item */ - FORCEINLINE T *Append() { return FirstFreeSubArray().Append(); } + inline T *Append() { return FirstFreeSubArray().Append(); } /** allocate and construct new item */ - FORCEINLINE T *AppendC() { return FirstFreeSubArray().AppendC(); } + inline T *AppendC() { return FirstFreeSubArray().AppendC(); } /** indexed access (non-const) */ - FORCEINLINE T& operator [] (uint index) + inline T& operator [] (uint index) { const SubArray& s = data[index / B]; T& item = s[index % B]; return item; } /** indexed access (const) */ - FORCEINLINE const T& operator [] (uint index) const + inline const T& operator [] (uint index) const { const SubArray& s = data[index / B]; const T& item = s[index % B];
--- a/src/misc/binaryheap.hpp +++ b/src/misc/binaryheap.hpp @@ -85,7 +85,7 @@ * @param item The proposed item for filling the gap * @return The (gap)position where the item fits */ - FORCEINLINE uint HeapifyDown(uint gap, T *item) + inline uint HeapifyDown(uint gap, T *item) { assert(gap != 0); @@ -121,7 +121,7 @@ * @param item The proposed item for filling the gap * @return The (gap)position where the item fits */ - FORCEINLINE uint HeapifyUp(uint gap, T *item) + inline uint HeapifyUp(uint gap, T *item) { assert(gap != 0); @@ -142,7 +142,7 @@ #if BINARYHEAP_CHECK /** Verify the heap consistency */ - FORCEINLINE void CheckConsistency() + inline void CheckConsistency() { for (uint child = 2; child <= this->items; child++) { uint parent = child / 2; @@ -157,28 +157,28 @@ * * @return The number of items in the queue */ - FORCEINLINE uint Length() const { return this->items; } + inline uint Length() const { return this->items; } /** * Test if the priority queue is empty. * * @return True if empty */ - FORCEINLINE bool IsEmpty() const { return this->items == 0; } + inline bool IsEmpty() const { return this->items == 0; } /** * Test if the priority queue is full. * * @return True if full. */ - FORCEINLINE bool IsFull() const { return this->items >= this->capacity; } + inline bool IsFull() const { return this->items >= this->capacity; } /** * Get the smallest item in the binary tree. * * @return The smallest item, or throw assert if empty. */ - FORCEINLINE T *Begin() + inline T *Begin() { assert(!this->IsEmpty()); return this->data[1]; @@ -191,7 +191,7 @@ * * @return The last item */ - FORCEINLINE T *End() + inline T *End() { return this->data[1 + this->items]; } @@ -201,7 +201,7 @@ * * @param new_item The pointer to the new item */ - FORCEINLINE void Include(T *new_item) + inline void Include(T *new_item) { if (this->IsFull()) { assert(this->capacity < UINT_MAX / 2); @@ -222,7 +222,7 @@ * * @return The pointer to the removed item */ - FORCEINLINE T *Shift() + inline T *Shift() { assert(!this->IsEmpty()); @@ -244,7 +244,7 @@ * * @param index The position of the item in the heap */ - FORCEINLINE void Remove(uint index) + inline void Remove(uint index) { if (index < this->items) { assert(index != 0); @@ -272,7 +272,7 @@ * @param item The reference to the item * @return The index of the item or zero if not found */ - FORCEINLINE uint FindIndex(const T &item) const + inline uint FindIndex(const T &item) const { if (this->IsEmpty()) return 0; for (T **ppI = this->data + 1, **ppLast = ppI + this->items; ppI <= ppLast; ppI++) { @@ -287,7 +287,7 @@ * Make the priority queue empty. * All remaining items will remain untouched. */ - FORCEINLINE void Clear() { this->items = 0; } + inline void Clear() { this->items = 0; } }; #endif /* BINARYHEAP_HPP */
--- a/src/misc/blob.hpp +++ b/src/misc/blob.hpp @@ -71,17 +71,17 @@ static const size_t header_size = sizeof(BlobHeader); /** default constructor - initializes empty blob */ - FORCEINLINE ByteBlob() { InitEmpty(); } + inline ByteBlob() { InitEmpty(); } /** copy constructor */ - FORCEINLINE ByteBlob(const ByteBlob &src) + inline ByteBlob(const ByteBlob &src) { InitEmpty(); AppendRaw(src); } /** move constructor - take ownership of blob data */ - FORCEINLINE ByteBlob(BlobHeader * const & src) + inline ByteBlob(BlobHeader * const & src) { assert(src != NULL); header = src; @@ -89,14 +89,14 @@ } /** destructor */ - FORCEINLINE ~ByteBlob() + inline ~ByteBlob() { Free(); } protected: /** all allocation should happen here */ - static FORCEINLINE BlobHeader *RawAlloc(size_t num_bytes) + static inline BlobHeader *RawAlloc(size_t num_bytes) { return (BlobHeader*)MallocT<byte>(num_bytes); } @@ -105,13 +105,13 @@ * Return header pointer to the static BlobHeader with * both items and capacity containing zero */ - static FORCEINLINE BlobHeader *Zero() + static inline BlobHeader *Zero() { return const_cast<BlobHeader *>(&ByteBlob::hdrEmpty[1]); } /** simple allocation policy - can be optimized later */ - static FORCEINLINE size_t AllocPolicy(size_t min_alloc) + static inline size_t AllocPolicy(size_t min_alloc) { if (min_alloc < (1 << 9)) { if (min_alloc < (1 << 5)) return (1 << 5); @@ -130,7 +130,7 @@ } /** all deallocations should happen here */ - static FORCEINLINE void RawFree(BlobHeader *p) + static inline void RawFree(BlobHeader *p) { /* Just to silence an unsilencable GCC 4.4+ warning. */ assert(p != ByteBlob::hdrEmpty); @@ -140,74 +140,74 @@ } /** initialize the empty blob */ - FORCEINLINE void InitEmpty() + inline void InitEmpty() { header = Zero(); } /** initialize blob by attaching it to the given header followed by data */ - FORCEINLINE void Init(BlobHeader *src) + inline void Init(BlobHeader *src) { header = &src[1]; } /** blob header accessor - use it rather than using the pointer arithmetics directly - non-const version */ - FORCEINLINE BlobHeader& Hdr() + inline BlobHeader& Hdr() { return *(header - 1); } /** blob header accessor - use it rather than using the pointer arithmetics directly - const version */ - FORCEINLINE const BlobHeader& Hdr() const + inline const BlobHeader& Hdr() const { return *(header - 1); } /** return reference to the actual blob size - used when the size needs to be modified */ - FORCEINLINE size_t& LengthRef() + inline size_t& LengthRef() { return Hdr().items; } public: /** return true if blob doesn't contain valid data */ - FORCEINLINE bool IsEmpty() const + inline bool IsEmpty() const { return Length() == 0; } /** return the number of valid data bytes in the blob */ - FORCEINLINE size_t Length() const + inline size_t Length() const { return Hdr().items; } /** return the current blob capacity in bytes */ - FORCEINLINE size_t Capacity() const + inline size_t Capacity() const { return Hdr().capacity; } /** return pointer to the first byte of data - non-const version */ - FORCEINLINE byte *Begin() + inline byte *Begin() { return data; } /** return pointer to the first byte of data - const version */ - FORCEINLINE const byte *Begin() const + inline const byte *Begin() const { return data; } /** invalidate blob's data - doesn't free buffer */ - FORCEINLINE void Clear() + inline void Clear() { LengthRef() = 0; } /** free the blob's memory */ - FORCEINLINE void Free() + inline void Free() { if (Capacity() > 0) { RawFree(&Hdr()); @@ -216,7 +216,7 @@ } /** append new bytes at the end of existing data bytes - reallocates if necessary */ - FORCEINLINE void AppendRaw(const void *p, size_t num_bytes) + inline void AppendRaw(const void *p, size_t num_bytes) { assert(p != NULL); if (num_bytes > 0) { @@ -225,7 +225,7 @@ } /** append bytes from given source blob to the end of existing data bytes - reallocates if necessary */ - FORCEINLINE void AppendRaw(const ByteBlob& src) + inline void AppendRaw(const ByteBlob& src) { if (!src.IsEmpty()) { memcpy(Append(src.Length()), src.Begin(), src.Length()); @@ -236,7 +236,7 @@ * Reallocate if there is no free space for num_bytes bytes. * @return pointer to the new data to be added */ - FORCEINLINE byte *Prepare(size_t num_bytes) + inline byte *Prepare(size_t num_bytes) { size_t new_size = Length() + num_bytes; if (new_size > Capacity()) SmartAlloc(new_size); @@ -247,7 +247,7 @@ * Increase Length() by num_bytes. * @return pointer to the new data added */ - FORCEINLINE byte *Append(size_t num_bytes) + inline byte *Append(size_t num_bytes) { byte *pNewData = Prepare(num_bytes); LengthRef() += num_bytes; @@ -281,7 +281,7 @@ } /** fixing the four bytes at the end of blob data - useful when blob is used to hold string */ - FORCEINLINE void FixTail() const + inline void FixTail() const { if (Capacity() > 0) { byte *p = &data[Length()]; @@ -317,73 +317,73 @@ }; /** Default constructor - makes new Blob ready to accept any data */ - FORCEINLINE CBlobT() + inline CBlobT() : base() {} /** Take ownership constructor */ - FORCEINLINE CBlobT(const OnTransfer& ot) + inline CBlobT(const OnTransfer& ot) : base(ot.header) {} /** Destructor - ensures that allocated memory (if any) is freed */ - FORCEINLINE ~CBlobT() + inline ~CBlobT() { Free(); } /** Check the validity of item index (only in debug mode) */ - FORCEINLINE void CheckIdx(size_t index) const + inline void CheckIdx(size_t index) const { assert(index < Size()); } /** Return pointer to the first data item - non-const version */ - FORCEINLINE T *Data() + inline T *Data() { return (T*)base::Begin(); } /** Return pointer to the first data item - const version */ - FORCEINLINE const T *Data() const + inline const T *Data() const { return (const T*)base::Begin(); } /** Return pointer to the index-th data item - non-const version */ - FORCEINLINE T *Data(size_t index) + inline T *Data(size_t index) { CheckIdx(index); return (Data() + index); } /** Return pointer to the index-th data item - const version */ - FORCEINLINE const T *Data(size_t index) const + inline const T *Data(size_t index) const { CheckIdx(index); return (Data() + index); } /** Return number of items in the Blob */ - FORCEINLINE size_t Size() const + inline size_t Size() const { return (base::Length() / type_size); } /** Return total number of items that can fit in the Blob without buffer reallocation */ - FORCEINLINE size_t MaxSize() const + inline size_t MaxSize() const { return (base::Capacity() / type_size); } /** Return number of additional items that can fit in the Blob without buffer reallocation */ - FORCEINLINE size_t GetReserve() const + inline size_t GetReserve() const { return ((base::Capacity() - base::Length()) / type_size); } /** Grow number of data items in Blob by given number - doesn't construct items */ - FORCEINLINE T *GrowSizeNC(size_t num_items) + inline T *GrowSizeNC(size_t num_items) { return (T*)base::Append(num_items * type_size); } @@ -392,12 +392,12 @@ * Ensures that given number of items can be added to the end of Blob. Returns pointer to the * first free (unused) item */ - FORCEINLINE T *MakeFreeSpace(size_t num_items) + inline T *MakeFreeSpace(size_t num_items) { return (T*)base::Prepare(num_items * type_size); } - FORCEINLINE OnTransfer Transfer() + inline OnTransfer Transfer() { return OnTransfer(*this); }
--- a/src/misc/countedptr.hpp +++ b/src/misc/countedptr.hpp @@ -35,64 +35,64 @@ public: /** default (NULL) construct or construct from a raw pointer */ - FORCEINLINE CCountedPtr(Tcls *pObj = NULL) : m_pT(pObj) {AddRef();} + inline CCountedPtr(Tcls *pObj = NULL) : m_pT(pObj) {AddRef();} /** copy constructor (invoked also when initializing from another smart ptr) */ - FORCEINLINE CCountedPtr(const CCountedPtr& src) : m_pT(src.m_pT) {AddRef();} + inline CCountedPtr(const CCountedPtr& src) : m_pT(src.m_pT) {AddRef();} /** destructor releasing the reference */ - FORCEINLINE ~CCountedPtr() {Release();} + inline ~CCountedPtr() {Release();} protected: /** add one ref to the underlaying object */ - FORCEINLINE void AddRef() {if (m_pT != NULL) m_pT->AddRef();} + inline void AddRef() {if (m_pT != NULL) m_pT->AddRef();} public: /** release smart pointer (and decrement ref count) if not null */ - FORCEINLINE void Release() {if (m_pT != NULL) {Tcls *pT = m_pT; m_pT = NULL; pT->Release();}} + inline void Release() {if (m_pT != NULL) {Tcls *pT = m_pT; m_pT = NULL; pT->Release();}} /** dereference of smart pointer - const way */ - FORCEINLINE const Tcls *operator -> () const {assert(m_pT != NULL); return m_pT;} + inline const Tcls *operator -> () const {assert(m_pT != NULL); return m_pT;} /** dereference of smart pointer - non const way */ - FORCEINLINE Tcls *operator -> () {assert(m_pT != NULL); return m_pT;} + inline Tcls *operator -> () {assert(m_pT != NULL); return m_pT;} /** raw pointer casting operator - const way */ - FORCEINLINE operator const Tcls*() const {assert(m_pT == NULL); return m_pT;} + inline operator const Tcls*() const {assert(m_pT == NULL); return m_pT;} /** raw pointer casting operator - non-const way */ - FORCEINLINE operator Tcls*() {return m_pT;} + inline operator Tcls*() {return m_pT;} /** operator & to support output arguments */ - FORCEINLINE Tcls** operator &() {assert(m_pT == NULL); return &m_pT;} + inline Tcls** operator &() {assert(m_pT == NULL); return &m_pT;} /** assignment operator from raw ptr */ - FORCEINLINE CCountedPtr& operator = (Tcls *pT) {Assign(pT); return *this;} + inline CCountedPtr& operator = (Tcls *pT) {Assign(pT); return *this;} /** assignment operator from another smart ptr */ - FORCEINLINE CCountedPtr& operator = (const CCountedPtr& src) {Assign(src.m_pT); return *this;} + inline CCountedPtr& operator = (const CCountedPtr& src) {Assign(src.m_pT); return *this;} /** assignment operator helper */ - FORCEINLINE void Assign(Tcls *pT); + inline void Assign(Tcls *pT); /** one way how to test for NULL value */ - FORCEINLINE bool IsNull() const {return m_pT == NULL;} + inline bool IsNull() const {return m_pT == NULL;} /** another way how to test for NULL value */ - //FORCEINLINE bool operator == (const CCountedPtr& sp) const {return m_pT == sp.m_pT;} + //inline bool operator == (const CCountedPtr& sp) const {return m_pT == sp.m_pT;} /** yet another way how to test for NULL value */ - //FORCEINLINE bool operator != (const CCountedPtr& sp) const {return m_pT != sp.m_pT;} + //inline bool operator != (const CCountedPtr& sp) const {return m_pT != sp.m_pT;} /** assign pointer w/o incrementing ref count */ - FORCEINLINE void Attach(Tcls *pT) {Release(); m_pT = pT;} + inline void Attach(Tcls *pT) {Release(); m_pT = pT;} /** detach pointer w/o decrementing ref count */ - FORCEINLINE Tcls *Detach() {Tcls *pT = m_pT; m_pT = NULL; return pT;} + inline Tcls *Detach() {Tcls *pT = m_pT; m_pT = NULL; return pT;} }; template <class Tcls_> -FORCEINLINE void CCountedPtr<Tcls_>::Assign(Tcls *pT) +inline void CCountedPtr<Tcls_>::Assign(Tcls *pT) { /* if they are the same, we do nothing */ if (pT != m_pT) {
--- a/src/misc/fixedsizearray.hpp +++ b/src/misc/fixedsizearray.hpp @@ -41,13 +41,13 @@ T *data; /** return reference to the array header (non-const) */ - FORCEINLINE ArrayHeader& Hdr() { return *(ArrayHeader*)(((byte*)data) - HeaderSize); } + inline ArrayHeader& Hdr() { return *(ArrayHeader*)(((byte*)data) - HeaderSize); } /** return reference to the array header (const) */ - FORCEINLINE const ArrayHeader& Hdr() const { return *(ArrayHeader*)(((byte*)data) - HeaderSize); } + inline const ArrayHeader& Hdr() const { return *(ArrayHeader*)(((byte*)data) - HeaderSize); } /** return reference to the block reference counter */ - FORCEINLINE uint& RefCnt() { return Hdr().reference_count; } + inline uint& RefCnt() { return Hdr().reference_count; } /** return reference to number of used items */ - FORCEINLINE uint& SizeRef() { return Hdr().items; } + inline uint& SizeRef() { return Hdr().items; } public: /** Default constructor. Preallocate space for items and header, then initialize header. */ @@ -83,7 +83,7 @@ } /** Clear (destroy) all items */ - FORCEINLINE void Clear() + inline void Clear() { /* Walk through all allocated items backward and destroy them * Note: this->Length() can be zero. In that case data[this->Length() - 1] is evaluated unsigned @@ -96,19 +96,19 @@ } /** return number of used items */ - FORCEINLINE uint Length() const { return Hdr().items; } + inline uint Length() const { return Hdr().items; } /** return true if array is full */ - FORCEINLINE bool IsFull() const { return Length() >= C; } + inline bool IsFull() const { return Length() >= C; } /** return true if array is empty */ - FORCEINLINE bool IsEmpty() const { return Length() <= 0; } + inline bool IsEmpty() const { return Length() <= 0; } /** add (allocate), but don't construct item */ - FORCEINLINE T *Append() { assert(!IsFull()); return &data[SizeRef()++]; } + inline T *Append() { assert(!IsFull()); return &data[SizeRef()++]; } /** add and construct item using default constructor */ - FORCEINLINE T *AppendC() { T *item = Append(); new(item)T; return item; } + inline T *AppendC() { T *item = Append(); new(item)T; return item; } /** return item by index (non-const version) */ - FORCEINLINE T& operator [] (uint index) { assert(index < Length()); return data[index]; } + inline T& operator [] (uint index) { assert(index < Length()); return data[index]; } /** return item by index (const version) */ - FORCEINLINE const T& operator [] (uint index) const { assert(index < Length()); return data[index]; } + inline const T& operator [] (uint index) const { assert(index < Length()); return data[index]; } }; #endif /* FIXEDSIZEARRAY_HPP */
--- a/src/misc/hashtable.hpp +++ b/src/misc/hashtable.hpp @@ -21,13 +21,13 @@ Titem_ *m_pFirst; - FORCEINLINE CHashTableSlotT() : m_pFirst(NULL) {} + inline CHashTableSlotT() : m_pFirst(NULL) {} /** hash table slot helper - clears the slot by simple forgetting its items */ - FORCEINLINE void Clear() {m_pFirst = NULL;} + inline void Clear() {m_pFirst = NULL;} /** hash table slot helper - linear search for item with given key through the given blob - const version */ - FORCEINLINE const Titem_ *Find(const Key& key) const + inline const Titem_ *Find(const Key& key) const { for (const Titem_ *pItem = m_pFirst; pItem != NULL; pItem = pItem->GetHashNext()) { if (pItem->GetKey() == key) { @@ -39,7 +39,7 @@ } /** hash table slot helper - linear search for item with given key through the given blob - non-const version */ - FORCEINLINE Titem_ *Find(const Key& key) + inline Titem_ *Find(const Key& key) { for (Titem_ *pItem = m_pFirst; pItem != NULL; pItem = pItem->GetHashNext()) { if (pItem->GetKey() == key) { @@ -51,7 +51,7 @@ } /** hash table slot helper - add new item to the slot */ - FORCEINLINE void Attach(Titem_& new_item) + inline void Attach(Titem_& new_item) { assert(new_item.GetHashNext() == NULL); new_item.SetHashNext(m_pFirst); @@ -59,7 +59,7 @@ } /** hash table slot helper - remove item from a slot */ - FORCEINLINE bool Detach(Titem_& item_to_remove) + inline bool Detach(Titem_& item_to_remove) { if (m_pFirst == &item_to_remove) { m_pFirst = item_to_remove.GetHashNext(); @@ -81,7 +81,7 @@ } /** hash table slot helper - remove and return item from a slot */ - FORCEINLINE Titem_ *Detach(const Key& key) + inline Titem_ *Detach(const Key& key) { /* do we have any items? */ if (m_pFirst == NULL) { @@ -150,13 +150,13 @@ public: /* default constructor */ - FORCEINLINE CHashTableT() : m_num_items(0) + inline CHashTableT() : m_num_items(0) { } protected: /** static helper - return hash for the given key modulo number of slots */ - FORCEINLINE static int CalcHash(const Tkey& key) + inline static int CalcHash(const Tkey& key) { int32 hash = key.CalcHash(); if ((8 * Thash_bits) < 32) hash ^= hash >> (min(8 * Thash_bits, 31)); @@ -168,14 +168,14 @@ } /** static helper - return hash for the given item modulo number of slots */ - FORCEINLINE static int CalcHash(const Titem_& item) {return CalcHash(item.GetKey());} + inline static int CalcHash(const Titem_& item) {return CalcHash(item.GetKey());} public: /** item count */ - FORCEINLINE int Count() const {return m_num_items;} + inline int Count() const {return m_num_items;} /** simple clear - forget all items - used by CSegmentCostCacheT.Flush() */ - FORCEINLINE void Clear() {for (int i = 0; i < Tcapacity; i++) m_slots[i].Clear();} + inline void Clear() {for (int i = 0; i < Tcapacity; i++) m_slots[i].Clear();} /** const item search */ const Titem_ *Find(const Tkey& key) const
--- a/src/misc/str.hpp +++ b/src/misc/str.hpp @@ -24,24 +24,24 @@ typedef CBlobT<char> base; ///< base class /** Create an empty CStrT */ - FORCEINLINE CStrA() + inline CStrA() { } /** Copy constructor */ - FORCEINLINE CStrA(const CStrA &src) : base(src) + inline CStrA(const CStrA &src) : base(src) { base::FixTail(); } /** Take over ownership constructor */ - FORCEINLINE CStrA(const OnTransfer& ot) + inline CStrA(const OnTransfer& ot) : base(ot) { } /** Grow the actual buffer and fix the trailing zero at the end. */ - FORCEINLINE char *GrowSizeNC(uint count) + inline char *GrowSizeNC(uint count) { char *ret = base::GrowSizeNC(count); base::FixTail(); @@ -49,7 +49,7 @@ } /** Append zero-ended C string. */ - FORCEINLINE void AppendStr(const char *str) + inline void AppendStr(const char *str) { if (!StrEmpty(str)) { base::AppendRaw(str, strlen(str)); @@ -58,7 +58,7 @@ } /** Append another CStrA. */ - FORCEINLINE void Append(const CStrA &src) + inline void Append(const CStrA &src) { if (src.Length() > 0) { base::AppendRaw(src); @@ -67,7 +67,7 @@ } /** Assignment from C string. */ - FORCEINLINE CStrA &operator = (const char *src) + inline CStrA &operator = (const char *src) { base::Clear(); AppendStr(src); @@ -75,7 +75,7 @@ } /** Assignment from another CStrA. */ - FORCEINLINE CStrA &operator = (const CStrA &src) + inline CStrA &operator = (const CStrA &src) { if (&src != this) { base::Clear(); @@ -86,7 +86,7 @@ } /** Lower-than operator (to support stl collections) */ - FORCEINLINE bool operator < (const CStrA &other) const + inline bool operator < (const CStrA &other) const { return strcmp(base::Data(), other.Data()) < 0; }
--- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -207,7 +207,7 @@ public: ByteReader(byte *data, byte *end) : data(data), end(end) { } - FORCEINLINE byte ReadByte() + inline byte ReadByte() { if (data < end) return *(data)++; throw OTTDByteReaderSignal(); @@ -261,22 +261,22 @@ return string; } - FORCEINLINE size_t Remaining() const + inline size_t Remaining() const { return end - data; } - FORCEINLINE bool HasData(size_t count = 1) const + inline bool HasData(size_t count = 1) const { return data + count <= end; } - FORCEINLINE byte *Data() + inline byte *Data() { return data; } - FORCEINLINE void Skip(size_t len) + inline void Skip(size_t len) { data += len; /* It is valid to move the buffer to exactly the end of the data,
--- a/src/newgrf_airport.h +++ b/src/newgrf_airport.h @@ -45,7 +45,7 @@ { } - FORCEINLINE TileIterator& operator ++() + inline TileIterator& operator ++() { this->att++; if (this->att->ti.x == -0x80) {
--- a/src/newgrf_config.h +++ b/src/newgrf_config.h @@ -89,7 +89,7 @@ * @param md5sum Expected md5sum, may be \c NULL (in which case, do not check it). * @return the object has the provided grfid and md5sum. */ - FORCEINLINE bool HasGrfIdentifier(uint32 grfid, const uint8 *md5sum) const + inline bool HasGrfIdentifier(uint32 grfid, const uint8 *md5sum) const { if (this->grfid != grfid) return false; if (md5sum == NULL) return true;
--- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -839,7 +839,7 @@ * @param c grf to display. * @return Palette for the sprite. */ - FORCEINLINE PaletteID GetPalette(const GRFConfig *c) const + inline PaletteID GetPalette(const GRFConfig *c) const { PaletteID pal;
--- a/src/pathfinder/follow_track.hpp +++ b/src/pathfinder/follow_track.hpp @@ -53,25 +53,25 @@ CPerformanceTimer *m_pPerf; RailTypes m_railtypes; - FORCEINLINE CFollowTrackT(const VehicleType *v = NULL, RailTypes railtype_override = INVALID_RAILTYPES, CPerformanceTimer *pPerf = NULL) + inline CFollowTrackT(const VehicleType *v = NULL, RailTypes railtype_override = INVALID_RAILTYPES, CPerformanceTimer *pPerf = NULL) { Init(v, railtype_override, pPerf); } - FORCEINLINE CFollowTrackT(Owner o, RailTypes railtype_override = INVALID_RAILTYPES, CPerformanceTimer *pPerf = NULL) + inline CFollowTrackT(Owner o, RailTypes railtype_override = INVALID_RAILTYPES, CPerformanceTimer *pPerf = NULL) { m_veh = NULL; Init(o, railtype_override, pPerf); } - FORCEINLINE void Init(const VehicleType *v, RailTypes railtype_override, CPerformanceTimer *pPerf) + inline void Init(const VehicleType *v, RailTypes railtype_override, CPerformanceTimer *pPerf) { assert(!IsRailTT() || (v != NULL && v->type == VEH_TRAIN)); m_veh = v; Init(v != NULL ? v->owner : INVALID_OWNER, IsRailTT() && railtype_override == INVALID_RAILTYPES ? Train::From(v)->compatible_railtypes : railtype_override, pPerf); } - FORCEINLINE void Init(Owner o, RailTypes railtype_override, CPerformanceTimer *pPerf) + inline void Init(Owner o, RailTypes railtype_override, CPerformanceTimer *pPerf) { assert((!IsRoadTT() || m_veh != NULL) && (!IsRailTT() || railtype_override != INVALID_RAILTYPES)); m_veh_owner = o; @@ -86,16 +86,16 @@ m_railtypes = railtype_override; } - FORCEINLINE static TransportType TT() {return Ttr_type_;} - FORCEINLINE static bool IsWaterTT() {return TT() == TRANSPORT_WATER;} - FORCEINLINE static bool IsRailTT() {return TT() == TRANSPORT_RAIL;} - FORCEINLINE bool IsTram() {return IsRoadTT() && HasBit(RoadVehicle::From(m_veh)->compatible_roadtypes, ROADTYPE_TRAM);} - FORCEINLINE static bool IsRoadTT() {return TT() == TRANSPORT_ROAD;} - FORCEINLINE static bool Allow90degTurns() {return T90deg_turns_allowed_;} - FORCEINLINE static bool DoTrackMasking() {return IsRailTT() && Tmask_reserved_tracks;} + inline static TransportType TT() {return Ttr_type_;} + inline static bool IsWaterTT() {return TT() == TRANSPORT_WATER;} + inline static bool IsRailTT() {return TT() == TRANSPORT_RAIL;} + inline bool IsTram() {return IsRoadTT() && HasBit(RoadVehicle::From(m_veh)->compatible_roadtypes, ROADTYPE_TRAM);} + inline static bool IsRoadTT() {return TT() == TRANSPORT_ROAD;} + inline static bool Allow90degTurns() {return T90deg_turns_allowed_;} + inline static bool DoTrackMasking() {return IsRailTT() && Tmask_reserved_tracks;} /** Tests if a tile is a road tile with a single tramtrack (tram can reverse) */ - FORCEINLINE DiagDirection GetSingleTramBit(TileIndex tile) + inline DiagDirection GetSingleTramBit(TileIndex tile) { assert(IsTram()); // this function shouldn't be called in other cases @@ -189,7 +189,7 @@ protected: /** Follow the m_exitdir from m_old_tile and fill m_new_tile and m_tiles_skipped */ - FORCEINLINE void FollowTileExit() + inline void FollowTileExit() { m_is_station = m_is_bridge = m_is_tunnel = false; m_tiles_skipped = 0; @@ -227,7 +227,7 @@ } /** stores track status (available trackdirs) for the new tile into m_new_td_bits */ - FORCEINLINE bool QueryNewTileTrackStatus() + inline bool QueryNewTileTrackStatus() { CPerfStart perf(*m_pPerf); if (IsRailTT() && IsPlainRailTile(m_new_tile)) { @@ -257,7 +257,7 @@ } /** return true if we can leave m_old_tile in m_exitdir */ - FORCEINLINE bool CanExitOldTile() + inline bool CanExitOldTile() { /* road stop can be left at one direction only unless it's a drive-through stop */ if (IsRoadTT() && IsStandardRoadStopTile(m_old_tile)) { @@ -289,7 +289,7 @@ } /** return true if we can enter m_new_tile from m_exitdir */ - FORCEINLINE bool CanEnterNewTile() + inline bool CanEnterNewTile() { if (IsRoadTT() && IsStandardRoadStopTile(m_new_tile)) { /* road stop can be entered from one direction only unless it's a drive-through stop */ @@ -386,7 +386,7 @@ } /** return true if we must reverse (in depots and single tram bits) */ - FORCEINLINE bool ForcedReverse() + inline bool ForcedReverse() { /* rail and road depots cause reversing */ if (!IsWaterTT() && IsDepotTypeTile(m_old_tile, TT())) { @@ -417,7 +417,7 @@ } /** return true if we successfully reversed at end of road/track */ - FORCEINLINE bool TryReverse() + inline bool TryReverse() { if (IsRoadTT() && !IsTram()) { /* if we reached the end of road, we can reverse the RV and continue moving */
--- a/src/pathfinder/npf/queue.h +++ b/src/pathfinder/npf/queue.h @@ -43,7 +43,7 @@ * @param i Element to access (starts at offset \c 1). * @return Value of the element. */ - FORCEINLINE BinaryHeapNode &GetElement(uint i) + inline BinaryHeapNode &GetElement(uint i) { assert(i > 0); return this->elements[(i - 1) >> BINARY_HEAP_BLOCKSIZE_BITS][(i - 1) & BINARY_HEAP_BLOCKSIZE_MASK]; @@ -96,7 +96,7 @@ /** * Gets the current size of the hash. */ - FORCEINLINE uint GetSize() const + inline uint GetSize() const { return this->size; }
--- a/src/pathfinder/pf_performance_timer.hpp +++ b/src/pathfinder/pf_performance_timer.hpp @@ -21,27 +21,27 @@ CPerformanceTimer() : m_start(0), m_acc(0) {} - FORCEINLINE void Start() + inline void Start() { m_start = QueryTime(); } - FORCEINLINE void Stop() + inline void Stop() { m_acc += QueryTime() - m_start; } - FORCEINLINE int Get(int64 coef) + inline int Get(int64 coef) { return (int)(m_acc * coef / QueryFrequency()); } - FORCEINLINE int64 QueryTime() + inline int64 QueryTime() { return ottd_rdtsc(); } - FORCEINLINE int64 QueryFrequency() + inline int64 QueryFrequency() { return ((int64)2200 * 1000000); } @@ -51,17 +51,17 @@ { CPerformanceTimer *m_pperf; - FORCEINLINE CPerfStartReal(CPerformanceTimer& perf) : m_pperf(&perf) + inline CPerfStartReal(CPerformanceTimer& perf) : m_pperf(&perf) { if (m_pperf != NULL) m_pperf->Start(); } - FORCEINLINE ~CPerfStartReal() + inline ~CPerfStartReal() { Stop(); } - FORCEINLINE void Stop() + inline void Stop() { if (m_pperf != NULL) { m_pperf->Stop(); @@ -72,9 +72,9 @@ struct CPerfStartFake { - FORCEINLINE CPerfStartFake(CPerformanceTimer& perf) {} - FORCEINLINE ~CPerfStartFake() {} - FORCEINLINE void Stop() {} + inline CPerfStartFake(CPerformanceTimer& perf) {} + inline ~CPerfStartFake() {} + inline void Stop() {} }; typedef CPerfStartFake CPerfStart;
--- a/src/pathfinder/yapf/nodelist.hpp +++ b/src/pathfinder/yapf/nodelist.hpp @@ -62,26 +62,26 @@ } /** return number of open nodes */ - FORCEINLINE int OpenCount() + inline int OpenCount() { return m_open.Count(); } /** return number of closed nodes */ - FORCEINLINE int ClosedCount() + inline int ClosedCount() { return m_closed.Count(); } /** allocate new data item from m_arr */ - FORCEINLINE Titem_ *CreateNewNode() + inline Titem_ *CreateNewNode() { if (m_new_node == NULL) m_new_node = m_arr.AppendC(); return m_new_node; } /** Notify the nodelist that we don't want to discard the given node. */ - FORCEINLINE void FoundBestNode(Titem_& item) + inline void FoundBestNode(Titem_& item) { /* for now it is enough to invalidate m_new_node if it is our given node */ if (&item == m_new_node) { @@ -91,7 +91,7 @@ } /** insert given item as open node (into m_open and m_open_queue) */ - FORCEINLINE void InsertOpenNode(Titem_& item) + inline void InsertOpenNode(Titem_& item) { assert(m_closed.Find(item.GetKey()) == NULL); m_open.Push(item); @@ -102,7 +102,7 @@ } /** return the best open node */ - FORCEINLINE Titem_ *GetBestOpenNode() + inline Titem_ *GetBestOpenNode() { if (!m_open_queue.IsEmpty()) { return m_open_queue.Begin(); @@ -111,7 +111,7 @@ } /** remove and return the best open node */ - FORCEINLINE Titem_ *PopBestOpenNode() + inline Titem_ *PopBestOpenNode() { if (!m_open_queue.IsEmpty()) { Titem_ *item = m_open_queue.Shift(); @@ -122,14 +122,14 @@ } /** return the open node specified by a key or NULL if not found */ - FORCEINLINE Titem_ *FindOpenNode(const Key& key) + inline Titem_ *FindOpenNode(const Key& key) { Titem_ *item = m_open.Find(key); return item; } /** remove and return the open node specified by a key */ - FORCEINLINE Titem_& PopOpenNode(const Key& key) + inline Titem_& PopOpenNode(const Key& key) { Titem_& item = m_open.Pop(key); uint idxPop = m_open_queue.FindIndex(item); @@ -138,23 +138,23 @@ } /** close node */ - FORCEINLINE void InsertClosedNode(Titem_& item) + inline void InsertClosedNode(Titem_& item) { assert(m_open.Find(item.GetKey()) == NULL); m_closed.Push(item); } /** return the closed node specified by a key or NULL if not found */ - FORCEINLINE Titem_ *FindClosedNode(const Key& key) + inline Titem_ *FindClosedNode(const Key& key) { Titem_ *item = m_closed.Find(key); return item; } /** The number of items. */ - FORCEINLINE int TotalCount() {return m_arr.Length();} + inline int TotalCount() {return m_arr.Length();} /** Get a particular item. */ - FORCEINLINE Titem_& ItemAt(int idx) {return m_arr[idx];} + inline Titem_& ItemAt(int idx) {return m_arr[idx];} /** Helper for creating output of this array. */ template <class D> void Dump(D &dmp) const
--- a/src/pathfinder/yapf/yapf.hpp +++ b/src/pathfinder/yapf/yapf.hpp @@ -18,7 +18,7 @@ #include "yapf.h" //#undef FORCEINLINE -//#define FORCEINLINE inline +//#define inline inline #include "../../misc/blob.hpp" #include "../../misc/str.hpp"
--- a/src/pathfinder/yapf/yapf_base.hpp +++ b/src/pathfinder/yapf/yapf_base.hpp @@ -37,11 +37,11 @@ * Requrements to your pathfinder class derived from CYapfBaseT: * ------------------------------------------------------------- * Your pathfinder derived class needs to implement following methods: - * FORCEINLINE void PfSetStartupNodes() - * FORCEINLINE void PfFollowNode(Node& org) - * FORCEINLINE bool PfCalcCost(Node& n) - * FORCEINLINE bool PfCalcEstimate(Node& n) - * FORCEINLINE bool PfDetectDestination(Node& n) + * inline void PfSetStartupNodes() + * inline void PfFollowNode(Node& org) + * inline bool PfCalcCost(Node& n) + * inline bool PfCalcEstimate(Node& n) + * inline bool PfDetectDestination(Node& n) * * For more details about those methods, look at the end of CYapfBaseT * declaration. There are some examples. For another example look at @@ -80,7 +80,7 @@ public: /** default constructor */ - FORCEINLINE CYapfBaseT() + inline CYapfBaseT() : m_pBestDestNode(NULL) , m_pBestIntermediateNode(NULL) , m_settings(&_settings_game.pf.yapf) @@ -97,14 +97,14 @@ protected: /** to access inherited path finder */ - FORCEINLINE Tpf& Yapf() + inline Tpf& Yapf() { return *static_cast<Tpf*>(this); } public: /** return current settings (can be custom - company based - but later) */ - FORCEINLINE const YAPFSettings& PfGetSettings() const + inline const YAPFSettings& PfGetSettings() const { return *m_settings; } @@ -182,7 +182,7 @@ * If path was found return the best node that has reached the destination. Otherwise * return the best visited node (which was nearest to the destination). */ - FORCEINLINE Node *GetBestNode() + inline Node *GetBestNode() { return (m_pBestDestNode != NULL) ? m_pBestDestNode : m_pBestIntermediateNode; } @@ -191,14 +191,14 @@ * Calls NodeList::CreateNewNode() - allocates new node that can be filled and used * as argument for AddStartupNode() or AddNewNode() */ - FORCEINLINE Node& CreateNewNode() + inline Node& CreateNewNode() { Node& node = *m_nodes.CreateNewNode(); return node; } /** Add new node (created by CreateNewNode and filled with data) into open list */ - FORCEINLINE void AddStartupNode(Node& n) + inline void AddStartupNode(Node& n) { Yapf().PfNodeCacheFetch(n); /* insert the new node only if it is not there */ @@ -212,7 +212,7 @@ } /** add multiple nodes - direct children of the given node */ - FORCEINLINE void AddMultipleNodes(Node *parent, const TrackFollower &tf) + inline void AddMultipleNodes(Node *parent, const TrackFollower &tf) { bool is_choice = (KillFirstBit(tf.m_new_td_bits) != TRACKDIR_BIT_NONE); for (TrackdirBits rtds = tf.m_new_td_bits; rtds != TRACKDIR_BIT_NONE; rtds = KillFirstBit(rtds)) { @@ -315,7 +315,7 @@ #if 0 /** Example: PfSetStartupNodes() - set source (origin) nodes */ - FORCEINLINE void PfSetStartupNodes() + inline void PfSetStartupNodes() { /* example: */ Node& n1 = *base::m_nodes.CreateNewNode(); @@ -326,7 +326,7 @@ } /** Example: PfFollowNode() - set following (child) nodes of the given node */ - FORCEINLINE void PfFollowNode(Node& org) + inline void PfFollowNode(Node& org) { for (each follower of node org) { Node& n = *base::m_nodes.CreateNewNode(); @@ -339,7 +339,7 @@ } /** Example: PfCalcCost() - set path cost from origin to the given node */ - FORCEINLINE bool PfCalcCost(Node& n) + inline bool PfCalcCost(Node& n) { /* evaluate last step cost */ int cost = ...; @@ -349,7 +349,7 @@ } /** Example: PfCalcEstimate() - set path cost estimate from origin to the target through given node */ - FORCEINLINE bool PfCalcEstimate(Node& n) + inline bool PfCalcEstimate(Node& n) { /* evaluate the distance to our destination */ int distance = ...; @@ -359,7 +359,7 @@ } /** Example: PfDetectDestination() - return true if the given node is our destination */ - FORCEINLINE bool PfDetectDestination(Node& n) + inline bool PfDetectDestination(Node& n) { bool bDest = (n.m_key.m_x == m_x2) && (n.m_key.m_y == m_y2); return bDest;
--- a/src/pathfinder/yapf/yapf_common.hpp +++ b/src/pathfinder/yapf/yapf_common.hpp @@ -26,7 +26,7 @@ TrackdirBits m_orgTrackdirs; ///< origin trackdir mask /** to access inherited path finder */ - FORCEINLINE Tpf& Yapf() + inline Tpf& Yapf() { return *static_cast<Tpf*>(this); } @@ -70,7 +70,7 @@ bool m_treat_first_red_two_way_signal_as_eol; ///< in some cases (leaving station) we need to handle first two-way signal differently /** to access inherited path finder */ - FORCEINLINE Tpf& Yapf() + inline Tpf& Yapf() { return *static_cast<Tpf*>(this); } @@ -104,7 +104,7 @@ } /** return true if first two-way signal should be treated as dead end */ - FORCEINLINE bool TreatFirstRedTwoWaySignalAsEOL() + inline bool TreatFirstRedTwoWaySignalAsEOL() { return Yapf().PfGetSettings().rail_firstred_twoway_eol && m_treat_first_red_two_way_signal_as_eol; } @@ -140,7 +140,7 @@ public: /** Called by YAPF to detect if node ends in the desired destination */ - FORCEINLINE bool PfDetectDestination(Node& n) + inline bool PfDetectDestination(Node& n) { bool bDest = (n.m_key.m_tile == m_destTile) && ((m_destTrackdirs & TrackdirToTrackdirBits(n.GetTrackdir())) != TRACKDIR_BIT_NONE); return bDest;
--- a/src/pathfinder/yapf/yapf_costbase.hpp +++ b/src/pathfinder/yapf/yapf_costbase.hpp @@ -20,7 +20,7 @@ * @param td The track direction to check. * @return True if there's a slope, otherwise false. */ - FORCEINLINE static bool stSlopeCost(TileIndex tile, Trackdir td) + inline static bool stSlopeCost(TileIndex tile, Trackdir td) { if (IsDiagonalTrackdir(td)) { if (IsBridgeTile(tile)) {
--- a/src/pathfinder/yapf/yapf_costcache.hpp +++ b/src/pathfinder/yapf/yapf_costcache.hpp @@ -30,7 +30,7 @@ * Called by YAPF to attach cached or local segment cost data to the given node. * @return true if globally cached data were used or false if local data was used */ - FORCEINLINE bool PfNodeCacheFetch(Node& n) + inline bool PfNodeCacheFetch(Node& n) { return false; } @@ -39,7 +39,7 @@ * Called by YAPF to flush the cached segment cost data back into cache storage. * Current cache implementation doesn't use that. */ - FORCEINLINE void PfNodeCacheFlush(Node& n) + inline void PfNodeCacheFlush(Node& n) { } }; @@ -65,7 +65,7 @@ LocalCache m_local_cache; /** to access inherited path finder */ - FORCEINLINE Tpf& Yapf() + inline Tpf& Yapf() { return *static_cast<Tpf*>(this); } @@ -75,7 +75,7 @@ * Called by YAPF to attach cached or local segment cost data to the given node. * @return true if globally cached data were used or false if local data was used */ - FORCEINLINE bool PfNodeCacheFetch(Node& n) + inline bool PfNodeCacheFetch(Node& n) { CacheKey key(n.GetKey()); Yapf().ConnectNodeToCachedData(n, *new (m_local_cache.Append()) CachedData(key)); @@ -86,7 +86,7 @@ * Called by YAPF to flush the cached segment cost data back into cache storage. * Current cache implementation doesn't use that. */ - FORCEINLINE void PfNodeCacheFlush(Node& n) + inline void PfNodeCacheFlush(Node& n) { } }; @@ -133,16 +133,16 @@ HashTable m_map; Heap m_heap; - FORCEINLINE CSegmentCostCacheT() {} + inline CSegmentCostCacheT() {} /** flush (clear) the cache */ - FORCEINLINE void Flush() + inline void Flush() { m_map.Clear(); m_heap.Clear(); } - FORCEINLINE Tsegment& Get(Key& key, bool *found) + inline Tsegment& Get(Key& key, bool *found) { Tsegment *item = m_map.Find(key); if (item == NULL) { @@ -177,15 +177,15 @@ protected: Cache& m_global_cache; - FORCEINLINE CYapfSegmentCostCacheGlobalT() : m_global_cache(stGetGlobalCache()) {}; + inline CYapfSegmentCostCacheGlobalT() : m_global_cache(stGetGlobalCache()) {}; /** to access inherited path finder */ - FORCEINLINE Tpf& Yapf() + inline Tpf& Yapf() { return *static_cast<Tpf*>(this); } - FORCEINLINE static Cache& stGetGlobalCache() + inline static Cache& stGetGlobalCache() { static int last_rail_change_counter = 0; static Date last_date = 0; @@ -211,7 +211,7 @@ * Called by YAPF to attach cached or local segment cost data to the given node. * @return true if globally cached data were used or false if local data was used */ - FORCEINLINE bool PfNodeCacheFetch(Node& n) + inline bool PfNodeCacheFetch(Node& n) { if (!Yapf().CanUseGlobalCache(n)) { return Tlocal::PfNodeCacheFetch(n); @@ -227,7 +227,7 @@ * Called by YAPF to flush the cached segment cost data back into cache storage. * Current cache implementation doesn't use that. */ - FORCEINLINE void PfNodeCacheFlush(Node& n) + inline void PfNodeCacheFlush(Node& n) { } };
--- a/src/pathfinder/yapf/yapf_costrail.hpp +++ b/src/pathfinder/yapf/yapf_costrail.hpp @@ -96,14 +96,14 @@ } public: - FORCEINLINE int SlopeCost(TileIndex tile, Trackdir td) + inline int SlopeCost(TileIndex tile, Trackdir td) { CPerfStart perf_cost(Yapf().m_perf_slope_cost); if (!stSlopeCost(tile, td)) return 0; return Yapf().PfGetSettings().rail_slope_penalty; } - FORCEINLINE int CurveCost(Trackdir td1, Trackdir td2) + inline int CurveCost(Trackdir td1, Trackdir td2) { assert(IsValidTrackdir(td1)); assert(IsValidTrackdir(td2)); @@ -119,7 +119,7 @@ return cost; } - FORCEINLINE int SwitchCost(TileIndex tile1, TileIndex tile2, DiagDirection exitdir) + inline int SwitchCost(TileIndex tile1, TileIndex tile2, DiagDirection exitdir) { if (IsPlainRailTile(tile1) && IsPlainRailTile(tile2)) { bool t1 = KillFirstBit(GetTrackBits(tile1) & DiagdirReachesTracks(ReverseDiagDir(exitdir))) != TRACK_BIT_NONE; @@ -130,7 +130,7 @@ } /** Return one tile cost (base cost + level crossing penalty). */ - FORCEINLINE int OneTileCost(TileIndex& tile, Trackdir trackdir) + inline int OneTileCost(TileIndex& tile, Trackdir trackdir) { int cost = 0; /* set base cost */ @@ -155,7 +155,7 @@ } /** Check for a reserved station platform. */ - FORCEINLINE bool IsAnyStationTileReserved(TileIndex tile, Trackdir trackdir, int skipped) + inline bool IsAnyStationTileReserved(TileIndex tile, Trackdir trackdir, int skipped) { TileIndexDiff diff = TileOffsByDiagDir(TrackdirToExitdir(ReverseTrackdir(trackdir))); for (; skipped >= 0; skipped--, tile += diff) { @@ -165,7 +165,7 @@ } /** The cost for reserved tiles, including skipped ones. */ - FORCEINLINE int ReservationCost(Node& n, TileIndex tile, Trackdir trackdir, int skipped) + inline int ReservationCost(Node& n, TileIndex tile, Trackdir trackdir, int skipped) { if (n.m_num_signals_passed >= m_sig_look_ahead_costs.Size() / 2) return 0; if (!IsPbsSignal(n.m_last_signal_type)) return 0; @@ -251,7 +251,7 @@ return cost; } - FORCEINLINE int PlatformLengthPenalty(int platform_length) + inline int PlatformLengthPenalty(int platform_length) { int cost = 0; const Train *v = Yapf().GetVehicle(); @@ -270,7 +270,7 @@ } public: - FORCEINLINE void SetMaxCost(int max_cost) + inline void SetMaxCost(int max_cost) { m_max_cost = max_cost; } @@ -280,7 +280,7 @@ * Calculates only the cost of given node, adds it to the parent node cost * and stores the result into Node::m_cost member */ - FORCEINLINE bool PfCalcCost(Node &n, const TrackFollower *tf) + inline bool PfCalcCost(Node &n, const TrackFollower *tf) { assert(!n.flags_u.flags_s.m_targed_seen); assert(tf->m_new_tile == n.m_key.m_tile); @@ -613,14 +613,14 @@ return true; } - FORCEINLINE bool CanUseGlobalCache(Node& n) const + inline bool CanUseGlobalCache(Node& n) const { return !m_disable_cache && (n.m_parent != NULL) && (n.m_parent->m_num_signals_passed >= m_sig_look_ahead_costs.Size()); } - FORCEINLINE void ConnectNodeToCachedData(Node& n, CachedData& ci) + inline void ConnectNodeToCachedData(Node& n, CachedData& ci) { n.m_segment = &ci; if (n.m_segment->m_cost < 0) {
--- a/src/pathfinder/yapf/yapf_destrail.hpp +++ b/src/pathfinder/yapf/yapf_destrail.hpp @@ -51,13 +51,13 @@ } /** Called by YAPF to detect if node ends in the desired destination */ - FORCEINLINE bool PfDetectDestination(Node& n) + inline bool PfDetectDestination(Node& n) { return PfDetectDestination(n.GetLastTile(), n.GetLastTrackdir()); } /** Called by YAPF to detect if node ends in the desired destination */ - FORCEINLINE bool PfDetectDestination(TileIndex tile, Trackdir td) + inline bool PfDetectDestination(TileIndex tile, Trackdir td) { bool bDest = IsRailDepotTile(tile); return bDest; @@ -67,7 +67,7 @@ * Called by YAPF to calculate cost estimate. Calculates distance to the destination * adds it to the actual cost from origin and stores the sum to the Node::m_estimate */ - FORCEINLINE bool PfCalcEstimate(Node& n) + inline bool PfCalcEstimate(Node& n) { n.m_estimate = n.m_cost; return true; @@ -91,13 +91,13 @@ } /** Called by YAPF to detect if node ends in the desired destination */ - FORCEINLINE bool PfDetectDestination(Node& n) + inline bool PfDetectDestination(Node& n) { return PfDetectDestination(n.GetLastTile(), n.GetLastTrackdir()); } /** Called by YAPF to detect if node ends in the desired destination */ - FORCEINLINE bool PfDetectDestination(TileIndex tile, Trackdir td) + inline bool PfDetectDestination(TileIndex tile, Trackdir td) { return IsSafeWaitingPosition(Yapf().GetVehicle(), tile, td, true, !TrackFollower::Allow90degTurns()) && IsWaitingPositionFree(Yapf().GetVehicle(), tile, td, !TrackFollower::Allow90degTurns()); @@ -107,7 +107,7 @@ * Called by YAPF to calculate cost estimate. Calculates distance to the destination * adds it to the actual cost from origin and stores the sum to the Node::m_estimate. */ - FORCEINLINE bool PfCalcEstimate(Node& n) + inline bool PfCalcEstimate(Node& n) { n.m_estimate = n.m_cost; return true; @@ -164,13 +164,13 @@ } /** Called by YAPF to detect if node ends in the desired destination */ - FORCEINLINE bool PfDetectDestination(Node& n) + inline bool PfDetectDestination(Node& n) { return PfDetectDestination(n.GetLastTile(), n.GetLastTrackdir()); } /** Called by YAPF to detect if node ends in the desired destination */ - FORCEINLINE bool PfDetectDestination(TileIndex tile, Trackdir td) + inline bool PfDetectDestination(TileIndex tile, Trackdir td) { bool bDest; if (m_dest_station_id != INVALID_STATION) { @@ -188,7 +188,7 @@ * Called by YAPF to calculate cost estimate. Calculates distance to the destination * adds it to the actual cost from origin and stores the sum to the Node::m_estimate */ - FORCEINLINE bool PfCalcEstimate(Node& n) + inline bool PfCalcEstimate(Node& n) { static const int dg_dir_to_x_offs[] = {-1, 0, 1, 0}; static const int dg_dir_to_y_offs[] = {0, 1, 0, -1};
--- a/src/pathfinder/yapf/yapf_node.hpp +++ b/src/pathfinder/yapf/yapf_node.hpp @@ -18,15 +18,15 @@ Trackdir m_td; DiagDirection m_exitdir; - FORCEINLINE void Set(TileIndex tile, Trackdir td) + inline void Set(TileIndex tile, Trackdir td) { m_tile = tile; m_td = td; m_exitdir = (m_td == INVALID_TRACKDIR) ? INVALID_DIAGDIR : TrackdirToExitdir(m_td); } - FORCEINLINE int CalcHash() const {return m_exitdir | (m_tile << 2);} - FORCEINLINE bool operator == (const CYapfNodeKeyExitDir& other) const {return (m_tile == other.m_tile) && (m_exitdir == other.m_exitdir);} + inline int CalcHash() const {return m_exitdir | (m_tile << 2);} + inline bool operator == (const CYapfNodeKeyExitDir& other) const {return (m_tile == other.m_tile) && (m_exitdir == other.m_exitdir);} void Dump(DumpTarget &dmp) const { @@ -38,8 +38,8 @@ struct CYapfNodeKeyTrackDir : public CYapfNodeKeyExitDir { - FORCEINLINE int CalcHash() const {return m_td | (m_tile << 4);} - FORCEINLINE bool operator == (const CYapfNodeKeyTrackDir& other) const {return (m_tile == other.m_tile) && (m_td == other.m_td);} + inline int CalcHash() const {return m_td | (m_tile << 4);} + inline bool operator == (const CYapfNodeKeyTrackDir& other) const {return (m_tile == other.m_tile) && (m_td == other.m_td);} }; /** Yapf Node base */ @@ -54,7 +54,7 @@ int m_cost; int m_estimate; - FORCEINLINE void Set(Node *parent, TileIndex tile, Trackdir td, bool is_choice) + inline void Set(Node *parent, TileIndex tile, Trackdir td, bool is_choice) { m_key.Set(tile, td); m_hash_next = NULL; @@ -63,14 +63,14 @@ m_estimate = 0; } - FORCEINLINE Node *GetHashNext() {return m_hash_next;} - FORCEINLINE void SetHashNext(Node *pNext) {m_hash_next = pNext;} - FORCEINLINE TileIndex GetTile() const {return m_key.m_tile;} - FORCEINLINE Trackdir GetTrackdir() const {return m_key.m_td;} - FORCEINLINE const Tkey_& GetKey() const {return m_key;} - FORCEINLINE int GetCost() const {return m_cost;} - FORCEINLINE int GetCostEstimate() const {return m_estimate;} - FORCEINLINE bool operator < (const Node& other) const {return m_estimate < other.m_estimate;} + inline Node *GetHashNext() {return m_hash_next;} + inline void SetHashNext(Node *pNext) {m_hash_next = pNext;} + inline TileIndex GetTile() const {return m_key.m_tile;} + inline Trackdir GetTrackdir() const {return m_key.m_td;} + inline const Tkey_& GetKey() const {return m_key;} + inline int GetCost() const {return m_cost;} + inline int GetCostEstimate() const {return m_estimate;} + inline bool operator < (const Node& other) const {return m_estimate < other.m_estimate;} void Dump(DumpTarget &dmp) const {
--- a/src/pathfinder/yapf/yapf_node_rail.hpp +++ b/src/pathfinder/yapf/yapf_node_rail.hpp @@ -17,39 +17,39 @@ { uint32 m_value; - FORCEINLINE CYapfRailSegmentKey(const CYapfRailSegmentKey& src) : m_value(src.m_value) {} + inline CYapfRailSegmentKey(const CYapfRailSegmentKey& src) : m_value(src.m_value) {} - FORCEINLINE CYapfRailSegmentKey(const CYapfNodeKeyTrackDir& node_key) + inline CYapfRailSegmentKey(const CYapfNodeKeyTrackDir& node_key) { Set(node_key); } - FORCEINLINE void Set(const CYapfRailSegmentKey& src) + inline void Set(const CYapfRailSegmentKey& src) { m_value = src.m_value; } - FORCEINLINE void Set(const CYapfNodeKeyTrackDir& node_key) + inline void Set(const CYapfNodeKeyTrackDir& node_key) { m_value = (((int)node_key.m_tile) << 4) | node_key.m_td; } - FORCEINLINE int32 CalcHash() const + inline int32 CalcHash() const { return m_value; } - FORCEINLINE TileIndex GetTile() const + inline TileIndex GetTile() const { return (TileIndex)(m_value >> 4); } - FORCEINLINE Trackdir GetTrackdir() const + inline Trackdir GetTrackdir() const { return (Trackdir)(m_value & 0x0F); } - FORCEINLINE bool operator == (const CYapfRailSegmentKey& other) const + inline bool operator == (const CYapfRailSegmentKey& other) const { return m_value == other.m_value; } @@ -144,7 +144,7 @@ EndSegmentReasonBits m_end_segment_reason; CYapfRailSegment *m_hash_next; - FORCEINLINE CYapfRailSegment(const CYapfRailSegmentKey& key) + inline CYapfRailSegment(const CYapfRailSegmentKey& key) : m_key(key) , m_last_tile(INVALID_TILE) , m_last_td(INVALID_TRACKDIR) @@ -155,22 +155,22 @@ , m_hash_next(NULL) {} - FORCEINLINE const Key& GetKey() const + inline const Key& GetKey() const { return m_key; } - FORCEINLINE TileIndex GetTile() const + inline TileIndex GetTile() const { return m_key.GetTile(); } - FORCEINLINE CYapfRailSegment *GetHashNext() + inline CYapfRailSegment *GetHashNext() { return m_hash_next; } - FORCEINLINE void SetHashNext(CYapfRailSegment *next) + inline void SetHashNext(CYapfRailSegment *next) { m_hash_next = next; } @@ -208,7 +208,7 @@ SignalType m_last_red_signal_type; SignalType m_last_signal_type; - FORCEINLINE void Set(CYapfRailNodeT *parent, TileIndex tile, Trackdir td, bool is_choice) + inline void Set(CYapfRailNodeT *parent, TileIndex tile, Trackdir td, bool is_choice) { base::Set(parent, tile, td, is_choice); m_segment = NULL; @@ -236,19 +236,19 @@ flags_u.flags_s.m_choice_seen |= is_choice; } - FORCEINLINE TileIndex GetLastTile() const + inline TileIndex GetLastTile() const { assert(m_segment != NULL); return m_segment->m_last_tile; } - FORCEINLINE Trackdir GetLastTrackdir() const + inline Trackdir GetLastTrackdir() const { assert(m_segment != NULL); return m_segment->m_last_td; } - FORCEINLINE void SetLastTileTrackdir(TileIndex tile, Trackdir td) + inline void SetLastTileTrackdir(TileIndex tile, Trackdir td) { assert(m_segment != NULL); m_segment->m_last_tile = tile;
--- a/src/pathfinder/yapf/yapf_rail.cpp +++ b/src/pathfinder/yapf/yapf_rail.cpp @@ -47,7 +47,7 @@ protected: /** to access inherited pathfinder */ - FORCEINLINE Tpf& Yapf() + inline Tpf& Yapf() { return *static_cast<Tpf*>(this); } @@ -197,7 +197,7 @@ protected: /** to access inherited path finder */ - FORCEINLINE Tpf& Yapf() + inline Tpf& Yapf() { return *static_cast<Tpf*>(this); } @@ -217,7 +217,7 @@ } /** return debug report character to identify the transportation type */ - FORCEINLINE char TransportTypeChar() const + inline char TransportTypeChar() const { return 't'; } @@ -252,7 +252,7 @@ return result1; } - FORCEINLINE bool FindNearestDepotTwoWay(const Train *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int max_penalty, int reverse_penalty, TileIndex *depot_tile, bool *reversed) + inline bool FindNearestDepotTwoWay(const Train *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int max_penalty, int reverse_penalty, TileIndex *depot_tile, bool *reversed) { /* set origin and destination nodes */ Yapf().SetOrigin(t1, td1, t2, td2, reverse_penalty, true); @@ -293,7 +293,7 @@ protected: /** to access inherited path finder */ - FORCEINLINE Tpf& Yapf() + inline Tpf& Yapf() { return *static_cast<Tpf*>(this); } @@ -313,7 +313,7 @@ } /** Return debug report character to identify the transportation type */ - FORCEINLINE char TransportTypeChar() const + inline char TransportTypeChar() const { return 't'; } @@ -376,7 +376,7 @@ protected: /** to access inherited path finder */ - FORCEINLINE Tpf& Yapf() + inline Tpf& Yapf() { return *static_cast<Tpf*>(this); } @@ -396,7 +396,7 @@ } /** return debug report character to identify the transportation type */ - FORCEINLINE char TransportTypeChar() const + inline char TransportTypeChar() const { return 't'; } @@ -422,7 +422,7 @@ return result1; } - FORCEINLINE Trackdir ChooseRailTrack(const Train *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found, bool reserve_track, PBSTileInfo *target) + inline Trackdir ChooseRailTrack(const Train *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found, bool reserve_track, PBSTileInfo *target) { if (target != NULL) target->tile = INVALID_TILE; @@ -480,7 +480,7 @@ return result1; } - FORCEINLINE bool CheckReverseTrain(const Train *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int reverse_penalty) + inline bool CheckReverseTrain(const Train *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int reverse_penalty) { /* create pathfinder instance * set origin and destination nodes */
--- a/src/pathfinder/yapf/yapf_road.cpp +++ b/src/pathfinder/yapf/yapf_road.cpp @@ -51,7 +51,7 @@ } /** return one tile cost */ - FORCEINLINE int OneTileCost(TileIndex tile, Trackdir trackdir) + inline int OneTileCost(TileIndex tile, Trackdir trackdir) { int cost = 0; /* set base cost */ @@ -100,7 +100,7 @@ * Calculates only the cost of given node, adds it to the parent node cost * and stores the result into Node::m_cost member */ - FORCEINLINE bool PfCalcCost(Node& n, const TrackFollower *tf) + inline bool PfCalcCost(Node& n, const TrackFollower *tf) { int segment_cost = 0; uint tiles = 0; @@ -181,13 +181,13 @@ } /** Called by YAPF to detect if node ends in the desired destination */ - FORCEINLINE bool PfDetectDestination(Node& n) + inline bool PfDetectDestination(Node& n) { bool bDest = IsRoadDepotTile(n.m_segment_last_tile); return bDest; } - FORCEINLINE bool PfDetectDestinationTile(TileIndex tile, Trackdir trackdir) + inline bool PfDetectDestinationTile(TileIndex tile, Trackdir trackdir) { return IsRoadDepotTile(tile); } @@ -196,7 +196,7 @@ * Called by YAPF to calculate cost estimate. Calculates distance to the destination * adds it to the actual cost from origin and stores the sum to the Node::m_estimate */ - FORCEINLINE bool PfCalcEstimate(Node& n) + inline bool PfCalcEstimate(Node& n) { n.m_estimate = n.m_cost; return true; @@ -245,12 +245,12 @@ public: /** Called by YAPF to detect if node ends in the desired destination */ - FORCEINLINE bool PfDetectDestination(Node& n) + inline bool PfDetectDestination(Node& n) { return PfDetectDestinationTile(n.m_segment_last_tile, n.m_segment_last_td); } - FORCEINLINE bool PfDetectDestinationTile(TileIndex tile, Trackdir trackdir) + inline bool PfDetectDestinationTile(TileIndex tile, Trackdir trackdir) { if (m_dest_station != INVALID_STATION) { return IsTileType(tile, MP_STATION) && @@ -305,7 +305,7 @@ protected: /** to access inherited path finder */ - FORCEINLINE Tpf& Yapf() + inline Tpf& Yapf() { return *static_cast<Tpf*>(this); } @@ -326,7 +326,7 @@ } /** return debug report character to identify the transportation type */ - FORCEINLINE char TransportTypeChar() const + inline char TransportTypeChar() const { return 'r'; } @@ -337,7 +337,7 @@ return pf.ChooseRoadTrack(v, tile, enterdir, path_found); } - FORCEINLINE Trackdir ChooseRoadTrack(const RoadVehicle *v, TileIndex tile, DiagDirection enterdir, bool &path_found) + inline Trackdir ChooseRoadTrack(const RoadVehicle *v, TileIndex tile, DiagDirection enterdir, bool &path_found) { /* Handle special case - when next tile is destination tile. * However, when going to a station the (initial) destination @@ -384,7 +384,7 @@ return pf.DistanceToTile(v, tile); } - FORCEINLINE uint DistanceToTile(const RoadVehicle *v, TileIndex dst_tile) + inline uint DistanceToTile(const RoadVehicle *v, TileIndex dst_tile) { /* handle special case - when current tile is the destination tile */ if (dst_tile == v->tile) { @@ -414,7 +414,7 @@ } /** Return true if the valid origin (tile/trackdir) was set from the current vehicle position. */ - FORCEINLINE bool SetOriginFromVehiclePos(const RoadVehicle *v) + inline bool SetOriginFromVehiclePos(const RoadVehicle *v) { /* set origin (tile, trackdir) */ TileIndex src_tile = v->tile; @@ -434,7 +434,7 @@ return pf.FindNearestDepot(v, tile, td, max_distance, depot_tile); } - FORCEINLINE bool FindNearestDepot(const RoadVehicle *v, TileIndex tile, Trackdir td, int max_distance, TileIndex *depot_tile) + inline bool FindNearestDepot(const RoadVehicle *v, TileIndex tile, Trackdir td, int max_distance, TileIndex *depot_tile) { /* set origin and destination nodes */ Yapf().SetOrigin(tile, TrackdirToTrackdirBits(td));
--- a/src/pathfinder/yapf/yapf_ship.cpp +++ b/src/pathfinder/yapf/yapf_ship.cpp @@ -27,7 +27,7 @@ protected: /** to access inherited path finder */ - FORCEINLINE Tpf& Yapf() + inline Tpf& Yapf() { return *static_cast<Tpf*>(this); } @@ -47,7 +47,7 @@ } /** return debug report character to identify the transportation type */ - FORCEINLINE char TransportTypeChar() const + inline char TransportTypeChar() const { return 'w'; } @@ -123,7 +123,7 @@ * Calculates only the cost of given node, adds it to the parent node cost * and stores the result into Node::m_cost member */ - FORCEINLINE bool PfCalcCost(Node& n, const TrackFollower *tf) + inline bool PfCalcCost(Node& n, const TrackFollower *tf) { /* base tile cost depending on distance */ int c = IsDiagonalTrackdir(n.GetTrackdir()) ? YAPF_TILE_LENGTH : YAPF_TILE_CORNER_LENGTH;
--- a/src/roadstop_base.h +++ b/src/roadstop_base.h @@ -46,7 +46,7 @@ * Get the length of this drive through stop. * @return the length in tile units. */ - FORCEINLINE int GetLength() const + inline int GetLength() const { return this->length; } @@ -55,7 +55,7 @@ * Get the amount of occupied space in this drive through stop. * @return the occupied space in tile units. */ - FORCEINLINE int GetOccupied() const + inline int GetOccupied() const { return this->occupied; } @@ -71,7 +71,7 @@ struct RoadStop *next; ///< Next stop of the given type at this station /** Initializes a RoadStop */ - FORCEINLINE RoadStop(TileIndex tile = INVALID_TILE) : + inline RoadStop(TileIndex tile = INVALID_TILE) : xy(tile), status((1 << RSSFB_BAY_COUNT) - 1) { } @@ -82,7 +82,7 @@ * Checks whether there is a free bay in this road stop * @return is at least one bay free? */ - FORCEINLINE bool HasFreeBay() const + inline bool HasFreeBay() const { return GB(this->status, 0, RSSFB_BAY_COUNT) != 0; } @@ -92,7 +92,7 @@ * @param nr bay to check * @return is given bay free? */ - FORCEINLINE bool IsFreeBay(uint nr) const + inline bool IsFreeBay(uint nr) const { assert(nr < RSSFB_BAY_COUNT); return HasBit(this->status, nr); @@ -102,7 +102,7 @@ * Checks whether the entrance of the road stop is occupied by a vehicle * @return is entrance busy? */ - FORCEINLINE bool IsEntranceBusy() const + inline bool IsEntranceBusy() const { return HasBit(this->status, RSSFB_ENTRY_BUSY); } @@ -111,7 +111,7 @@ * Makes an entrance occupied or free * @param busy if true, marks busy; free otherwise */ - FORCEINLINE void SetEntranceBusy(bool busy) + inline void SetEntranceBusy(bool busy) { SB(this->status, RSSFB_ENTRY_BUSY, 1, busy); } @@ -121,7 +121,7 @@ * @param direction the direciton to get the entry for * @return the entry */ - FORCEINLINE const Entry *GetEntry(DiagDirection dir) const + inline const Entry *GetEntry(DiagDirection dir) const { return HasBit((int)dir, 1) ? this->west : this->east; } @@ -131,7 +131,7 @@ * @param direction the direciton to get the entry for * @return the entry */ - FORCEINLINE Entry *GetEntry(DiagDirection dir) + inline Entry *GetEntry(DiagDirection dir) { return HasBit((int)dir, 1) ? this->west : this->east; } @@ -157,7 +157,7 @@ * @return the allocated bay number * @pre this->HasFreeBay() */ - FORCEINLINE uint AllocateBay() + inline uint AllocateBay() { assert(this->HasFreeBay()); @@ -173,7 +173,7 @@ * Allocates a bay in a drive-through road stop * @param nr the number of the bay to allocate */ - FORCEINLINE void AllocateDriveThroughBay(uint nr) + inline void AllocateDriveThroughBay(uint nr) { assert(nr < RSSFB_BAY_COUNT); ClrBit(this->status, nr); @@ -183,7 +183,7 @@ * Frees the given bay * @param nr the number of the bay to free */ - FORCEINLINE void FreeBay(uint nr) + inline void FreeBay(uint nr) { assert(nr < RSSFB_BAY_COUNT); SetBit(this->status, nr);
--- a/src/roadveh.h +++ b/src/roadveh.h @@ -132,7 +132,7 @@ * Allows to know the power value that this vehicle will use. * @return Power value from the engine in HP, or zero if the vehicle is not powered. */ - FORCEINLINE uint16 GetPower() const + inline uint16 GetPower() const { /* Power is not added for articulated parts */ if (!this->IsArticulatedPart()) { @@ -146,7 +146,7 @@ * Returns a value if this articulated part is powered. * @return Zero, because road vehicles don't have powered parts. */ - FORCEINLINE uint16 GetPoweredPartPower(const RoadVehicle *head) const + inline uint16 GetPoweredPartPower(const RoadVehicle *head) const { return 0; } @@ -155,7 +155,7 @@ * Allows to know the weight value that this vehicle will use. * @return Weight value from the engine in tonnes. */ - FORCEINLINE uint16 GetWeight() const + inline uint16 GetWeight() const { uint16 weight = (CargoSpec::Get(this->cargo_type)->weight * this->cargo.Count()) / 16; @@ -172,7 +172,7 @@ * Allows to know the tractive effort value that this vehicle will use. * @return Tractive effort value from the engine. */ - FORCEINLINE byte GetTractiveEffort() const + inline byte GetTractiveEffort() const { /* The tractive effort coefficient is in units of 1/256. */ return GetVehicleProperty(this, PROP_ROADVEH_TRACTIVE_EFFORT, RoadVehInfo(this->engine_type)->tractive_effort); @@ -182,7 +182,7 @@ * Gets the area used for calculating air drag. * @return Area of the engine in m^2. */ - FORCEINLINE byte GetAirDragArea() const + inline byte GetAirDragArea() const { return 6; } @@ -191,7 +191,7 @@ * Gets the air drag coefficient of this vehicle. * @return Air drag value from the engine. */ - FORCEINLINE byte GetAirDrag() const + inline byte GetAirDrag() const { return RoadVehInfo(this->engine_type)->air_drag; } @@ -200,7 +200,7 @@ * Checks the current acceleration status of this vehicle. * @return Acceleration status. */ - FORCEINLINE AccelStatus GetAccelerationStatus() const + inline AccelStatus GetAccelerationStatus() const { return (this->vehstatus & VS_STOPPED) ? AS_BRAKE : AS_ACCEL; } @@ -209,7 +209,7 @@ * Calculates the current speed of this vehicle. * @return Current speed in km/h-ish. */ - FORCEINLINE uint16 GetCurrentSpeed() const + inline uint16 GetCurrentSpeed() const { return this->cur_speed / 2; } @@ -218,7 +218,7 @@ * Returns the rolling friction coefficient of this vehicle. * @return Rolling friction coefficient in [1e-4]. */ - FORCEINLINE uint32 GetRollingFriction() const + inline uint32 GetRollingFriction() const { /* Trams have a slightly greater friction coefficient than trains. * The rest of road vehicles have bigger values. */ @@ -232,7 +232,7 @@ * Allows to know the acceleration type of a vehicle. * @return Zero, road vehicles always use a normal acceleration method. */ - FORCEINLINE int GetAccelerationType() const + inline int GetAccelerationType() const { return 0; } @@ -241,7 +241,7 @@ * Returns the slope steepness used by this vehicle. * @return Slope steepness used by the vehicle. */ - FORCEINLINE uint32 GetSlopeSteepness() const + inline uint32 GetSlopeSteepness() const { return _settings_game.vehicle.roadveh_slope_steepness; } @@ -250,7 +250,7 @@ * Gets the maximum speed allowed by the track for this vehicle. * @return Since roads don't limit road vehicle speed, it returns always zero. */ - FORCEINLINE uint16 GetMaxTrackSpeed() const + inline uint16 GetMaxTrackSpeed() const { return 0; } @@ -259,7 +259,7 @@ * Checks if the vehicle is at a tile that can be sloped. * @return True if the tile can be sloped. */ - FORCEINLINE bool TileMayHaveSlopedTrack() const + inline bool TileMayHaveSlopedTrack() const { TrackStatus ts = GetTileTrackStatus(this->tile, TRANSPORT_ROAD, this->compatible_roadtypes); TrackBits trackbits = TrackStatusToTrackBits(ts); @@ -274,7 +274,7 @@ * even if it is not reversing. * @return are we (possibly) reversing? */ - FORCEINLINE bool HasToUseGetSlopePixelZ() + inline bool HasToUseGetSlopePixelZ() { const RoadVehicle *rv = this->First();
--- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -416,7 +416,7 @@ * Calculates the maximum speed of the vehicle under its current conditions. * @return Maximum speed of the vehicle. */ -FORCEINLINE int RoadVehicle::GetCurrentMaxSpeed() const +inline int RoadVehicle::GetCurrentMaxSpeed() const { if (_settings_game.vehicle.roadveh_acceleration_model == AM_ORIGINAL) return this->vcache.cached_max_speed;
--- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -278,7 +278,7 @@ { } - FORCEINLINE byte ReadByte() + inline byte ReadByte() { if (this->bufp == this->bufe) { size_t len = this->reader->Read(this->buf, lengthof(this->buf)); @@ -318,7 +318,7 @@ * Write a single byte into the dumper. * @param b The byte to write. */ - FORCEINLINE void WriteByte(byte b) + inline void WriteByte(byte b) { /* Are we at the end of this chunk? */ if (this->buf == this->bufe) {
--- a/src/script/api/script_companymode.hpp +++ b/src/script/api/script_companymode.hpp @@ -19,10 +19,10 @@ * If you create an instance of this class, the company will be switched. * The original company is stored and recovered from when ever the * instance is destroyed. - * All actions performed within the scope of this mode, will be executed - * on behalf of the company you switched to. This includes any costs - * attached to the action performed. If the company does not have the - * funds the action will be aborted. In other words, this is like the + * All actions performed within the scope of this mode, will be executed + * on behalf of the company you switched to. This includes any costs + * attached to the action performed. If the company does not have the + * funds the action will be aborted. In other words, this is like the * real player is executing the commands. * If the company is not valid during an action, the error * ERR_PRECONDITION_INVALID_COMPANY will be returned. You can switch to
--- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -598,7 +598,7 @@ static const uint8 FORCE_REFRESH_PERIOD = 0x1F; ///< map is redrawn after that many ticks uint8 refresh; ///< refresh counter, zeroed every FORCE_REFRESH_PERIOD ticks - FORCEINLINE Point SmallmapRemapCoords(int x, int y) const + inline Point SmallmapRemapCoords(int x, int y) const { Point pt; pt.x = (y - x) * 2; @@ -612,7 +612,7 @@ * @param tile_y Y coordinate of the tile. * @return Position to draw on. */ - FORCEINLINE Point RemapTile(int tile_x, int tile_y) const + inline Point RemapTile(int tile_x, int tile_y) const { int x_offset = tile_x - this->scroll_x / (int)TILE_SIZE; int y_offset = tile_y - this->scroll_y / (int)TILE_SIZE; @@ -636,7 +636,7 @@ * @return Tile being displayed at the given position relative to #scroll_x and #scroll_y. * @note The #subscroll offset is already accounted for. */ - FORCEINLINE Point PixelToTile(int px, int py, int *sub, bool add_sub = true) const + inline Point PixelToTile(int px, int py, int *sub, bool add_sub = true) const { if (add_sub) px += this->subscroll; // Total horizontal offset.
--- a/src/station_base.h +++ b/src/station_base.h @@ -89,7 +89,7 @@ } /** Check if this airport has at least one hangar. */ - FORCEINLINE bool HasHangar() const + inline bool HasHangar() const { return this->GetSpec()->nof_depots > 0; } @@ -102,7 +102,7 @@ * @param tidc The tilediff to add to the airport tile. * @return The tile of this airport plus the rotated offset. */ - FORCEINLINE TileIndex GetRotatedTileFromOffset(TileIndexDiffC tidc) const + inline TileIndex GetRotatedTileFromOffset(TileIndexDiffC tidc) const { const AirportSpec *as = this->GetSpec(); switch (this->rotation) { @@ -124,7 +124,7 @@ * @pre hangar_num < GetNumHangars(). * @return A tile with the given hangar. */ - FORCEINLINE TileIndex GetHangarTile(uint hangar_num) const + inline TileIndex GetHangarTile(uint hangar_num) const { const AirportSpec *as = this->GetSpec(); for (uint i = 0; i < as->nof_depots; i++) { @@ -141,7 +141,7 @@ * @pre IsHangarTile(tile). * @return The exit direction of the hangar, taking airport rotation into account. */ - FORCEINLINE Direction GetHangarExitDirection(TileIndex tile) const + inline Direction GetHangarExitDirection(TileIndex tile) const { const AirportSpec *as = this->GetSpec(); const HangarTileTable *htt = GetHangarDataByTile(tile); @@ -154,14 +154,14 @@ * @pre IsHangarTile(tile). * @return The hangar number of the hangar at the given tile. */ - FORCEINLINE uint GetHangarNum(TileIndex tile) const + inline uint GetHangarNum(TileIndex tile) const { const HangarTileTable *htt = GetHangarDataByTile(tile); return htt->hangar_num; } /** Get the number of hangars on this airport. */ - FORCEINLINE uint GetNumHangars() const + inline uint GetNumHangars() const { uint num = 0; uint counted = 0; @@ -182,7 +182,7 @@ * @return The requested hangar information. * @pre The \a tile must be at a hangar tile at an airport. */ - FORCEINLINE const HangarTileTable *GetHangarDataByTile(TileIndex tile) const + inline const HangarTileTable *GetHangarDataByTile(TileIndex tile) const { const AirportSpec *as = this->GetSpec(); for (uint i = 0; i < as->nof_depots; i++) { @@ -245,12 +245,12 @@ uint GetCatchmentRadius() const; Rect GetCatchmentRect() const; - /* virtual */ FORCEINLINE bool TileBelongsToRailStation(TileIndex tile) const + /* virtual */ inline bool TileBelongsToRailStation(TileIndex tile) const { return IsRailStationTile(tile) && GetStationIndex(tile) == this->index; } - FORCEINLINE bool TileBelongsToAirport(TileIndex tile) const + inline bool TileBelongsToAirport(TileIndex tile) const { return IsAirportTile(tile) && GetStationIndex(tile) == this->index; } @@ -277,7 +277,7 @@ if (!st->TileBelongsToAirport(this->tile)) ++(*this); } - FORCEINLINE TileIterator& operator ++() + inline TileIterator& operator ++() { (*this).OrthogonalTileIterator::operator++(); while (this->tile != INVALID_TILE && !st->TileBelongsToAirport(this->tile)) {
--- a/src/stdafx.h +++ b/src/stdafx.h @@ -121,7 +121,6 @@ /* Stuff for GCC */ #if defined(__GNUC__) #define NORETURN __attribute__ ((noreturn)) - #define FORCEINLINE inline #define CDECL #define __int64 long long #define GCC_PACK __attribute__((packed)) @@ -137,7 +136,6 @@ #if defined(__WATCOMC__) #define NORETURN - #define FORCEINLINE inline #define CDECL #define GCC_PACK #define WARN_FORMAT(string, args) @@ -185,8 +183,7 @@ #include <malloc.h> // alloca() #define NORETURN __declspec(noreturn) - #define FORCEINLINE __forceinline - #define inline _inline + #define inline __forceinline #if !defined(WINCE) #define CDECL _cdecl @@ -448,7 +445,7 @@ * Version of the standard free that accepts const pointers. * @param ptr The data to free. */ -static FORCEINLINE void free(const void *ptr) +static inline void free(const void *ptr) { free(const_cast<void *>(ptr)); }
--- a/src/subsidy_base.h +++ b/src/subsidy_base.h @@ -33,18 +33,18 @@ /** * We need an (empty) constructor so struct isn't zeroed (as C++ standard states) */ - FORCEINLINE Subsidy() { } + inline Subsidy() { } /** * (Empty) destructor has to be defined else operator delete might be called with NULL parameter */ - FORCEINLINE ~Subsidy() { } + inline ~Subsidy() { } /** * Tests whether this subsidy has been awarded to someone * @return is this subsidy awarded? */ - FORCEINLINE bool IsAwarded() const + inline bool IsAwarded() const { return this->awarded != INVALID_COMPANY; }
--- a/src/tilearea_type.h +++ b/src/tilearea_type.h @@ -85,7 +85,7 @@ * Get the tile we are currently at. * @return The tile we are at, or INVALID_TILE when we're done. */ - FORCEINLINE operator TileIndex () const + inline operator TileIndex () const { return this->tile; } @@ -120,7 +120,7 @@ /** * Move ourselves to the next tile in the rectange on the map. */ - FORCEINLINE TileIterator& operator ++() + inline TileIterator& operator ++() { assert(this->tile != INVALID_TILE);
--- a/src/tilematrix_type.hpp +++ b/src/tilematrix_type.hpp @@ -137,7 +137,7 @@ } /** Array access operator, see #Get. */ - FORCEINLINE T &operator[](TileIndex tile) + inline T &operator[](TileIndex tile) { return *this->Get(tile); }
--- a/src/town.h +++ b/src/town.h @@ -133,7 +133,7 @@ void UpdateVirtCoord(); - static FORCEINLINE Town *GetByTile(TileIndex tile) + static inline Town *GetByTile(TileIndex tile) { return Town::Get(GetTownIndex(tile)); }
--- a/src/train.h +++ b/src/train.h @@ -128,7 +128,7 @@ * Get the next real (non-articulated part and non rear part of dualheaded engine) vehicle in the consist. * @return Next vehicle in the consist. */ - FORCEINLINE Train *GetNextUnit() const + inline Train *GetNextUnit() const { Train *v = this->GetNextVehicle(); if (v != NULL && v->IsRearDualheaded()) v = v->GetNextVehicle(); @@ -140,7 +140,7 @@ * Get the previous real (non-articulated part and non rear part of dualheaded engine) vehicle in the consist. * @return Previous vehicle in the consist. */ - FORCEINLINE Train *GetPrevUnit() + inline Train *GetPrevUnit() { Train *v = this->GetPrevVehicle(); if (v != NULL && v->IsRearDualheaded()) v = v->GetPrevVehicle(); @@ -167,7 +167,7 @@ * Allows to know the power value that this vehicle will use. * @return Power value from the engine in HP, or zero if the vehicle is not powered. */ - FORCEINLINE uint16 GetPower() const + inline uint16 GetPower() const { /* Power is not added for articulated parts */ if (!this->IsArticulatedPart() && HasPowerOnRail(this->railtype, GetRailType(this->tile))) { @@ -184,7 +184,7 @@ * Returns a value if this articulated part is powered. * @return Power value from the articulated part in HP, or zero if it is not powered. */ - FORCEINLINE uint16 GetPoweredPartPower(const Train *head) const + inline uint16 GetPoweredPartPower(const Train *head) const { /* For powered wagons the engine defines the type of engine (i.e. railtype) */ if (HasBit(this->flags, VRF_POWEREDWAGON) && HasPowerOnRail(head->railtype, GetRailType(this->tile))) { @@ -198,7 +198,7 @@ * Allows to know the weight value that this vehicle will use. * @return Weight value from the engine in tonnes. */ - FORCEINLINE uint16 GetWeight() const + inline uint16 GetWeight() const { uint16 weight = (CargoSpec::Get(this->cargo_type)->weight * this->cargo.Count() * FreightWagonMult(this->cargo_type)) / 16; @@ -219,7 +219,7 @@ * Allows to know the tractive effort value that this vehicle will use. * @return Tractive effort value from the engine. */ - FORCEINLINE byte GetTractiveEffort() const + inline byte GetTractiveEffort() const { return GetVehicleProperty(this, PROP_TRAIN_TRACTIVE_EFFORT, RailVehInfo(this->engine_type)->tractive_effort); } @@ -228,7 +228,7 @@ * Gets the area used for calculating air drag. * @return Area of the engine in m^2. */ - FORCEINLINE byte GetAirDragArea() const + inline byte GetAirDragArea() const { /* Air drag is higher in tunnels due to the limited cross-section. */ return (this->track == TRACK_BIT_WORMHOLE && this->vehstatus & VS_HIDDEN) ? 28 : 14; @@ -238,7 +238,7 @@ * Gets the air drag coefficient of this vehicle. * @return Air drag value from the engine. */ - FORCEINLINE byte GetAirDrag() const + inline byte GetAirDrag() const { return RailVehInfo(this->engine_type)->air_drag; } @@ -247,7 +247,7 @@ * Checks the current acceleration status of this vehicle. * @return Acceleration status. */ - FORCEINLINE AccelStatus GetAccelerationStatus() const + inline AccelStatus GetAccelerationStatus() const { return (this->vehstatus & VS_STOPPED) || HasBit(this->flags, VRF_REVERSING) || HasBit(this->flags, VRF_TRAIN_STUCK) ? AS_BRAKE : AS_ACCEL; } @@ -256,7 +256,7 @@ * Calculates the current speed of this vehicle. * @return Current speed in km/h-ish. */ - FORCEINLINE uint16 GetCurrentSpeed() const + inline uint16 GetCurrentSpeed() const { return this->cur_speed; } @@ -265,7 +265,7 @@ * Returns the rolling friction coefficient of this vehicle. * @return Rolling friction coefficient in [1e-4]. */ - FORCEINLINE uint32 GetRollingFriction() const + inline uint32 GetRollingFriction() const { /* Rolling friction for steel on steel is between 0.1% and 0.2%. * The friction coefficient increases with speed in a way that @@ -277,7 +277,7 @@ * Allows to know the acceleration type of a vehicle. * @return Acceleration type of the vehicle. */ - FORCEINLINE int GetAccelerationType() const + inline int GetAccelerationType() const { return GetRailTypeInfo(this->railtype)->acceleration_type; } @@ -286,7 +286,7 @@ * Returns the slope steepness used by this vehicle. * @return Slope steepness used by the vehicle. */ - FORCEINLINE uint32 GetSlopeSteepness() const + inline uint32 GetSlopeSteepness() const { return _settings_game.vehicle.train_slope_steepness; } @@ -295,7 +295,7 @@ * Gets the maximum speed allowed by the track for this vehicle. * @return Maximum speed allowed. */ - FORCEINLINE uint16 GetMaxTrackSpeed() const + inline uint16 GetMaxTrackSpeed() const { return GetRailTypeInfo(GetRailType(this->tile))->max_speed; } @@ -304,7 +304,7 @@ * Checks if the vehicle is at a tile that can be sloped. * @return True if the tile can be sloped. */ - FORCEINLINE bool TileMayHaveSlopedTrack() const + inline bool TileMayHaveSlopedTrack() const { /* Any track that isn't TRACK_BIT_X or TRACK_BIT_Y cannot be sloped. */ return this->track == TRACK_BIT_X || this->track == TRACK_BIT_Y; @@ -315,7 +315,7 @@ * have always the same direction as the track under them. * @return false */ - FORCEINLINE bool HasToUseGetSlopePixelZ() + inline bool HasToUseGetSlopePixelZ() { return false; }
--- a/src/train_gui.cpp +++ b/src/train_gui.cpp @@ -166,7 +166,7 @@ StationID source; ///< One of the source stations /** Used by CargoSummary::Find() and similiar functions */ - FORCEINLINE bool operator != (const CargoSummaryItem &other) const + inline bool operator != (const CargoSummaryItem &other) const { return this->cargo != other.cargo || this->subtype != other.subtype; }
--- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -295,7 +295,7 @@ * @param speed Direction-independent unscaled speed. * @return speed scaled by movement direction. 256 units are required for each movement step. */ - FORCEINLINE uint GetOldAdvanceSpeed(uint speed) + inline uint GetOldAdvanceSpeed(uint speed) { return (this->direction & 1) ? speed : speed * 3 / 4; } @@ -312,7 +312,7 @@ * @param speed Direction-independent unscaled speed. * @return speed, scaled to match #GetAdvanceDistance(). */ - static FORCEINLINE uint GetAdvanceSpeed(uint speed) + static inline uint GetAdvanceSpeed(uint speed) { return speed * 3 / 4; } @@ -324,7 +324,7 @@ * * @return distance to drive for a movement step on the map. */ - FORCEINLINE uint GetAdvanceDistance() + inline uint GetAdvanceDistance() { return (this->direction & 1) ? 192 : 256; } @@ -361,7 +361,7 @@ * Invalidates cached NewGRF variables * @see InvalidateNewGRFCacheOfChain */ - FORCEINLINE void InvalidateNewGRFCache() + inline void InvalidateNewGRFCache() { this->grf_cache.cache_valid = 0; } @@ -370,7 +370,7 @@ * Invalidates cached NewGRF variables of all vehicles in the chain (after the current vehicle) * @see InvalidateNewGRFCache */ - FORCEINLINE void InvalidateNewGRFCacheOfChain() + inline void InvalidateNewGRFCacheOfChain() { for (Vehicle *u = this; u != NULL; u = u->Next()) { u->InvalidateNewGRFCache(); @@ -381,7 +381,7 @@ * Check if the vehicle is a ground vehicle. * @return True iff the vehicle is a train or a road vehicle. */ - FORCEINLINE bool IsGroundVehicle() const + inline bool IsGroundVehicle() const { return this->type == VEH_TRAIN || this->type == VEH_ROAD; } @@ -739,7 +739,7 @@ * Check if the vehicle is a front engine. * @return Returns true if the vehicle is a front engine. */ - FORCEINLINE bool IsFrontEngine() const + inline bool IsFrontEngine() const { return this->IsGroundVehicle() && HasBit(this->subtype, GVSF_FRONT); } @@ -748,7 +748,7 @@ * Check if the vehicle is an articulated part of an engine. * @return Returns true if the vehicle is an articulated part. */ - FORCEINLINE bool IsArticulatedPart() const + inline bool IsArticulatedPart() const { return this->IsGroundVehicle() && HasBit(this->subtype, GVSF_ARTICULATED_PART); } @@ -757,7 +757,7 @@ * Check if an engine has an articulated part. * @return True if the engine has an articulated part. */ - FORCEINLINE bool HasArticulatedPart() const + inline bool HasArticulatedPart() const { return this->Next() != NULL && this->Next()->IsArticulatedPart(); } @@ -767,7 +767,7 @@ * @return Next part of the articulated engine. * @pre The vehicle is an articulated engine. */ - FORCEINLINE Vehicle *GetNextArticulatedPart() const + inline Vehicle *GetNextArticulatedPart() const { assert(this->HasArticulatedPart()); return this->Next(); @@ -777,7 +777,7 @@ * Get the first part of an articulated engine. * @return First part of the engine. */ - FORCEINLINE Vehicle *GetFirstEnginePart() + inline Vehicle *GetFirstEnginePart() { Vehicle *v = this; while (v->IsArticulatedPart()) v = v->Previous(); @@ -788,7 +788,7 @@ * Get the first part of an articulated engine. * @return First part of the engine. */ - FORCEINLINE const Vehicle *GetFirstEnginePart() const + inline const Vehicle *GetFirstEnginePart() const { const Vehicle *v = this; while (v->IsArticulatedPart()) v = v->Previous(); @@ -799,7 +799,7 @@ * Get the last part of an articulated engine. * @return Last part of the engine. */ - FORCEINLINE Vehicle *GetLastEnginePart() + inline Vehicle *GetLastEnginePart() { Vehicle *v = this; while (v->HasArticulatedPart()) v = v->GetNextArticulatedPart(); @@ -810,7 +810,7 @@ * Get the next real (non-articulated part) vehicle in the consist. * @return Next vehicle in the consist. */ - FORCEINLINE Vehicle *GetNextVehicle() const + inline Vehicle *GetNextVehicle() const { const Vehicle *v = this; while (v->HasArticulatedPart()) v = v->GetNextArticulatedPart(); @@ -823,7 +823,7 @@ * Get the previous real (non-articulated part) vehicle in the consist. * @return Previous vehicle in the consist. */ - FORCEINLINE Vehicle *GetPrevVehicle() const + inline Vehicle *GetPrevVehicle() const { Vehicle *v = this->Previous(); while (v != NULL && v->IsArticulatedPart()) v = v->Previous(); @@ -858,88 +858,88 @@ /** * Set vehicle type correctly */ - FORCEINLINE SpecializedVehicle<T, Type>() : Vehicle(Type) { } + inline SpecializedVehicle<T, Type>() : Vehicle(Type) { } /** * Get the first vehicle in the chain * @return first vehicle in the chain */ - FORCEINLINE T *First() const { return (T *)this->Vehicle::First(); } + inline T *First() const { return (T *)this->Vehicle::First(); } /** * Get the last vehicle in the chain * @return last vehicle in the chain */ - FORCEINLINE T *Last() { return (T *)this->Vehicle::Last(); } + inline T *Last() { return (T *)this->Vehicle::Last(); } /** * Get the last vehicle in the chain * @return last vehicle in the chain */ - FORCEINLINE const T *Last() const { return (const T *)this->Vehicle::Last(); } + inline const T *Last() const { return (const T *)this->Vehicle::Last(); } /** * Get next vehicle in the chain * @return next vehicle in the chain */ - FORCEINLINE T *Next() const { return (T *)this->Vehicle::Next(); } + inline T *Next() const { return (T *)this->Vehicle::Next(); } /** * Get previous vehicle in the chain * @return previous vehicle in the chain */ - FORCEINLINE T *Previous() const { return (T *)this->Vehicle::Previous(); } + inline T *Previous() const { return (T *)this->Vehicle::Previous(); } /** * Get the next part of an articulated engine. * @return Next part of the articulated engine. * @pre The vehicle is an articulated engine. */ - FORCEINLINE T *GetNextArticulatedPart() { return (T *)this->Vehicle::GetNextArticulatedPart(); } + inline T *GetNextArticulatedPart() { return (T *)this->Vehicle::GetNextArticulatedPart(); } /** * Get the next part of an articulated engine. * @return Next part of the articulated engine. * @pre The vehicle is an articulated engine. */ - FORCEINLINE T *GetNextArticulatedPart() const { return (T *)this->Vehicle::GetNextArticulatedPart(); } + inline T *GetNextArticulatedPart() const { return (T *)this->Vehicle::GetNextArticulatedPart(); } /** * Get the first part of an articulated engine. * @return First part of the engine. */ - FORCEINLINE T *GetFirstEnginePart() { return (T *)this->Vehicle::GetFirstEnginePart(); } + inline T *GetFirstEnginePart() { return (T *)this->Vehicle::GetFirstEnginePart(); } /** * Get the first part of an articulated engine. * @return First part of the engine. */ - FORCEINLINE const T *GetFirstEnginePart() const { return (const T *)this->Vehicle::GetFirstEnginePart(); } + inline const T *GetFirstEnginePart() const { return (const T *)this->Vehicle::GetFirstEnginePart(); } /** * Get the last part of an articulated engine. * @return Last part of the engine. */ - FORCEINLINE T *GetLastEnginePart() { return (T *)this->Vehicle::GetLastEnginePart(); } + inline T *GetLastEnginePart() { return (T *)this->Vehicle::GetLastEnginePart(); } /** * Get the next real (non-articulated part) vehicle in the consist. * @return Next vehicle in the consist. */ - FORCEINLINE T *GetNextVehicle() const { return (T *)this->Vehicle::GetNextVehicle(); } + inline T *GetNextVehicle() const { return (T *)this->Vehicle::GetNextVehicle(); } /** * Get the previous real (non-articulated part) vehicle in the consist. * @return Previous vehicle in the consist. */ - FORCEINLINE T *GetPrevVehicle() const { return (T *)this->Vehicle::GetPrevVehicle(); } + inline T *GetPrevVehicle() const { return (T *)this->Vehicle::GetPrevVehicle(); } /** * Tests whether given index is a valid index for vehicle of this type * @param index tested index * @return is this index valid index of T? */ - static FORCEINLINE bool IsValidID(size_t index) + static inline bool IsValidID(size_t index) { return Vehicle::IsValidID(index) && Vehicle::Get(index)->type == Type; } @@ -948,7 +948,7 @@ * Gets vehicle with given index * @return pointer to vehicle with given index casted to T * */ - static FORCEINLINE T *Get(size_t index) + static inline T *Get(size_t index) { return (T *)Vehicle::Get(index); } @@ -957,7 +957,7 @@ * Returns vehicle if the index is a valid index for this vehicle type * @return pointer to vehicle with given index if it's a vehicle of this type */ - static FORCEINLINE T *GetIfValid(size_t index) + static inline T *GetIfValid(size_t index) { return IsValidID(index) ? Get(index) : NULL; } @@ -967,7 +967,7 @@ * @param v Vehicle pointer * @return pointer to SpecializedVehicle */ - static FORCEINLINE T *From(Vehicle *v) + static inline T *From(Vehicle *v) { assert(v->type == Type); return (T *)v; @@ -978,7 +978,7 @@ * @param v Vehicle pointer * @return pointer to SpecializedVehicle */ - static FORCEINLINE const T *From(const Vehicle *v) + static inline const T *From(const Vehicle *v) { assert(v->type == Type); return (const T *)v; @@ -989,7 +989,7 @@ * @param moved Was the vehicle moved? * @param turned Did the vehicle direction change? */ - FORCEINLINE void UpdateViewport(bool moved, bool turned) + inline void UpdateViewport(bool moved, bool turned) { extern void VehicleMove(Vehicle *v, bool update_viewport);
--- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -297,7 +297,7 @@ * @param other Compare to this #RefitOption. * @return True if both #RefitOption are different. */ - FORCEINLINE bool operator != (const RefitOption &other) const + inline bool operator != (const RefitOption &other) const { return other.cargo != this->cargo || other.value != this->value; } @@ -307,7 +307,7 @@ * @param other Compare to this #RefitOption. * @return True if both #RefitOption are equal. */ - FORCEINLINE bool operator == (const RefitOption &other) const + inline bool operator == (const RefitOption &other) const { return other.cargo == this->cargo && other.value == this->value; }
--- a/src/waypoint_base.h +++ b/src/waypoint_base.h @@ -27,7 +27,7 @@ void UpdateVirtCoord(); - /* virtual */ FORCEINLINE bool TileBelongsToRailStation(TileIndex tile) const + /* virtual */ inline bool TileBelongsToRailStation(TileIndex tile) const { return IsRailWaypointTile(tile) && GetStationIndex(tile) == this->index; } @@ -50,7 +50,7 @@ * Is this a single tile waypoint? * @return true if it is. */ - FORCEINLINE bool IsSingleTile() const + inline bool IsSingleTile() const { return (this->facilities & FACIL_TRAIN) != 0 && this->train_station.w == 1 && this->train_station.h == 1; } @@ -61,7 +61,7 @@ * @param wp The waypoint to compare to. * @return true iff their types are equal. */ - FORCEINLINE bool IsOfType(const Waypoint *wp) const + inline bool IsOfType(const Waypoint *wp) const { return this->string_id == wp->string_id; }
--- a/src/widget_type.h +++ b/src/widget_type.h @@ -143,7 +143,7 @@ * @param bottom Amount of additional space below the widget. * @param left Amount of additional space left of the widget. */ - FORCEINLINE void SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left) + inline void SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left) { this->padding_top = top; this->padding_right = right; @@ -151,8 +151,8 @@ this->padding_left = left; } - FORCEINLINE uint GetHorizontalStepSize(SizingType sizing) const; - FORCEINLINE uint GetVerticalStepSize(SizingType sizing) const; + inline uint GetHorizontalStepSize(SizingType sizing) const; + inline uint GetVerticalStepSize(SizingType sizing) const; virtual void Draw(const Window *w) = 0; virtual void SetDirty(const Window *w) const; @@ -183,14 +183,14 @@ uint8 padding_left; ///< Paddings added to the left of the widget. Managed by parent container widget. protected: - FORCEINLINE void StoreSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height); + inline void StoreSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height); }; /** * Get the horizontal sizing step. * @param sizing Type of resize being performed. */ -FORCEINLINE uint NWidgetBase::GetHorizontalStepSize(SizingType sizing) const +inline uint NWidgetBase::GetHorizontalStepSize(SizingType sizing) const { return (sizing == ST_RESIZE) ? this->resize_x : this->fill_x; } @@ -199,7 +199,7 @@ * Get the vertical sizing step. * @param sizing Type of resize being performed. */ -FORCEINLINE uint NWidgetBase::GetVerticalStepSize(SizingType sizing) const +inline uint NWidgetBase::GetVerticalStepSize(SizingType sizing) const { return (sizing == ST_RESIZE) ? this->resize_y : this->fill_y; } @@ -212,7 +212,7 @@ * @param given_width Width allocated to the widget. * @param given_height Height allocated to the widget. */ -FORCEINLINE void NWidgetBase::StoreSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height) +inline void NWidgetBase::StoreSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height) { this->pos_x = x; this->pos_y = y; @@ -607,7 +607,7 @@ * Gets the number of elements in the list * @return the number of elements */ - FORCEINLINE uint16 GetCount() const + inline uint16 GetCount() const { return this->count; } @@ -616,7 +616,7 @@ * Gets the number of visible elements of the scrollbar * @return the number of visible elements */ - FORCEINLINE uint16 GetCapacity() const + inline uint16 GetCapacity() const { return this->cap; } @@ -625,7 +625,7 @@ * Gets the position of the first visible element in the list * @return the position of the element */ - FORCEINLINE uint16 GetPosition() const + inline uint16 GetPosition() const { return this->pos; } @@ -635,7 +635,7 @@ * @param item to check * @return true iff the item is visible */ - FORCEINLINE bool IsVisible(uint16 item) const + inline bool IsVisible(uint16 item) const { return IsInsideBS(item, this->GetPosition(), this->GetCapacity()); } @@ -644,7 +644,7 @@ * Is the scrollbar vertical or not? * @return True iff the scrollbar is vertical. */ - FORCEINLINE bool IsVertical() const + inline bool IsVertical() const { return this->is_vertical; } @@ -789,7 +789,7 @@ * @param step Stepsize of the widget. * @return Biggest possible size of the widget, assuming that \a base may only be incremented by \a step size steps. */ -static FORCEINLINE uint ComputeMaxSize(uint base, uint max_space, uint step) +static inline uint ComputeMaxSize(uint base, uint max_space, uint step) { if (base >= max_space || step == 0) return base; if (step == 1) return max_space;
--- a/src/window_gui.h +++ b/src/window_gui.h @@ -263,7 +263,7 @@ * to destruct them all at the same time too, which is kinda hard. * @param size the amount of space not to allocate */ - FORCEINLINE void *operator new[](size_t size) + inline void *operator new[](size_t size) { NOT_REACHED(); } @@ -273,7 +273,7 @@ * Don't free the window directly; it corrupts the linked list when iterating * @param ptr the pointer not to free */ - FORCEINLINE void operator delete(void *ptr) + inline void operator delete(void *ptr) { }