Added static RNGseed control

This commit is contained in:
Edward Richardson 2014-05-03 02:11:16 +12:00
parent 940794929c
commit d6af8dc352
4 changed files with 53 additions and 2 deletions

View file

@ -1993,6 +1993,13 @@ static void D_DoomInit()
SetLanguageIDs (); SetLanguageIDs ();
const char *v = Args->CheckValue("-rngseed");
if (v)
{
rngseed = staticrngseed = atoi(v);
use_staticrng = true;
}
else
rngseed = I_MakeRNGSeed(); rngseed = I_MakeRNGSeed();
FRandom::StaticClearRandom (); FRandom::StaticClearRandom ();

View file

@ -408,7 +408,11 @@ void G_InitNew (const char *mapname, bool bTitleLevel)
if (!savegamerestore) if (!savegamerestore)
{ {
if (!netgame) if (use_staticrng)
{
rngseed = staticrngseed;
}
else if (!netgame)
{ // [RH] Change the random seed for each new single player game { // [RH] Change the random seed for each new single player game
rngseed = rngseed + 1; rngseed = rngseed + 1;
} }

View file

@ -96,6 +96,42 @@ FRandom M_Random;
// Global seed. This is modified predictably to initialize every RNG. // Global seed. This is modified predictably to initialize every RNG.
DWORD rngseed; DWORD rngseed;
// Static RNG marker. This is only used when the RNG is set for each new game.
DWORD staticrngseed;
bool use_staticrng;
// Allows checking or staticly setting the global seed.
CCMD(rngseed)
{
if (argv.argc() == 1)
{
Printf("Usage: rngseed get|set|clear\n");
return;
}
if (stricmp(argv[1], "get") == 0)
{
Printf("rngseed is %d\n", rngseed);
}
else if (stricmp(argv[1], "set") == 0)
{
if (argv.argc() == 2)
{
Printf("You need to specify a value to set\n");
}
else
{
staticrngseed = atoi(argv[2]);
use_staticrng = true;
Printf("Static rngseed %d will be set for next game\n", staticrngseed);
}
}
else if (stricmp(argv[1], "clear") == 0)
{
use_staticrng = false;
Printf("Static rngseed cleared\n");
}
}
// PRIVATE DATA DEFINITIONS ------------------------------------------------ // PRIVATE DATA DEFINITIONS ------------------------------------------------
FRandom *FRandom::RNGList; FRandom *FRandom::RNGList;

View file

@ -215,6 +215,10 @@ private:
extern DWORD rngseed; // The starting seed (not part of state) extern DWORD rngseed; // The starting seed (not part of state)
extern DWORD staticrngseed; // Static rngseed that can be set by the user
extern bool use_staticrng;
// M_Random can be used for numbers that do not affect gameplay // M_Random can be used for numbers that do not affect gameplay
extern FRandom M_Random; extern FRandom M_Random;