diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/alloc_func.hpp | 6 | ||||
-rw-r--r-- | src/core/alloc_type.hpp | 16 | ||||
-rw-r--r-- | src/core/bitmath_func.hpp | 30 | ||||
-rw-r--r-- | src/core/endian_func.hpp | 4 | ||||
-rw-r--r-- | src/core/enum_type.hpp | 38 | ||||
-rw-r--r-- | src/core/math_func.hpp | 42 | ||||
-rw-r--r-- | src/core/mem_func.hpp | 12 | ||||
-rw-r--r-- | src/core/overflowsafe_type.hpp | 122 | ||||
-rw-r--r-- | src/core/pool_type.hpp | 30 | ||||
-rw-r--r-- | src/core/random_func.hpp | 14 | ||||
-rw-r--r-- | src/core/smallmap_type.hpp | 20 | ||||
-rw-r--r-- | src/core/smallvec_type.hpp | 42 | ||||
-rw-r--r-- | src/core/sort_func.hpp | 2 |
13 files changed, 189 insertions, 189 deletions
diff --git a/src/core/alloc_func.hpp b/src/core/alloc_func.hpp index 4ba8c5f53..c7e17421f 100644 --- a/src/core/alloc_func.hpp +++ b/src/core/alloc_func.hpp @@ -56,7 +56,7 @@ static inline void CheckAllocationConstraints(size_t num_elements) * @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 @@ static FORCEINLINE T *MallocT(size_t num_elements) * @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 @@ static FORCEINLINE T *CallocT(size_t num_elements) * @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 diff --git a/src/core/alloc_type.hpp b/src/core/alloc_type.hpp index 9cac62758..6caaf916a 100644 --- a/src/core/alloc_type.hpp +++ b/src/core/alloc_type.hpp @@ -48,7 +48,7 @@ struct SmallStackSafeStackAlloc { * 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 @@ struct SmallStackSafeStackAlloc { * 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 @@ struct SmallStackSafeStackAlloc { * @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 @@ public: * 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 @@ public: * @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 */ diff --git a/src/core/bitmath_func.hpp b/src/core/bitmath_func.hpp index d10003007..533f7f279 100644 --- 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 @@ static FORCEINLINE uint GB(const T x, const uint8 s, const uint8 n) * @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 @@ static FORCEINLINE T SB(T &x, const uint8 s, const uint8 n, const U d) * @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 @@ static FORCEINLINE T AB(T &x, const uint8 s, const uint8 n, const U i) * @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 @@ static FORCEINLINE bool HasBit(const T x, const uint8 y) * @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 @@ static FORCEINLINE T SetBit(T &x, const uint8 y) * @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 @@ static FORCEINLINE T ClrBit(T &x, const uint8 y) * @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 @@ extern const uint8 _ffb_64[64]; * @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 @@ uint8 FindLastBit(uint64 x); * @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 @@ static inline uint CountBits(T value) * @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 @@ static FORCEINLINE bool HasExactlyOneBit(T value) * @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 @@ static FORCEINLINE bool HasAtMostOneBit(T value) * @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 @@ static FORCEINLINE T ROL(const T x, const uint8 n) * @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 @@ static FORCEINLINE T ROR(const T x, const uint8 n) * @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 @@ static FORCEINLINE T ROR(const T x, const uint8 n) * @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); } diff --git a/src/core/endian_func.hpp b/src/core/endian_func.hpp index 186cb2a3b..ab5b18150 100644 --- 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; diff --git a/src/core/enum_type.hpp b/src/core/enum_type.hpp index 21518d269..a6332296a 100644 --- 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 @@ struct TinyEnumT { 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 @@ struct TinyEnumT { } /** 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 @@ struct SimpleTinyEnumT { 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; diff --git a/src/core/math_func.hpp b/src/core/math_func.hpp index 42c41abad..b613d1e6a 100644 --- 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 @@ static FORCEINLINE T max(const T a, const T b) * @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 @@ static FORCEINLINE T min(const T a, const T b) * @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 @@ static FORCEINLINE int min(const int a, const int b) * @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 @@ static FORCEINLINE uint minu(const uint a, const uint b) * @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 @@ static FORCEINLINE T abs(const T a) * @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 @@ static FORCEINLINE T Align(const T x, uint n) * @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 @@ static FORCEINLINE T *AlignPtr(T *x, uint n) * @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 @@ static FORCEINLINE T Clamp(const T a, const T min, const T max) * @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 @@ static FORCEINLINE int Clamp(const int a, const int min, const int max) * @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 @@ static FORCEINLINE uint ClampU(const uint a, const uint min, const uint max) * @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 @@ static FORCEINLINE int32 ClampToI32(const int64 a) * @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 @@ static FORCEINLINE uint16 ClampToU16(const uint64 a) * @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 @@ static FORCEINLINE T Delta(const T a, const T b) * @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 @@ static FORCEINLINE bool IsInsideBS(const T x, const uint base, const uint size) * @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 @@ static FORCEINLINE bool IsInsideMM(const T x, const uint min, const uint max) * @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 @@ static FORCEINLINE void Swap(T &a, T &b) * @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 @@ static FORCEINLINE uint ToPercent8(uint i) * @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 @@ int GreatestCommonDivisor(int a, int b); * @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 @@ static FORCEINLINE uint CeilDiv(uint a, uint b) * @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 @@ static FORCEINLINE uint Ceil(uint a, uint b) * @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 */ diff --git a/src/core/mem_func.hpp b/src/core/mem_func.hpp index 42e7b42f4..687871164 100644 --- 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 @@ static FORCEINLINE void MemCpyT(T *destination, const T *source, size_t num = 1) * @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 @@ static FORCEINLINE void MemMoveT(T *destination, const T *source, size_t num = 1 * @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 @@ static FORCEINLINE void MemSetT(T *ptr, byte value, size_t num = 1) * @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 @@ static FORCEINLINE int MemCmpT(const T *ptr1, const T *ptr2, size_t num = 1) * @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 @@ static FORCEINLINE void MemReverseT(T *ptr1, T *ptr2) * @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); diff --git a/src/core/overflowsafe_type.hpp b/src/core/overflowsafe_type.hpp index e6a31395a..dda08d96c 100644 --- a/src/core/overflowsafe_type.hpp +++ b/src/core/overflowsafe_type.hpp @@ -33,9 +33,9 @@ public: 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 @@ public: * @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 @@ public: } /* 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; } - - 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 + (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; } + + 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 @@ public: * @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 @@ public: } /* 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); } - - FORCEINLINE operator int64 () const { return this->m_value; } + 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); } + + 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; diff --git a/src/core/pool_type.hpp b/src/core/pool_type.hpp index f9b1e8230..f4b155842 100644 --- a/src/core/pool_type.hpp +++ b/src/core/pool_type.hpp @@ -98,7 +98,7 @@ struct Pool : PoolBase { * @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 @@ struct Pool : PoolBase { * @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 @@ struct Pool : PoolBase { * @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 @@ struct Pool : PoolBase { * @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 @@ struct Pool : PoolBase { * @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 @@ struct Pool : PoolBase { * @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 @@ struct Pool : PoolBase { * @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 @@ struct Pool : PoolBase { * @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 @@ struct Pool : PoolBase { * 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 @@ struct Pool : PoolBase { * @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 @@ struct Pool : PoolBase { * @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 @@ struct Pool : PoolBase { * @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 @@ struct Pool : PoolBase { * 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 @@ struct Pool : PoolBase { * 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 @@ struct Pool : PoolBase { * @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: diff --git a/src/core/random_func.hpp b/src/core/random_func.hpp index 597efcdc7..8c3bed166 100644 --- a/src/core/random_func.hpp +++ b/src/core/random_func.hpp @@ -81,23 +81,23 @@ void SetRandomSeed(uint32 seed); #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 @@ static FORCEINLINE uint32 InteractiveRandomRange(uint32 max) * @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 @@ static FORCEINLINE bool Chance16I(const uint a, const uint b, const uint32 r) #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 @@ static FORCEINLINE bool Chance16(const uint a, const uint b) #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); diff --git a/src/core/smallmap_type.hpp b/src/core/smallmap_type.hpp index f72a8800d..57373c442 100644 --- a/src/core/smallmap_type.hpp +++ b/src/core/smallmap_type.hpp @@ -26,7 +26,7 @@ struct SmallPair { 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 @@ struct SmallMap : SmallVector<SmallPair<T, U>, S> { 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 @@ struct SmallMap : SmallVector<SmallPair<T, U>, S> { * @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 @@ struct SmallMap : SmallVector<SmallPair<T, U>, S> { * @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 @@ struct SmallMap : SmallVector<SmallPair<T, U>, S> { * @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 @@ struct SmallMap : SmallVector<SmallPair<T, U>, S> { * @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 @@ struct SmallMap : SmallVector<SmallPair<T, U>, S> { * @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 @@ struct SmallMap : SmallVector<SmallPair<T, U>, S> { return n->second; } - FORCEINLINE void SortByKey() + inline void SortByKey() { QSortT(this->Begin(), this->items, KeySorter); } diff --git a/src/core/smallvec_type.hpp b/src/core/smallvec_type.hpp index 40793788d..c230b4750 100644 --- a/src/core/smallvec_type.hpp +++ b/src/core/smallvec_type.hpp @@ -65,7 +65,7 @@ public: /** * 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 @@ public: /** * 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 @@ public: /** * 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 @@ public: * @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 @@ public: * @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 @@ public: * @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 @@ public: * @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 @@ public: * @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 @@ public: * @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 @@ public: * @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 @@ public: /** * Get the number of items in the list. */ - FORCEINLINE uint Length() const + inline uint Length() const { return this->items; } @@ -208,7 +208,7 @@ public: * * @return the pointer to the first item */ - FORCEINLINE const T *Begin() const + inline const T *Begin() const { return this->data; } @@ -218,7 +218,7 @@ public: * * @return the pointer to the first item */ - FORCEINLINE T *Begin() + inline T *Begin() { return this->data; } @@ -228,7 +228,7 @@ public: * * @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 @@ public: * * @return the pointer behind the last valid item */ - FORCEINLINE T *End() + inline T *End() { return &this->data[this->items]; } @@ -249,7 +249,7 @@ public: * @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 @@ public: * @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 @@ public: * @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 @@ public: * @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 @@ public: /** * 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 @@ public: /** * Remove all items from the list. */ - FORCEINLINE void Clear() + inline void Clear() { for (uint i = 0; i < this->items; i++) { delete this->data[i]; diff --git a/src/core/sort_func.hpp b/src/core/sort_func.hpp index 94aef195f..4181fd63a 100644 --- 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; |