Merge branch 'master' into jgrpp

# Conflicts:
#	src/3rdparty/squirrel/include/squirrel.h
#	src/blitter/32bpp_sse_func.hpp
#	src/bridge_map.h
#	src/clear_map.h
#	src/company_manager_face.h
#	src/console_func.h
#	src/core/bitmath_func.hpp
#	src/core/endian_func.hpp
#	src/core/random_func.hpp
#	src/depot_map.h
#	src/elrail_func.h
#	src/fontcache.h
#	src/industry_map.h
#	src/map_func.h
#	src/newgrf_spritegroup.h
#	src/object_map.h
#	src/rail.h
#	src/rail_map.h
#	src/road_func.h
#	src/road_map.h
#	src/saveload/saveload.h
#	src/saveload/saveload_error.hpp
#	src/settings_gui.cpp
#	src/sl/oldloader.h
#	src/sprite.h
#	src/spritecache.h
#	src/station_func.h
#	src/station_map.h
#	src/story_base.h
#	src/strings_func.h
#	src/tile_cmd.h
#	src/tile_map.h
#	src/tile_type.h
#	src/town.h
#	src/town_map.h
#	src/tree_map.h
#	src/tunnel_map.h
#	src/tunnelbridge_map.h
#	src/vehicle_func.h
#	src/viewport_func.h
#	src/void_map.h
#	src/water.h
#	src/water_map.h
#	src/widget_type.h
This commit is contained in:
Jonathan G Rennison
2024-01-07 15:00:16 +00:00
106 changed files with 1080 additions and 1080 deletions

View File

