Update to 14.0-beta1
This commit is contained in:
@@ -10,44 +10,39 @@
|
||||
#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()
|
||||
/* static */ SQInteger 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)
|
||||
/* static */ SQInteger ScriptBase::RandItem(SQInteger)
|
||||
{
|
||||
return ScriptBase::Rand();
|
||||
}
|
||||
|
||||
/* static */ uint ScriptBase::RandRange(uint max)
|
||||
/* static */ SQInteger ScriptBase::RandRange(SQInteger 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);
|
||||
max = Clamp<SQInteger>(max, 0, UINT32_MAX);
|
||||
return ScriptObject::GetRandomizer().Next(max);
|
||||
}
|
||||
|
||||
/* static */ uint32 ScriptBase::RandRangeItem(int unused_param, uint max)
|
||||
/* static */ SQInteger ScriptBase::RandRangeItem(SQInteger, SQInteger max)
|
||||
{
|
||||
return ScriptBase::RandRange(max);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptBase::Chance(uint out, uint max)
|
||||
/* static */ bool ScriptBase::Chance(SQInteger out, SQInteger max)
|
||||
{
|
||||
out = Clamp<SQInteger>(out, 0, UINT32_MAX);
|
||||
max = Clamp<SQInteger>(max, 0, UINT32_MAX);
|
||||
EnforcePrecondition(false, out <= max);
|
||||
return ScriptBase::RandRange(max) < out;
|
||||
}
|
||||
|
||||
/* static */ bool ScriptBase::ChanceItem(int unused_param, uint out, uint max)
|
||||
/* static */ bool ScriptBase::ChanceItem(SQInteger, SQInteger out, SQInteger max)
|
||||
{
|
||||
return ScriptBase::Chance(out, max);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user