Expose item manager random seed (synchronized in online too) in scripting
This commit is contained in:
parent
06b11056c8
commit
b29a42719c
@ -50,6 +50,7 @@ std::vector<video::SColorf> ItemManager::m_glow_color;
|
|||||||
bool ItemManager::m_disable_item_collection = false;
|
bool ItemManager::m_disable_item_collection = false;
|
||||||
std::shared_ptr<ItemManager> ItemManager::m_item_manager;
|
std::shared_ptr<ItemManager> ItemManager::m_item_manager;
|
||||||
std::mt19937 ItemManager::m_random_engine;
|
std::mt19937 ItemManager::m_random_engine;
|
||||||
|
uint32_t ItemManager::m_random_seed = 0;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
/** Creates one instance of the item manager. */
|
/** Creates one instance of the item manager. */
|
||||||
|
@ -54,6 +54,8 @@ private:
|
|||||||
static bool m_disable_item_collection;
|
static bool m_disable_item_collection;
|
||||||
|
|
||||||
static std::mt19937 m_random_engine;
|
static std::mt19937 m_random_engine;
|
||||||
|
|
||||||
|
static uint32_t m_random_seed;
|
||||||
protected:
|
protected:
|
||||||
/** The instance of ItemManager while a race is on. */
|
/** The instance of ItemManager while a race is on. */
|
||||||
static std::shared_ptr<ItemManager> m_item_manager;
|
static std::shared_ptr<ItemManager> m_item_manager;
|
||||||
@ -66,7 +68,14 @@ public:
|
|||||||
static void updateRandomSeed(uint32_t seed_number)
|
static void updateRandomSeed(uint32_t seed_number)
|
||||||
{
|
{
|
||||||
m_random_engine.seed(seed_number);
|
m_random_engine.seed(seed_number);
|
||||||
|
m_random_seed = seed_number;
|
||||||
} // updateRandomSeed
|
} // updateRandomSeed
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
static uint32_t getRandomSeed()
|
||||||
|
{
|
||||||
|
return m_random_seed;
|
||||||
|
} // getRandomSeed
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
/** Disable item collection, useful to test client mispreditions or
|
/** Disable item collection, useful to test client mispreditions or
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "input/device_manager.hpp"
|
#include "input/device_manager.hpp"
|
||||||
#include "input/input_device.hpp"
|
#include "input/input_device.hpp"
|
||||||
#include "input/input_manager.hpp"
|
#include "input/input_manager.hpp"
|
||||||
|
#include "items/item_manager.hpp"
|
||||||
#include "modes/world.hpp"
|
#include "modes/world.hpp"
|
||||||
#include "scriptengine/property_animator.hpp"
|
#include "scriptengine/property_animator.hpp"
|
||||||
#include "scriptengine/aswrappedcall.hpp"
|
#include "scriptengine/aswrappedcall.hpp"
|
||||||
@ -185,6 +186,11 @@ namespace Scripting
|
|||||||
return ::Track::getCurrentTrack()->getIsDuringDay();
|
return ::Track::getCurrentTrack()->getIsDuringDay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t getItemManagerRandomSeed()
|
||||||
|
{
|
||||||
|
return ItemManager::getRandomSeed();
|
||||||
|
}
|
||||||
|
|
||||||
void setFog(float maxDensity, float start, float end, int r, int g, int b, float duration)
|
void setFog(float maxDensity, float start, float end, int r, int g, int b, float duration)
|
||||||
{
|
{
|
||||||
PropertyAnimator* animator = PropertyAnimator::get();
|
PropertyAnimator* animator = PropertyAnimator::get();
|
||||||
@ -557,6 +563,10 @@ namespace Scripting
|
|||||||
mp ? WRAP_FN(getMajorRaceMode) : asFUNCTION(getMajorRaceMode),
|
mp ? WRAP_FN(getMajorRaceMode) : asFUNCTION(getMajorRaceMode),
|
||||||
call_conv); assert(r >= 0);
|
call_conv); assert(r >= 0);
|
||||||
|
|
||||||
|
r = engine->RegisterGlobalFunction("uint getItemManagerRandomSeed()",
|
||||||
|
mp ? WRAP_FN(getItemManagerRandomSeed) : asFUNCTION(getItemManagerRandomSeed),
|
||||||
|
call_conv); assert(r >= 0);
|
||||||
|
|
||||||
r = engine->RegisterGlobalFunction("int getMinorRaceMode()",
|
r = engine->RegisterGlobalFunction("int getMinorRaceMode()",
|
||||||
mp ? WRAP_FN(getMinorRaceMode) : asFUNCTION(getMinorRaceMode),
|
mp ? WRAP_FN(getMinorRaceMode) : asFUNCTION(getMinorRaceMode),
|
||||||
call_conv); assert(r >= 0);
|
call_conv); assert(r >= 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user