Space Viking's many mercs changes plus numerous generic bug fixes

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@2498 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
SpaceViking
2009-01-15 01:26:13 +00:00
parent f64f58fbf8
commit f26095d86f
138 changed files with 3493 additions and 3265 deletions
+11 -57
View File
@@ -1,23 +1,11 @@
#ifdef JA2_PRECOMPILED_HEADERS
#include "JA2 SGP ALL.H"
#elif defined( WIZ8_PRECOMPILED_HEADERS )
#include "WIZ8 SGP ALL.H"
#else
#include "Random.h"
#endif
#ifdef PRERANDOM_GENERATOR
UINT32 guiPreRandomIndex = 0;
UINT32 guiPreRandomNums[ MAX_PREGENERATED_NUMS ];
#ifdef JA2BETAVERSION
UINT32 guiRandoms = 0;
UINT32 guiPreRandoms = 0;
BOOLEAN gfCountRandoms = FALSE;
#endif
#endif
UINT32 guiPreRandomIndex = 0;
UINT32 guiPreRandomNums[ MAX_PREGENERATED_NUMS ];
void InitializeRandom()
@@ -25,27 +13,19 @@ void InitializeRandom()
// Seed the random-number generator with current time so that
// the numbers will be different every time we run.
srand( (unsigned) time(NULL) );
#ifdef PRERANDOM_GENERATOR
//Pregenerate all of the random numbers.
for( guiPreRandomIndex = 0; guiPreRandomIndex < MAX_PREGENERATED_NUMS; guiPreRandomIndex++ )
{
guiPreRandomNums[ guiPreRandomIndex ] = rand();
}
guiPreRandomIndex = 0;
#endif
//Pregenerate all of the random numbers.
for( guiPreRandomIndex = 0; guiPreRandomIndex < MAX_PREGENERATED_NUMS; guiPreRandomIndex++ )
{
guiPreRandomNums[ guiPreRandomIndex ] = rand();
}
guiPreRandomIndex = 0;
}
// Returns a pseudo-random integer between 0 and uiRange
UINT32 Random(UINT32 uiRange)
{
// Always return 0, if no range given (it's not an error)
#ifdef JA2BETAVERSION
if( gfCountRandoms )
{
guiRandoms++;
}
#endif
if (uiRange == 0)
return(0);
return rand() * uiRange / RAND_MAX % uiRange;
@@ -53,20 +33,13 @@ UINT32 Random(UINT32 uiRange)
BOOLEAN Chance( UINT32 uiChance )
{
AssertLE(uiChance, 100);
return (BOOLEAN)(Random( 100 ) < uiChance);
}
#ifdef PRERANDOM_GENERATOR
UINT32 PreRandom( UINT32 uiRange )
{
UINT32 uiNum;
#ifdef JA2BETAVERSION
if( gfCountRandoms )
{
guiPreRandoms++;
}
#endif
if( !uiRange )
return 0;
//Extract the current pregenerated number
@@ -98,25 +71,6 @@ UINT32 PreRandom( UINT32 uiRange )
BOOLEAN PreChance( UINT32 uiChance )
{
AssertLE(uiChance, 100);
return (BOOLEAN)(PreRandom( 100 ) < uiChance);
}
#ifdef JA2BETAVERSION
void CountRandomCalls( BOOLEAN fStart )
{
gfCountRandoms = fStart;
if( fStart )
{
guiRandoms = 0;
guiPreRandoms = 0;
}
}
void GetRandomCalls( UINT32 *puiRandoms, UINT32 *puiPreRandoms )
{
*puiRandoms = guiRandoms;
*puiPreRandoms = guiPreRandoms;
}
#endif
#endif