Hi, I’m using this class for generating random numbers since our app has multiplayer support on all platforms and consistent pseudo random numbers are very important:

Based on Java’s LinearRandom pseudo random number implementation

```
class Random
{
public:
Random(void);
Random( long seed);
static void setSeed(long _seed);
static int next();
public:
static long seed;
static long multiplier;
static long addend;
static long mask;
};
long Random::multiplier = 0x5DEECE6C;
long Random::addend = 0xB;
long Random::mask = (1L << 48) - 1;
long Random::seed= 0x2342dda;
Random::Random(void)
{
setSeed(time(NULL));
}
Random::Random( long seed) {
setSeed(seed);
}
void Random::setSeed(long _seed) {
seed = (unsigned)(_seed & 0x7fffffffU);
}
int Random::next() {
seed = (seed * 1103515245U + 12345U) & 0x7fffffffU;
return (int)(seed);
}
```

usage:

```
#define RANDOM(X) Random::next()%(int)X
#define RANDOM_SEED(X) Random::setSeed(X)
RANDOM(100); // random number between 0 and 99
```

Hope this helps