mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Utils: Changed all Trinity::Containers utilities to work on all container types (including arrays where it makes sense)
* Added MapGetValuePtr to allow writing `if (Val* v = MapGetValuePtr(map, key))` * Added utility IteratorPair class with begin/end methods and MapEqualRange for use in range for syntax with multimaps
This commit is contained in:
@@ -20,8 +20,10 @@
|
||||
#include "Errors.h"
|
||||
#include "SFMT.h"
|
||||
#include <boost/thread/tss.hpp>
|
||||
#include <random>
|
||||
|
||||
static boost::thread_specific_ptr<SFMTRand> sfmtRand;
|
||||
static SFMTEngine engine;
|
||||
|
||||
static SFMTRand* GetRng()
|
||||
{
|
||||
@@ -84,8 +86,13 @@ double rand_chance()
|
||||
return GetRng()->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()
|
||||
{
|
||||
static SFMTEngine engine;
|
||||
return engine;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user