Skip to content

Commit

Permalink
Merge pull request #1562 from paulsapps/master
Browse files Browse the repository at this point in the history
use AE rng seed in AO mixing both really drops a bomb on engine merging
  • Loading branch information
Paul authored Sep 7, 2022
2 parents 212637b + aa26791 commit a86aee5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
5 changes: 5 additions & 0 deletions Source/AliveLibAE/Math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Source/AliveLibAE/Math.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions Source/AliveLibAO/DemoPlayback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -41,7 +39,7 @@ EXPORT DemoPlayback* DemoPlayback::ctor_4517B0(u8** ppPlaybackData, s16 bFromHan
auto pd = reinterpret_cast<PlaybackData*>(*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;
Expand Down
5 changes: 0 additions & 5 deletions Source/AliveLibAO/Math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit a86aee5

Please sign in to comment.