Codechange: move choice for randomizer of scripts to a single location

This commit is contained in:
Rubidium
2023-01-13 23:48:59 +01:00
committed by rubidium42
parent 3373128233
commit 6abad681bd
7 changed files with 23 additions and 19 deletions

View File

@@ -10,17 +10,12 @@
#include "../../stdafx.h"
#include "script_base.hpp"
#include "script_error.hpp"
#include "../../network/network.h"
#include "../../core/random_func.hpp"
#include "../../safeguards.h"
/* static */ uint32 ScriptBase::Rand()
{
/* We pick RandomRange if we are in SP (so when saved, we do the same over and over)
* but we pick InteractiveRandomRange if we are a network_server or network-client. */
if (_networking) return ::InteractiveRandom();
return ::Random();
return ScriptObject::GetRandomizer().Next();
}
/* static */ uint32 ScriptBase::RandItem(int unused_param)
@@ -30,10 +25,7 @@
/* static */ uint ScriptBase::RandRange(uint max)
{
/* We pick RandomRange if we are in SP (so when saved, we do the same over and over)
* but we pick InteractiveRandomRange if we are a network_server or network-client. */
if (_networking) return ::InteractiveRandomRange(max);
return ::RandomRange(max);
return ScriptObject::GetRandomizer().Next(max);
}
/* static */ uint32 ScriptBase::RandRangeItem(int unused_param, uint max)