fix(Core/Battlegrounds) Rewrite RandomBG and enabling bg/arenas weights (#2516)

This commit is contained in:
Shard
2019-12-28 09:40:13 +01:00
committed by Stoabrogga
parent 5198b2614e
commit 067d9e791f
19 changed files with 210 additions and 221 deletions

View File

@@ -18,9 +18,11 @@
#include <array>
#include <cwchar>
#include <string>
#include <random>
typedef ACE_TSS<SFMTRand> SFMTRandTSS;
static SFMTRandTSS sfmtRand;
static SFMTEngine engine;
int32 irand(int32 min, int32 max)
{
@@ -55,6 +57,17 @@ double rand_chance()
return sfmtRand->Random() * 100.0;
}
uint32 urandweighted(size_t count, double const* chances)
{
std::discrete_distribution<uint32> dd(chances, chances + count);
return dd(SFMTEngine::Instance());
}
SFMTEngine& SFMTEngine::Instance()
{
return engine;
}
Tokenizer::Tokenizer(const std::string &src, const char sep, uint32 vectorReserve)
{
m_str = new char[src.length() + 1];