mirror of
https://github.com/love2d/love.git
synced 2026-08-19 20:19:42 +02:00
Fix pointer alignment of default random generator object.
This commit is contained in:
@@ -201,11 +201,12 @@ float linearToGamma(float c)
|
|||||||
|
|
||||||
Math::Math()
|
Math::Math()
|
||||||
: Module(M_MATH, "love.math")
|
: Module(M_MATH, "love.math")
|
||||||
, rng()
|
|
||||||
{
|
{
|
||||||
RandomGenerator::Seed seed;
|
RandomGenerator::Seed seed;
|
||||||
seed.b64 = (uint64) time(nullptr);
|
seed.b64 = (uint64) time(nullptr);
|
||||||
rng.setSeed(seed);
|
|
||||||
|
rng.set(new RandomGenerator(), Acquire::NORETAIN);
|
||||||
|
rng->setSeed(seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
Math::~Math()
|
Math::~Math()
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public:
|
|||||||
|
|
||||||
RandomGenerator *getRandomGenerator()
|
RandomGenerator *getRandomGenerator()
|
||||||
{
|
{
|
||||||
return &rng;
|
return rng.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -120,7 +120,9 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
RandomGenerator rng;
|
// All love objects accessible in Lua should be heap-allocated,
|
||||||
|
// to guarantee a minimum pointer alignment.
|
||||||
|
StrongRef<RandomGenerator> rng;
|
||||||
|
|
||||||
}; // Math
|
}; // Math
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user