Fix pointer alignment of default random generator object.

This commit is contained in:
Sasha Szpakowski
2024-02-25 11:23:52 -04:00
parent e20f018272
commit 476e520969
2 changed files with 7 additions and 4 deletions
+3 -2
View File
@@ -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()
+4 -2
View File
@@ -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