diff options
Diffstat (limited to 'src/utility.h')
-rw-r--r-- | src/utility.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/utility.h b/src/utility.h index a61de1c37..8839887f7 100644 --- a/src/utility.h +++ b/src/utility.h @@ -207,6 +207,10 @@ public: { return ptr == t; } + T & operator[](unsigned int i) + { + return ptr[i]; + } private: void drop() { @@ -572,6 +576,15 @@ inline bool isInArea(v2s16 p, s16 d) ); } +inline bool isInArea(v3s16 p, v3s16 d) +{ + return ( + p.X >= 0 && p.X < d.X && + p.Y >= 0 && p.Y < d.Y && + p.Z >= 0 && p.Z < d.Z + ); +} + inline s16 rangelim(s16 i, s16 min, s16 max) { if(i < min) @@ -1459,6 +1472,13 @@ int myrand(void); void mysrand(unsigned seed); #define MYRAND_MAX 32767 +inline int myrand_range(int min, int max) +{ + if(min >= max) + return max; + return (myrand()%(max-min+1))+min; +} + /* Some kind of a thing that stores attributes related to coordinate points |