From aa267919ae42456e6dea158140f6c5e675aa0abc Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 7 Sep 2022 22:53:56 +0100 Subject: [PATCH] use AE rng seed in AO mixing both really drops a bomb on engine merging --- Source/AliveLibAE/Math.cpp | 5 +++++ Source/AliveLibAE/Math.hpp | 2 ++ Source/AliveLibAO/DemoPlayback.cpp | 4 +--- Source/AliveLibAO/Math.cpp | 5 ----- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/AliveLibAE/Math.cpp b/Source/AliveLibAE/Math.cpp index f1dc04a00..be0200356 100644 --- a/Source/AliveLibAE/Math.cpp +++ b/Source/AliveLibAE/Math.cpp @@ -32,6 +32,11 @@ ALIVE_ARY(1, 0x546744, u8, 256, sRandomBytes_546744, ALIVE_VAR(1, 0x5D1E10, u8, sRandomSeed_5D1E10, 0); +EXPORT void AE_SetRndSeed(u8 v) +{ + sRandomSeed_5D1E10 = v; +} + EXPORT u32 CC Math_FixedPoint_Multiply_496C50(s32 op1, s32 op2) { u32 op1a; // ecx diff --git a/Source/AliveLibAE/Math.hpp b/Source/AliveLibAE/Math.hpp index 815507df4..bc3a1fd96 100644 --- a/Source/AliveLibAE/Math.hpp +++ b/Source/AliveLibAE/Math.hpp @@ -7,6 +7,8 @@ using FP = FixedPoint; void Math_ForceLink(); +EXPORT void AE_SetRndSeed(u8 v); + EXPORT u32 CC Math_FixedPoint_Multiply_496C50(s32 op1, s32 op2); EXPORT u32 CC Math_FixedPoint_Divide_496B70(s32 op1, s32 op2); EXPORT s16 CC Math_RandomRange_496AB0(s16 min, s16 max); diff --git a/Source/AliveLibAO/DemoPlayback.cpp b/Source/AliveLibAO/DemoPlayback.cpp index 1fef1a10a..d0dfcdf26 100644 --- a/Source/AliveLibAO/DemoPlayback.cpp +++ b/Source/AliveLibAO/DemoPlayback.cpp @@ -12,8 +12,6 @@ namespace AO { -ALIVE_VAR_EXTERN(u8, sRandomSeed_50A228); //Math.cpp - EXPORT DemoPlayback* DemoPlayback::ctor_4517B0(u8** ppPlaybackData, s16 bFromHandStone) { ctor_487E10(1); @@ -41,7 +39,7 @@ EXPORT DemoPlayback* DemoPlayback::ctor_4517B0(u8** ppPlaybackData, s16 bFromHan auto pd = reinterpret_cast(*ppPlaybackData); ResourceManager::Set_Header_Flags_4557D0(ppPlaybackData, ResourceManager::ResourceHeaderFlags::eLocked); SaveGame::LoadFromMemory_459970(&pd->saveData, 1); - sRandomSeed_50A228 = pd->randomSeed; + AE_SetRndSeed(pd->randomSeed); field_10_state = States::eState_0_Init; field_14_ppDemoRes = ppPlaybackData; field_8_update_delay = 1; diff --git a/Source/AliveLibAO/Math.cpp b/Source/AliveLibAO/Math.cpp index 6750079fe..cc0222393 100644 --- a/Source/AliveLibAO/Math.cpp +++ b/Source/AliveLibAO/Math.cpp @@ -29,14 +29,9 @@ ALIVE_ARY(1, 0x4BBE30, u8, 256, sRandomBytes_4BBE30, }); // clang-format on -ALIVE_VAR(1, 0x50A228, u8, sRandomSeed_50A228, 0); u8 Math_NextRandom() { - if (!RunningAsInjectedDll()) - { - return sRandomBytes_4BBE30[sRandomSeed_50A228++]; - } return ::Math_NextRandom(); // Ae ver }