Skip to content

Commit b5134e6

Browse files
author
sourcehold
committed
reimplement: OpenSHC::Random::RNG 100%
1 parent 9413c23 commit b5134e6

7 files changed

Lines changed: 123 additions & 9 deletions

File tree

src/OpenSHC/Random/RNG.func.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ namespace OpenSHC {
77
namespace Random {
88
namespace RNG_Func {
99

10-
MACRO_FUNCTION_RESOLVER(void (RNG::*)(), false, Address::SHC_3BB0A8C1_0x0046A740, &RNG::setTimeBasedSeed)
10+
MACRO_FUNCTION_RESOLVER(void (RNG::*)(), true, Address::SHC_3BB0A8C1_0x0046A740, &RNG::setTimeBasedSeed)
1111
setTimeBasedSeed;
1212

13-
MACRO_FUNCTION_RESOLVER(void (RNG::*)(), false, Address::SHC_3BB0A8C1_0x0046A760, &RNG::populateRNG1040)
13+
MACRO_FUNCTION_RESOLVER(void (RNG::*)(), true, Address::SHC_3BB0A8C1_0x0046A760, &RNG::populateRNG1040)
1414
populateRNG1040;
1515

16-
MACRO_FUNCTION_RESOLVER(void (RNG::*)(), false, Address::SHC_3BB0A8C1_0x0046A7D0, &RNG::nextRandomNumber2)
16+
MACRO_FUNCTION_RESOLVER(void (RNG::*)(), true, Address::SHC_3BB0A8C1_0x0046A7D0, &RNG::nextRandomNumber2)
1717
nextRandomNumber2;
1818

19-
MACRO_FUNCTION_RESOLVER(void (RNG::*)(), false, Address::SHC_3BB0A8C1_0x0046A800, &RNG::nextRandomNumber1)
19+
MACRO_FUNCTION_RESOLVER(void (RNG::*)(), true, Address::SHC_3BB0A8C1_0x0046A800, &RNG::nextRandomNumber1)
2020
nextRandomNumber1;
2121

2222
} // namespace RNG_Func
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include "OpenSHC/Random/RNG.func.hpp"
2+
#include "OpenSHC/Random/RNG.hpp"
3+
4+
namespace OpenSHC {
5+
namespace Random {
6+
7+
// FUNCTION: STRONGHOLDCRUSADER 0x00471810
8+
RNG* RNG::Constructor_RNG()
9+
10+
{
11+
MACRO_CALL_MEMBER(RNG_Func::setTimeBasedSeed, this)();
12+
MACRO_CALL_MEMBER(RNG_Func::populateRNG1040, this)();
13+
return this;
14+
}
15+
16+
}
17+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
#include "OpenSHC/Random/RNG.hpp"
3+
4+
namespace OpenSHC {
5+
namespace Random {
6+
7+
// FUNCTION: STRONGHOLDCRUSADER 0x0046a800
8+
void RNG::nextRandomNumber1()
9+
{
10+
this->currentNumber1 = this->randomNumbers[this->index1];
11+
this->index1 = this->index1 + 1;
12+
if (20000 <= this->index1) {
13+
this->index1 = 0;
14+
}
15+
return;
16+
}
17+
}
18+
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
#include "OpenSHC/Random/RNG.hpp"
3+
4+
namespace OpenSHC {
5+
namespace Random {
6+
7+
// FUNCTION: STRONGHOLDCRUSADER 0x0046a7d0
8+
void RNG::nextRandomNumber2()
9+
{
10+
this->currentNumber2 = this->randomNumbers[this->index2];
11+
this->index2 = this->index2 + 1;
12+
if (20000 <= this->index2) {
13+
this->index2 = 0;
14+
}
15+
return;
16+
}
17+
}
18+
19+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include "OpenSHC/Global.func.hpp"
2+
#include "OpenSHC/OS.func.hpp"
3+
#include "OpenSHC/Random/RNG.func.hpp"
4+
#include "OpenSHC/Random/RNG.hpp"
5+
6+
namespace OpenSHC {
7+
namespace Random {
8+
9+
// FUNCTION: STRONGHOLDCRUSADER 0x0046a760
10+
void RNG::populateRNG1040()
11+
12+
{
13+
int iVar1;
14+
int iVar2;
15+
short* _pRandomNumber;
16+
17+
MACRO_CALL(OpenSHC::Global_Func::SetRNGSeed)(this->seed);
18+
this->index2 = 0;
19+
this->index1 = 0;
20+
_pRandomNumber = &this->randomNumbers[0];
21+
iVar2 = 20000;
22+
do {
23+
iVar1 = MACRO_CALL(OpenSHC::OS_Func::_rand)();
24+
*_pRandomNumber = (short)iVar1;
25+
_pRandomNumber = _pRandomNumber + 1;
26+
iVar2 = iVar2 + -1;
27+
} while (iVar2 != 0);
28+
29+
this->currentNumber2 = this->randomNumbers[this->index2];
30+
this->index2 = this->index2 + 1;
31+
32+
this->currentNumber1 = this->randomNumbers[this->index1];
33+
this->index1 = this->index1 + 1;
34+
35+
return;
36+
}
37+
38+
}
39+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include "OpenSHC/OS.func.hpp"
2+
#include "OpenSHC/Random/RNG.func.hpp"
3+
#include "OpenSHC/Random/RNG.hpp"
4+
#include <time.h>
5+
6+
namespace OpenSHC {
7+
namespace Random {
8+
9+
// FUNCTION: STRONGHOLDCRUSADER 0x0046a740
10+
void RNG::setTimeBasedSeed()
11+
12+
{
13+
14+
__time64_t _Var1 = MACRO_CALL(OpenSHC::OS_Func::__time64)((__time64_t*)0x0);
15+
this->seed = (int)_Var1;
16+
return;
17+
}
18+
19+
}
20+
}

status/addresses-SHC-3BB0A8C1.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10168,10 +10168,10 @@ SHC_3BB0A8C1_0x0046A4C4 | 0.0% | Pending
1016810168
SHC_3BB0A8C1_0x0046A4C8 | 0.0% | Pending
1016910169
SHC_3BB0A8C1_0x0046A4D0 | 0.0% | Pending
1017010170
SHC_3BB0A8C1_0x0046A720 | 0.0% | Pending
10171-
SHC_3BB0A8C1_0x0046A740 | 0.0% | Pending
10172-
SHC_3BB0A8C1_0x0046A760 | 0.0% | Pending
10173-
SHC_3BB0A8C1_0x0046A7D0 | 0.0% | Pending
10174-
SHC_3BB0A8C1_0x0046A800 | 0.0% | Pending
10171+
SHC_3BB0A8C1_0x0046A740 | 100.0% | Reimplemented
10172+
SHC_3BB0A8C1_0x0046A760 | 100.0% | Reimplemented
10173+
SHC_3BB0A8C1_0x0046A7D0 | 100.0% | Reimplemented
10174+
SHC_3BB0A8C1_0x0046A800 | 100.0% | Reimplemented
1017510175
SHC_3BB0A8C1_0x0046A830 | 0.0% | Pending
1017610176
SHC_3BB0A8C1_0x0046A850 | 0.0% | Pending
1017710177
SHC_3BB0A8C1_0x0046A890 | 0.0% | Pending
@@ -10475,7 +10475,7 @@ SHC_3BB0A8C1_0x004717F8 | 0.0% | Pending
1047510475
SHC_3BB0A8C1_0x004717FC | 0.0% | Pending
1047610476
SHC_3BB0A8C1_0x00471800 | 0.0% | Pending
1047710477
SHC_3BB0A8C1_0x00471804 | 0.0% | Pending
10478-
SHC_3BB0A8C1_0x00471810 | 0.0% | Pending
10478+
SHC_3BB0A8C1_0x00471810 | 100.0% | Reimplemented
1047910479
SHC_3BB0A8C1_0x00471830 | 0.0% | Pending
1048010480
SHC_3BB0A8C1_0x00471860 | 0.0% | Pending
1048110481
SHC_3BB0A8C1_0x00471890 | 0.0% | Pending

0 commit comments

Comments
 (0)