diff --git a/src/OpenSHC/Random/RNG/Constructor_RNG.cpp b/src/OpenSHC/Random/RNG/Constructor_RNG.cpp new file mode 100644 index 00000000..9360960a --- /dev/null +++ b/src/OpenSHC/Random/RNG/Constructor_RNG.cpp @@ -0,0 +1,16 @@ +#include "OpenSHC/Random/RNG.func.hpp" +#include "OpenSHC/Random/RNG.hpp" + +namespace OpenSHC { +namespace Random { + + // FUNCTION: STRONGHOLDCRUSADER 0x00471810 + RNG* RNG::Constructor_RNG() + { + MACRO_CALL_MEMBER(RNG_Func::setTimeBasedSeed, this)(); + MACRO_CALL_MEMBER(RNG_Func::populateRNG1040, this)(); + return this; + } + +} +} diff --git a/src/OpenSHC/Random/RNG/nextRandomNumber1.cpp b/src/OpenSHC/Random/RNG/nextRandomNumber1.cpp new file mode 100644 index 00000000..988ef465 --- /dev/null +++ b/src/OpenSHC/Random/RNG/nextRandomNumber1.cpp @@ -0,0 +1,18 @@ + +#include "OpenSHC/Random/RNG.hpp" + +namespace OpenSHC { +namespace Random { + + // FUNCTION: STRONGHOLDCRUSADER 0x0046A800 + void RNG::nextRandomNumber1() + { + this->currentNumber1 = this->randomNumbers[this->index1]; + this->index1 += 1; + if (20000 <= this->index1) { + this->index1 = 0; + } + } +} + +} diff --git a/src/OpenSHC/Random/RNG/nextRandomNumber2.cpp b/src/OpenSHC/Random/RNG/nextRandomNumber2.cpp new file mode 100644 index 00000000..cb2de6af --- /dev/null +++ b/src/OpenSHC/Random/RNG/nextRandomNumber2.cpp @@ -0,0 +1,18 @@ + +#include "OpenSHC/Random/RNG.hpp" + +namespace OpenSHC { +namespace Random { + + // FUNCTION: STRONGHOLDCRUSADER 0x0046a7d0 + void RNG::nextRandomNumber2() + { + this->currentNumber2 = this->randomNumbers[this->index2]; + this->index2 = this->index2 + 1; + if (20000 <= this->index2) { + this->index2 = 0; + } + } +} + +} diff --git a/src/OpenSHC/Random/RNG/populateRNG1040.cpp b/src/OpenSHC/Random/RNG/populateRNG1040.cpp new file mode 100644 index 00000000..170f957f --- /dev/null +++ b/src/OpenSHC/Random/RNG/populateRNG1040.cpp @@ -0,0 +1,27 @@ +#include "OpenSHC/Global.func.hpp" +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Random/RNG.func.hpp" +#include "OpenSHC/Random/RNG.hpp" + +namespace OpenSHC { +namespace Random { + + // FUNCTION: STRONGHOLDCRUSADER 0x0046a760 + void RNG::populateRNG1040() + { + MACRO_CALL(OpenSHC::Global_Func::SetRNGSeed)(this->seed); + this->index2 = 0; + this->index1 = 0; + for (int i = 0; i < 20000; i++) { + this->randomNumbers[i] = MACRO_CALL(OpenSHC::OS_Func::_rand)(); + } + + this->currentNumber2 = this->randomNumbers[this->index2]; + this->index2 += 1; + + this->currentNumber1 = this->randomNumbers[this->index1]; + this->index1 += 1; + } + +} +} diff --git a/src/OpenSHC/Random/RNG/setTimeBasedSeed.cpp b/src/OpenSHC/Random/RNG/setTimeBasedSeed.cpp new file mode 100644 index 00000000..4d4643af --- /dev/null +++ b/src/OpenSHC/Random/RNG/setTimeBasedSeed.cpp @@ -0,0 +1,17 @@ +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Random/RNG.func.hpp" +#include "OpenSHC/Random/RNG.hpp" +#include + +namespace OpenSHC { +namespace Random { + + // FUNCTION: STRONGHOLDCRUSADER 0x0046A740 + void RNG::setTimeBasedSeed() + { + __time64_t time = MACRO_CALL(OpenSHC::OS_Func::__time64)((__time64_t*)0x0); + this->seed = (int)time; + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 36120333..d09f48e2 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -10168,10 +10168,10 @@ SHC_3BB0A8C1_0x0046A4C4 | 0.0% | Pending SHC_3BB0A8C1_0x0046A4C8 | 0.0% | Pending SHC_3BB0A8C1_0x0046A4D0 | 0.0% | Pending SHC_3BB0A8C1_0x0046A720 | 0.0% | Pending -SHC_3BB0A8C1_0x0046A740 | 0.0% | Pending -SHC_3BB0A8C1_0x0046A760 | 0.0% | Pending -SHC_3BB0A8C1_0x0046A7D0 | 0.0% | Pending -SHC_3BB0A8C1_0x0046A800 | 0.0% | Pending +SHC_3BB0A8C1_0x0046A740 | 100.0% | Reimplemented +SHC_3BB0A8C1_0x0046A760 | 100.0% | Reimplemented +SHC_3BB0A8C1_0x0046A7D0 | 100.0% | Reimplemented +SHC_3BB0A8C1_0x0046A800 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0046A830 | 0.0% | Pending SHC_3BB0A8C1_0x0046A850 | 0.0% | Pending SHC_3BB0A8C1_0x0046A890 | 0.0% | Pending @@ -10475,7 +10475,7 @@ SHC_3BB0A8C1_0x004717F8 | 0.0% | Pending SHC_3BB0A8C1_0x004717FC | 0.0% | Pending SHC_3BB0A8C1_0x00471800 | 0.0% | Pending SHC_3BB0A8C1_0x00471804 | 0.0% | Pending -SHC_3BB0A8C1_0x00471810 | 0.0% | Pending +SHC_3BB0A8C1_0x00471810 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00471830 | 0.0% | Pending SHC_3BB0A8C1_0x00471860 | 0.0% | Pending SHC_3BB0A8C1_0x00471890 | 0.0% | Pending