mirror of https://github.com/OpenTTD/OpenTTD
(svn r13607) -Fix (r13606): some coding style issues got fixed but some got/stayed broken
parent
640e547886
commit
b4ef380c49
|
@ -76,7 +76,7 @@ static FORCEINLINE T *CallocT(size_t num_elements)
|
||||||
* @return NULL when num_elements == 0, non-NULL otherwise.
|
* @return NULL when num_elements == 0, non-NULL otherwise.
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
FORCEINLINE T *ReallocT(T *t_ptr, size_t num_elements)
|
static FORCEINLINE T *ReallocT(T *t_ptr, size_t num_elements)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* MorphOS cannot handle 0 elements allocations, or rather that always
|
* MorphOS cannot handle 0 elements allocations, or rather that always
|
||||||
|
|
|
@ -29,28 +29,39 @@ struct SmallStackSafeStackAlloc {
|
||||||
|
|
||||||
/** Allocating the memory */
|
/** Allocating the memory */
|
||||||
SmallStackSafeStackAlloc() : data(MallocT<T>(length)), len(length) {}
|
SmallStackSafeStackAlloc() : data(MallocT<T>(length)), len(length) {}
|
||||||
|
|
||||||
/** And freeing when it goes out of scope */
|
/** And freeing when it goes out of scope */
|
||||||
~SmallStackSafeStackAlloc() { free(data); }
|
~SmallStackSafeStackAlloc()
|
||||||
|
{
|
||||||
|
free(data);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a pointer to the data stored in this wrapper.
|
* Gets a pointer to the data stored in this wrapper.
|
||||||
* @return the pointer.
|
* @return the pointer.
|
||||||
*/
|
*/
|
||||||
FORCEINLINE operator T* () { return data; }
|
FORCEINLINE operator T* ()
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a pointer to the data stored in this wrapper.
|
* Gets a pointer to the data stored in this wrapper.
|
||||||
* @return the pointer.
|
* @return the pointer.
|
||||||
*/
|
*/
|
||||||
FORCEINLINE T* operator -> () { return data; }
|
FORCEINLINE T* operator -> ()
|
||||||
|
{
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a pointer to the last data element stored in this wrapper.
|
* Gets a pointer to the last data element stored in this wrapper.
|
||||||
* @note needed because endof does not work properly for pointers.
|
* @note needed because endof does not work properly for pointers.
|
||||||
* @return the 'endof' pointer.
|
* @return the 'endof' pointer.
|
||||||
*/
|
*/
|
||||||
FORCEINLINE T* EndOf() {
|
FORCEINLINE T* EndOf()
|
||||||
|
{
|
||||||
#if !defined(__NDS__)
|
#if !defined(__NDS__)
|
||||||
return endof(data);
|
return endof(data);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -192,7 +192,8 @@ static FORCEINLINE uint16 ClampToU16(const uint64 a)
|
||||||
* @return The absolute difference between the given scalars
|
* @return The absolute difference between the given scalars
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static FORCEINLINE T Delta(const T a, const T b) {
|
static FORCEINLINE T Delta(const T a, const T b)
|
||||||
|
{
|
||||||
return (a < b) ? b - a : a - b;
|
return (a < b) ? b - a : a - b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,12 +59,26 @@ void SetRandomSeed(uint32 seed);
|
||||||
#define RandomRange(max) DoRandomRange(max, __LINE__, __FILE__)
|
#define RandomRange(max) DoRandomRange(max, __LINE__, __FILE__)
|
||||||
uint DoRandomRange(uint max, int line, const char *file);
|
uint DoRandomRange(uint max, int line, const char *file);
|
||||||
#else
|
#else
|
||||||
static FORCEINLINE uint32 Random() { return _random.Next(); }
|
static FORCEINLINE uint32 Random()
|
||||||
static FORCEINLINE uint32 RandomRange(uint16 max) { return _random.Next(max); }
|
{
|
||||||
|
return _random.Next();
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCEINLINE uint32 RandomRange(uint16 max)
|
||||||
|
{
|
||||||
|
return _random.Next(max);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static FORCEINLINE uint32 InteractiveRandom() { return _interactive_random.Next(); }
|
static FORCEINLINE uint32 InteractiveRandom()
|
||||||
static FORCEINLINE uint32 InteractiveRandomRange(uint16 max) { return _interactive_random.Next(max); }
|
{
|
||||||
|
return _interactive_random.Next();
|
||||||
|
}
|
||||||
|
|
||||||
|
static FORCEINLINE uint32 InteractiveRandomRange(uint16 max)
|
||||||
|
{
|
||||||
|
return _interactive_random.Next(max);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a given randomize-number is below a given probability.
|
* Checks if a given randomize-number is below a given probability.
|
||||||
|
|
Loading…
Reference in New Issue