@@ -26,7 +26,7 @@ void NORETURN ReallocError(size_t size);
* @param element_size Size of the structure to allocate.
* @param num_elements Number of elements to allocate.
*/
static inline void CheckAllocationConstraints(size_t element_size, size_t num_elements)
inline void CheckAllocationConstraints(size_t element_size, size_t num_elements)
{
if (num_elements > SIZE_MAX / element_size) MallocError(SIZE_MAX);
}
@@ -38,7 +38,7 @@ static inline void CheckAllocationConstraints(size_t element_size, size_t num_el
* @param num_elements Number of elements to allocate.
*/
template <typename T>
static inline void CheckAllocationConstraints(size_t num_elements)
inline void CheckAllocationConstraints(size_t num_elements)
{
CheckAllocationConstraints(sizeof(T), num_elements);
}
@@ -54,7 +54,7 @@ static inline void CheckAllocationConstraints(size_t num_elements)
* @return nullptr when num_elements == 0, non-nullptr otherwise.
*/
template <typename T>
static inline T *MallocT(size_t num_elements)
inline T *MallocT(size_t num_elements)
{
/*
* MorphOS cannot handle 0 elements allocations, or rather that always
@@ -82,7 +82,7 @@ static inline T *MallocT(size_t num_elements)
* @return nullptr when num_elements == 0, non-nullptr otherwise.
*/
template <typename T>
static inline T *CallocT(size_t num_elements)
inline T *CallocT(size_t num_elements)
{
/*
* MorphOS cannot handle 0 elements allocations, or rather that always
@@ -108,7 +108,7 @@ static inline T *CallocT(size_t num_elements)
* @return nullptr when num_elements == 0, non-nullptr otherwise.
*/
template <typename T>
static inline T *ReallocT(T *t_ptr, size_t num_elements)
inline T *ReallocT(T *t_ptr, size_t num_elements)
{
/*
* MorphOS cannot handle 0 elements allocations, or rather that always

View File

@@ -57,7 +57,7 @@ debug_inline constexpr static uint GB(const T x, const uint8 s, const uint8 n)
* @return The new value of \a x
*/
template <typename T, typename U>
static inline T SB(T &x, const uint8 s, const uint8 n, const U d)
inline T SB(T &x, const uint8_t s, const uint8_t n, const U d)
{
x &= (T)(~((((T)1U << n) - 1) << s));
typename std::make_unsigned<T>::type td = d;
@@ -83,7 +83,7 @@ static inline T SB(T &x, const uint8 s, const uint8 n, const U d)
* @return The new value of \a x
*/
template <typename T, typename U>
static inline T AB(T &x, const uint8 s, const uint8 n, const U i)
inline T AB(T &x, const uint8_t s, const uint8_t n, const U i)
{
const T mask = ((((T)1U << n) - 1) << s);
x = (T)((x & ~mask) | ((x + (i << s)) & mask));
@@ -121,7 +121,7 @@ debug_inline static bool HasBit(const T x, const uint8 y)
* @return The new value of the old value with the bit set
*/
template <typename T>
static inline T SetBit(T &x, const uint8 y)
inline T SetBit(T &x, const uint8_t y)
{
return x = (T)(x | ((T)1U << y));
}
@@ -151,7 +151,7 @@ static inline T SetBit(T &x, const uint8 y)
* @return The new value of the old value with the bit cleared
*/
template <typename T>
static inline T ClrBit(T &x, const uint8 y)
inline T ClrBit(T &x, const uint8_t y)
{
return x = (T)(x & ~((T)1U << y));
}
@@ -181,7 +181,7 @@ static inline T ClrBit(T &x, const uint8 y)
* @return The new value of the old value with the bit toggled
*/
template <typename T>
static inline T ToggleBit(T &x, const uint8 y)
inline T ToggleBit(T &x, const uint8_t y)
{
return x = (T)(x ^ ((T)1U << y));
}
@@ -216,7 +216,7 @@ extern const uint8 _ffb_64[64];
* @return The position of the first bit set, or 0 when value is 0
*/
template <typename T>
static inline uint8 FindFirstBit(T value)
inline uint8 FindFirstBit(T value)
{
static_assert(sizeof(T) <= sizeof(unsigned long long));
#ifdef WITH_BITMATH_BUILTINS
@@ -247,7 +247,7 @@ static inline uint8 FindFirstBit(T value)
* @return The position of the last bit set, or 0 when value is 0
*/
template <typename T>
static inline uint8 FindLastBit(T value)
inline uint8 FindLastBit(T value)
{
static_assert(sizeof(T) <= sizeof(unsigned long long));
#ifdef WITH_BITMATH_BUILTINS
@@ -278,7 +278,7 @@ static inline uint8 FindLastBit(T value)
* @return The position of the first bit which is set
* @see FIND_FIRST_BIT
*/
static inline uint8 FindFirstBit2x64(const int value)
inline uint8_t FindFirstBit2x64(const int value)
{
#ifdef WITH_BITMATH_BUILTINS
return FindFirstBit(value & 0x3F3F);
@@ -303,7 +303,7 @@ static inline uint8 FindFirstBit2x64(const int value)
* @return The new value with the first bit cleared
*/
template <typename T>
static inline T KillFirstBit(T value)
inline T KillFirstBit(T value)
{
return value &= (T)(value - 1);
}
@@ -315,7 +315,7 @@ static inline T KillFirstBit(T value)
* @return the number of bits.
*/
template <typename T>
static inline uint CountBits(T value)
inline uint CountBits(T value)
{
static_assert(sizeof(T) <= sizeof(unsigned long long));
#ifdef WITH_BITMATH_BUILTINS
@@ -350,7 +350,7 @@ static inline uint CountBits(T value)
* @return true if the parity is odd.
*/
template <typename T>
static inline bool IsOddParity(T value)
inline bool IsOddParity(T value)
{
static_assert(sizeof(T) <= sizeof(unsigned long long));
#ifdef WITH_BITMATH_BUILTINS
@@ -374,7 +374,7 @@ static inline bool IsOddParity(T value)
* @return does \a value have exactly 1 bit set?
*/
template <typename T>
static inline bool HasExactlyOneBit(T value)
inline bool HasExactlyOneBit(T value)
{
return value != 0 && (value & (value - 1)) == 0;
}
@@ -386,7 +386,7 @@ static inline bool HasExactlyOneBit(T value)
* @return does \a value have at most 1 bit set?
*/
template <typename T>
static inline bool HasAtMostOneBit(T value)
inline bool HasAtMostOneBit(T value)
{
return (value & (value - 1)) == 0;
}
@@ -401,7 +401,7 @@ static inline bool HasAtMostOneBit(T value)
* @return A bit rotated number
*/
template <typename T>
static inline T ROL(const T x, const uint8 n)
inline T ROL(const T x, const uint8_t n)
{
if (n == 0) return x;
return (T)(x << n | x >> (sizeof(x) * 8 - n));
@@ -417,7 +417,7 @@ static inline T ROL(const T x, const uint8 n)
* @return A bit rotated number
*/
template <typename T>
static inline T ROR(const T x, const uint8 n)
inline T ROR(const T x, const uint8_t n)
{
if (n == 0) return x;
return (T)(x >> n | x << (sizeof(x) * 8 - n));

View File

@@ -46,12 +46,12 @@
#define TO_LE64(x) (x)
#endif /* TTD_ENDIAN == TTD_BIG_ENDIAN */
static inline uint16 ReadLE16Aligned(const void *x)
inline uint16_t ReadLE16Aligned(const void *x)
{
return FROM_LE16(*(const uint16*)x);
}
static inline uint16 ReadLE16Unaligned(const void *x)
inline uint16_t ReadLE16Unaligned(const void *x)
{
#if OTTD_ALIGNMENT == 1
return ((const byte*)x)[0] | ((const byte*)x)[1] << 8;

View File

@@ -20,7 +20,7 @@ Dimension adddim(const Dimension &d1, const Dimension &d2);
* @param r Rectangle to check.
* @return True if and only if the rectangle doesn't define space.
*/
static inline bool IsEmptyRect(const Rect &r)
inline bool IsEmptyRect(const Rect &r)
{
return (r.left | r.top | r.right | r.bottom) == 0;
}

View File

@@ -23,7 +23,7 @@
* @return The unsigned value
*/
template <typename T>
static inline T abs(const T a)
inline T abs(const T a)
{
return (a < (T)0) ? -a : a;
}
@@ -37,7 +37,7 @@ static inline T abs(const T a)
* @return The smallest multiple of n equal or greater than x
*/
template <typename T>
static inline T Align(const T x, uint n)
inline T Align(const T x, uint n)
{
assert((n & (n - 1)) == 0 && n != 0);
n--;
@@ -55,7 +55,7 @@ static inline T Align(const T x, uint n)
* @see Align()
*/
template <typename T>
static inline T *AlignPtr(T *x, uint n)
inline T *AlignPtr(T *x, uint n)
{
static_assert(sizeof(size_t) == sizeof(void *));
return reinterpret_cast<T *>(Align((size_t)x, n));
@@ -79,7 +79,7 @@ static inline T *AlignPtr(T *x, uint n)
* @see Clamp(int, int, int)
*/
template <typename T>
static inline T Clamp(const T a, const T min, const T max)
inline T Clamp(const T a, const T min, const T max)
{
assert(min <= max);
if (a <= min) return min;
@@ -102,7 +102,7 @@ static inline T Clamp(const T a, const T min, const T max)
* @returns A value between min and max which is closest to a.
*/
template <typename T>
static inline T SoftClamp(const T a, const T min, const T max)
inline T SoftClamp(const T a, const T min, const T max)
{
if (min > max) {
using U = std::make_unsigned_t<T>;
@@ -129,7 +129,7 @@ static inline T SoftClamp(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 inline int Clamp(const int a, const int min, const int max)
inline int Clamp(const int a, const int min, const int max)
{
return Clamp<int>(a, min, max);
}
@@ -150,7 +150,7 @@ static inline 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 inline uint ClampU(const uint a, const uint min, const uint max)
inline uint ClampU(const uint a, const uint min, const uint max)
{
return Clamp<uint>(a, min, max);
}
@@ -234,7 +234,7 @@ constexpr To ClampTo(From value)
* @return The absolute difference between the given scalars
*/
template <typename T>
static inline T Delta(const T a, const T b)
inline T Delta(const T a, const T b)
{
return (a < b) ? b - a : a - b;
}
@@ -252,7 +252,7 @@ static inline T Delta(const T a, const T b)
* @return True if the value is in the interval, false else.
*/
template <typename T>
static inline bool IsInsideBS(const T x, const size_t base, const size_t size)
inline bool IsInsideBS(const T x, const size_t base, const size_t size)
{
return (size_t)(x - base) < size;
}
@@ -283,7 +283,7 @@ static constexpr inline bool IsInsideMM(const T x, const size_t min, const size_
* @param b variable to swap with a
*/
template <typename T>
static inline void Swap(T &a, T &b)
inline void Swap(T &a, T &b)
{
T t = a;
a = b;
@@ -295,7 +295,7 @@ static inline void Swap(T &a, T &b)
* @param i value to convert, range 0..255
* @return value in range 0..100
*/
static inline uint ToPercent8(uint i)
inline uint ToPercent8(uint i)
{
assert(i < 256);
return i * 101 >> 8;
@@ -306,7 +306,7 @@ static inline uint ToPercent8(uint i)
* @param i value to convert, range 0..65535
* @return value in range 0..100
*/
static inline uint ToPercent16(uint i)
inline uint ToPercent16(uint i)
{
assert(i < 65536);
return i * 101 >> 16;
@@ -322,7 +322,7 @@ int DivideApprox(int a, int b);
* @param b Denominator
* @return Quotient, rounded up
*/
static inline uint CeilDiv(uint a, uint b)
inline uint CeilDiv(uint a, uint b)
{
return (a + b - 1) / b;
}
@@ -334,7 +334,7 @@ static inline uint CeilDiv(uint a, uint b)
* @return Quotient, rounded up
*/
template <typename T>
static inline T CeilDivT(T a, T b)
inline T CeilDivT(T a, T b)
{
return (a + b - 1) / b;
}
@@ -345,7 +345,7 @@ static inline T CeilDivT(T a, T b)
* @param b Denominator
* @return a rounded up to the nearest multiple of b.
*/
static inline uint Ceil(uint a, uint b)
inline uint Ceil(uint a, uint b)
{
return CeilDiv(a, b) * b;
}
@@ -357,7 +357,7 @@ static inline uint Ceil(uint a, uint b)
* @return a rounded up to the nearest multiple of b.
*/
template <typename T>
static inline T CeilT(T a, T b)
inline T CeilT(T a, T b)
{
return CeilDivT<T>(a, b) * b;
}
@@ -368,7 +368,7 @@ static inline T CeilT(T a, T b)
* @param b Denominator
* @return Quotient, rounded to nearest
*/
static inline int RoundDivSU(int a, uint b)
inline int RoundDivSU(int a, uint b)
{
if (a > 0) {
/* 0.5 is rounded to 1 */
@@ -385,7 +385,7 @@ static inline int RoundDivSU(int a, uint b)
* @param b Denominator
* @return Quotient, rounded away from zero
*/
static inline int DivAwayFromZero(int a, uint b)
inline int DivAwayFromZero(int a, uint b)
{
const int _b = static_cast<int>(b);
if (a > 0) {
@@ -403,7 +403,7 @@ static inline int DivAwayFromZero(int a, uint b)
* @return Quotient, rounded towards negative infinity
*/
template <typename T>
static inline T DivTowardsNegativeInf(T a, T b)
inline T DivTowardsNegativeInf(T a, T b)
{
return (a / b) - (a % b < 0 ? 1 : 0);
}
@@ -415,7 +415,7 @@ static inline T DivTowardsNegativeInf(T a, T b)
* @return Quotient, rounded towards positive infinity
*/
template <typename T>
static inline T DivTowardsPositiveInf(T a, T b)
inline T DivTowardsPositiveInf(T a, T b)
{
return (a / b) + (a % b > 0 ? 1 : 0);
}

View File

@@ -20,7 +20,7 @@
* @param num number of items to be copied. (!not number of bytes!)
*/
template <typename T>
static inline void MemCpyT(T *destination, const T *source, size_t num = 1)
inline void MemCpyT(T *destination, const T *source, size_t num = 1)
{
memcpy(destination, source, num * sizeof(T));
}
@@ -33,7 +33,7 @@ static inline 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 inline void MemMoveT(T *destination, const T *source, size_t num = 1)
inline void MemMoveT(T *destination, const T *source, size_t num = 1)
{
memmove(destination, source, num * sizeof(T));
}
@@ -46,7 +46,7 @@ static inline 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 inline void MemSetT(T *ptr, byte value, size_t num = 1)
inline void MemSetT(T *ptr, byte value, size_t num = 1)
{
memset(ptr, value, num * sizeof(T));
}
@@ -60,7 +60,7 @@ static inline 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 inline int MemCmpT(const T *ptr1, const T *ptr2, size_t num = 1)
inline int MemCmpT(const T *ptr1, const T *ptr2, size_t num = 1)
{
return memcmp(ptr1, ptr2, num * sizeof(T));
}

View File

@@ -41,7 +41,7 @@ struct SavedRandomSeeds {
* Saves the current seeds
* @param storage Storage for saving
*/
static inline void SaveRandomSeeds(SavedRandomSeeds *storage)
inline void SaveRandomSeeds(SavedRandomSeeds *storage)
{
storage->random = _random;
storage->interactive_random = _interactive_random;
@@ -51,7 +51,7 @@ static inline void SaveRandomSeeds(SavedRandomSeeds *storage)
* Restores previously saved seeds
* @param storage Storage where SaveRandomSeeds() stored the seeds
*/
static inline void RestoreRandomSeeds(const SavedRandomSeeds &storage)
inline void RestoreRandomSeeds(const SavedRandomSeeds &storage)
{
_random = storage.random;
_interactive_random = storage.interactive_random;
@@ -102,12 +102,12 @@ void SetRandomSeed(uint32 seed);
}
#endif
static inline uint32 InteractiveRandom()
inline uint32_t InteractiveRandom()
{
return _interactive_random.Next();
}
static inline uint32 InteractiveRandomRange(uint32 limit)
inline uint32_t InteractiveRandomRange(uint32_t limit)
{
return _interactive_random.Next(limit);
}
@@ -127,7 +127,7 @@ static inline uint32 InteractiveRandomRange(uint32 limit)
* @param r The given randomize-number
* @return True if the probability given by r is less or equal to (a/b)
*/
static inline bool Chance16I(const uint a, const uint b, const uint32 r)
inline bool Chance16I(const uint a, const uint b, const uint32_t r)
{
assert(b != 0);
return (((uint16)r * b + b / 2) >> 16) < a;
@@ -146,7 +146,7 @@ static inline 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 inline bool Chance16(const uint a, const uint b)
inline bool Chance16(const uint a, const uint b)
{
return Chance16I(a, b, Random());
}
@@ -170,7 +170,7 @@ static inline 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 inline bool Chance16R(const uint a, const uint b, uint32 &r)
inline bool Chance16R(const uint a, const uint b, uint32_t &r)
{
r = Random();
return Chance16I(a, b, r);