Universalize a single call to srand() on map init (#1422)

This commit is contained in:
Deathreus 2021-03-07 07:54:27 -05:00 committed by GitHub
parent 5bc48b2ab3
commit f9633a5f6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 3 additions and 6 deletions

View File

@ -1174,7 +1174,6 @@ void CExtensionManager::OnRootConsoleCommand(const char *cmdname, const ICommand
rootmenu->ConsolePrint(" -> %s", pPlugin->GetFilename());
}
}
srand(static_cast<int>(time(NULL)));
pExt->unload_code = (rand() % 877) + 123; //123 to 999
rootmenu->ConsolePrint("[SM] To verify unloading %s, please use the following: ", pExt->GetFilename());
rootmenu->ConsolePrint("[SM] sm exts unload %d %d", num, pExt->unload_code);

View File

@ -485,7 +485,6 @@ void CMenuHandler::OnMenuVoteResults(IBaseMenu *menu, const menu_vote_result_t *
if (num_items > 1)
{
/* Yes, we do. */
srand(time(NULL));
winning_item = rand() % num_items;
winning_item = results->item_list[winning_item].item;
} else {

View File

@ -91,8 +91,6 @@ enum SortOrder
void sort_random(cell_t *array, cell_t size)
{
srand((unsigned int)time(NULL));
for (int i = size-1; i > 0; i--)
{
int n = rand() % (i + 1);
@ -442,8 +440,6 @@ void sort_adt_random(CellArray *cArray)
{
size_t arraysize = cArray->size();
srand((unsigned int)time(NULL));
for (int i = arraysize-1; i > 0; i--)
{
int n = rand() % (i + 1);

View File

@ -337,6 +337,9 @@ void SourceModBase::StartSourceMod(bool late)
static bool g_LevelEndBarrier = false;
bool SourceModBase::LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background)
{
/* Seed rand() globally per map */
srand(time(NULL));
g_Players.MaxPlayersChanged();
/* If we're not loaded... */