Alter frandom's API such that it takes no parameters and returns a float ranging from 0.f to 1.f

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@6608 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2009-02-09 22:51:41 +00:00
parent f1ae7b9620
commit 516067dec0
2 changed files with 5 additions and 6 deletions

View File

@ -113,13 +113,11 @@ static inline WZ_DECL_CONST float hypotf(float x, float y)
/*! /*!
* Calculates a random floating point number in a certain range * Calculates a random floating point number in a certain range
* \param x Lower bound * \return Random number between 0.f and 1.f
* \param y Upper boundX
* \return Random number between x and y
*/ */
static inline float frandom(float x, float y) static inline float frandom(void)
{ {
return x + (y-x)*rand()/(float)RAND_MAX; return (float)rand() / (float)RAND_MAX;
} }

View File

@ -396,7 +396,8 @@ BOOL proj_SendProjectile(WEAPON *psWeap, BASE_OBJECT *psAttacker, int player, Ve
if (psTarget) if (psTarget)
{ {
unsigned int heightVariance = frandom(0, establishTargetHeight(psTarget)); const float maxHeight = establishTargetHeight(psTarget);
unsigned int heightVariance = frandom() * maxHeight;
scoreUpdateVar(WD_SHOTS_ON_TARGET); scoreUpdateVar(WD_SHOTS_ON_TARGET);