Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/OpenSHC/Random/RNG.func.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ namespace OpenSHC {
namespace Random {
namespace RNG_Func {

MACRO_FUNCTION_RESOLVER(void (RNG::*)(), false, Address::SHC_3BB0A8C1_0x0046A740, &RNG::setTimeBasedSeed)
MACRO_FUNCTION_RESOLVER(void (RNG::*)(), true, Address::SHC_3BB0A8C1_0x0046A740, &RNG::setTimeBasedSeed)
setTimeBasedSeed;

MACRO_FUNCTION_RESOLVER(void (RNG::*)(), false, Address::SHC_3BB0A8C1_0x0046A760, &RNG::populateRNG1040)
MACRO_FUNCTION_RESOLVER(void (RNG::*)(), true, Address::SHC_3BB0A8C1_0x0046A760, &RNG::populateRNG1040)
populateRNG1040;

MACRO_FUNCTION_RESOLVER(void (RNG::*)(), false, Address::SHC_3BB0A8C1_0x0046A7D0, &RNG::nextRandomNumber2)
MACRO_FUNCTION_RESOLVER(void (RNG::*)(), true, Address::SHC_3BB0A8C1_0x0046A7D0, &RNG::nextRandomNumber2)
nextRandomNumber2;

MACRO_FUNCTION_RESOLVER(void (RNG::*)(), false, Address::SHC_3BB0A8C1_0x0046A800, &RNG::nextRandomNumber1)
MACRO_FUNCTION_RESOLVER(void (RNG::*)(), true, Address::SHC_3BB0A8C1_0x0046A800, &RNG::nextRandomNumber1)
nextRandomNumber1;

} // namespace RNG_Func
Expand Down
17 changes: 17 additions & 0 deletions src/OpenSHC/Random/RNG/Constructor_RNG.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "OpenSHC/Random/RNG.func.hpp"
#include "OpenSHC/Random/RNG.hpp"

namespace OpenSHC {
namespace Random {

// FUNCTION: STRONGHOLDCRUSADER 0x00471810
RNG* RNG::Constructor_RNG()

Copy link
Copy Markdown
Contributor

@TheRedDaemon TheRedDaemon May 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This newline is valid according to our linter settings?
Well, ok. 😅

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like it either hahaha, shall we update the clang-formatter? :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you find a fitting setting, feel free.
It is not horrible if some of this slips through, but better earlier than later.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, short research indicates that there is no specific setting to remove this line break. I think than it is okayish, but if these things happen, try to remove them manually.

{
MACRO_CALL_MEMBER(RNG_Func::setTimeBasedSeed, this)();
MACRO_CALL_MEMBER(RNG_Func::populateRNG1040, this)();
return this;
}

}
}
19 changes: 19 additions & 0 deletions src/OpenSHC/Random/RNG/nextRandomNumber1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

#include "OpenSHC/Random/RNG.hpp"

namespace OpenSHC {
namespace Random {

// FUNCTION: STRONGHOLDCRUSADER 0x0046a800
void RNG::nextRandomNumber1()
{
this->currentNumber1 = this->randomNumbers[this->index1];
this->index1 = this->index1 + 1;
if (20000 <= this->index1) {
this->index1 = 0;
}
return;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think we should use an explicit final return in a void function.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair!

}
}

}
19 changes: 19 additions & 0 deletions src/OpenSHC/Random/RNG/nextRandomNumber2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

#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;
}
return;
}
}

}
36 changes: 36 additions & 0 deletions src/OpenSHC/Random/RNG/populateRNG1040.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#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;
short* _pRandomNumber = &this->randomNumbers[0];
int n = 20000;
do {
int random = MACRO_CALL(OpenSHC::OS_Func::_rand)();
*_pRandomNumber = (short)random;
_pRandomNumber += 1;
n -= 1;
} while (n != 0);
Comment on lines +17 to +24
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unnerving... I would think running over the whole randomNumbers array with a loop assigning numbers would be sensical, but this runs positiv to 0, but 0 index to 19999...why...

I assume making this an up-counting for loop will not create the same effect, hm?
Can you try something like this (although I assume it is likely this does not produce the same code):

for (int i = 0; i < 20000; ++i)
{
    this->randomNumbers[i] =  static_cast<short>(MACRO_CALL(OpenSHC::OS_Func::_rand)());
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, this one is interesting:
It actually works this way and generates the fitting bytecode. Having an inverse counter just seems to be something the compiler decided, so you can use this simpler loop.

I checked how one would get the size of an C array also, but the only thing I found was sizeof(array) / sizeof(array[0]), so one could make this:

for (int i = 0; i < sizeof(this->randomNumbers) / sizeof(this->randomNumbers[0]); i++) {
    this->randomNumbers[i] = MACRO_CALL(OpenSHC::OS_Func::_rand)();
}

One could also make the size of randoms a constant or something, to use in different positions. But I am not sure if this kind of "binding" is something we want to do at this point, since it makes an overreach, leaving the current cpp file.

But it makes my suspicion likelier, that structures like short* _pRandomNumber = &this->randomNumbers[0]; outside of a loop are in general an indicator for a for loop with array access.


this->currentNumber2 = this->randomNumbers[this->index2];
this->index2 += 1;

this->currentNumber1 = this->randomNumbers[this->index1];
this->index1 += 1;

return;
}

}
}
20 changes: 20 additions & 0 deletions src/OpenSHC/Random/RNG/setTimeBasedSeed.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "OpenSHC/OS.func.hpp"
#include "OpenSHC/Random/RNG.func.hpp"
#include "OpenSHC/Random/RNG.hpp"
#include <time.h>

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;
return;
}

}
}
10 changes: 5 additions & 5 deletions status/addresses-SHC-3BB0A8C1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10168,10 +10168,10 @@ SHC_3BB0A8C1_0x0046A4C4 | 0.0% | Pending
SHC_3BB0A8C1_0x0046A4C8 | 0.0% | Pending
Copy link
Copy Markdown
Contributor

@TheRedDaemon TheRedDaemon May 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you count the one that work if the Lib functions are active as 100%?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! I was not sure what to call them. "Reimplemented (non-call matching)"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a similar case in #56. It really depends a bit on how we handle the resolvers. I wrote you on Discord that the partial tests might get harder the more resolvers are active.

If we assume we keep the resolver on false in general, a reimplementation would be 100% if it matches 100% in case the called resolvers are active. In would not make sense otherwise and would not need a special mark, since the non-100% are artifical through the resolvers.

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
Expand Down Expand Up @@ -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
Expand Down
Loading