mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +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()
|
||||
: Module(M_MATH, "love.math")
|
||||
, rng()
|
||||
{
|
||||
RandomGenerator::Seed seed;
|
||||
seed.b64 = (uint64) time(nullptr);
|
||||
rng.setSeed(seed);
|
||||
|
||||
rng.set(new RandomGenerator(), Acquire::NORETAIN);
|
||||
rng->setSeed(seed);
|
||||
}
|
||||
|
||||
Math::~Math()
|
||||
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
|
||||
RandomGenerator *getRandomGenerator()
|
||||
{
|
||||
return &rng;
|
||||
return rng.get();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,7 +120,9 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
RandomGenerator rng;
|
||||
// All love objects accessible in Lua should be heap-allocated,
|
||||
// to guarantee a minimum pointer alignment.
|
||||
StrongRef<RandomGenerator> rng;
|
||||
|
||||
}; // Math
|
||||
|
||||
|
||||
Reference in New Issue
Block a user