From c802749836521b7e8b5ff1ac8c839781a50a607c Mon Sep 17 00:00:00 2001 From: TheRedDaemon <66257843+TheRedDaemon@users.noreply.github.com> Date: Sun, 30 Aug 2026 19:55:37 +0200 Subject: [PATCH 1/2] reimplement: OpenSHC::Util::Timing::Stopwatch 100% --- .../Stopwatch/Constructor_Stopwatch.cpp | 17 ++++++++++++++++ src/OpenSHC/Util/Timing/Stopwatch/start.cpp | 16 +++++++++++++++ src/OpenSHC/Util/Timing/Stopwatch/stop.cpp | 20 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 4 ++-- 4 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 src/OpenSHC/Util/Timing/Stopwatch/Constructor_Stopwatch.cpp create mode 100644 src/OpenSHC/Util/Timing/Stopwatch/start.cpp create mode 100644 src/OpenSHC/Util/Timing/Stopwatch/stop.cpp diff --git a/src/OpenSHC/Util/Timing/Stopwatch/Constructor_Stopwatch.cpp b/src/OpenSHC/Util/Timing/Stopwatch/Constructor_Stopwatch.cpp new file mode 100644 index 00000000..e5cdf312 --- /dev/null +++ b/src/OpenSHC/Util/Timing/Stopwatch/Constructor_Stopwatch.cpp @@ -0,0 +1,17 @@ +#include "../Stopwatch.func.hpp" + +namespace OpenSHC { +namespace Util { + namespace Timing { + + // FUNCTION: STRONGHOLDCRUSADER 0x0046CEC0 + Stopwatch* Stopwatch::Constructor_Stopwatch() + { + this->running_0x4 = FALSE; + this->duration_0x0 = 0; + return this; + } + + } +} +} diff --git a/src/OpenSHC/Util/Timing/Stopwatch/start.cpp b/src/OpenSHC/Util/Timing/Stopwatch/start.cpp new file mode 100644 index 00000000..8f1feef1 --- /dev/null +++ b/src/OpenSHC/Util/Timing/Stopwatch/start.cpp @@ -0,0 +1,16 @@ +#include "../Stopwatch.func.hpp" + +namespace OpenSHC { +namespace Util { + namespace Timing { + + // FUNCTION: STRONGHOLDCRUSADER 0x0046CED0 + void Stopwatch::start() + { + this->startTime_0x8 = timeGetTime(); + this->running_0x4 = TRUE; + } + + } +} +} diff --git a/src/OpenSHC/Util/Timing/Stopwatch/stop.cpp b/src/OpenSHC/Util/Timing/Stopwatch/stop.cpp new file mode 100644 index 00000000..9d3991d8 --- /dev/null +++ b/src/OpenSHC/Util/Timing/Stopwatch/stop.cpp @@ -0,0 +1,20 @@ +#include "../Stopwatch.func.hpp" + +namespace OpenSHC { +namespace Util { + namespace Timing { + + // FUNCTION: STRONGHOLDCRUSADER 0x0046CEF0 + void Stopwatch::stop() + { + if (!this->running_0x4) { + return; + } + this->stopTime_0xc = timeGetTime(); + this->running_0x4 = FALSE; + this->duration_0x0 = this->stopTime_0xc - this->startTime_0x8; + } + + } +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 6b3a4b48..9db18dd7 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -20967,9 +20967,9 @@ SHC_3BB0A8C1_0x0046CEAC | 0.0% | Pending SHC_3BB0A8C1_0x0046CEB0 | 0.0% | Pending -SHC_3BB0A8C1_0x0046CEC0 | 0.0% | Pending +SHC_3BB0A8C1_0x0046CEC0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0046CED0 | 0.0% | Pending +SHC_3BB0A8C1_0x0046CED0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0046CEF0 | 0.0% | Pending From 1c10daaebc5616677e768d83b4dc13279eab37b0 Mon Sep 17 00:00:00 2001 From: TheRedDaemon <66257843+TheRedDaemon@users.noreply.github.com> Date: Sun, 30 Aug 2026 20:51:46 +0200 Subject: [PATCH 2/2] reimplement: OpenSHC::Util::WideCharMultiByteState 100% --- .../Util/WideCharMultiByteState.func.hpp | 18 +++++++++--------- src/OpenSHC/Util/WideCharMultiByteState.hpp | 8 ++++---- .../multiByteToWideCharWithSize.cpp | 19 +++++++++++++++++++ .../multiByteToWideCharacter.cpp | 17 +++++++++++++++++ .../singleMultiByteToWideChar.cpp | 16 ++++++++++++++++ .../singleWideCharToMultiByte.cpp | 16 ++++++++++++++++ .../wideCharToMultiByteComplete.cpp | 17 +++++++++++++++++ .../wideCharToMultiByteWithSize.cpp | 19 +++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 14 +++++++------- 9 files changed, 124 insertions(+), 20 deletions(-) create mode 100644 src/OpenSHC/Util/WideCharMultiByteState/multiByteToWideCharWithSize.cpp create mode 100644 src/OpenSHC/Util/WideCharMultiByteState/multiByteToWideCharacter.cpp create mode 100644 src/OpenSHC/Util/WideCharMultiByteState/singleMultiByteToWideChar.cpp create mode 100644 src/OpenSHC/Util/WideCharMultiByteState/singleWideCharToMultiByte.cpp create mode 100644 src/OpenSHC/Util/WideCharMultiByteState/wideCharToMultiByteComplete.cpp create mode 100644 src/OpenSHC/Util/WideCharMultiByteState/wideCharToMultiByteWithSize.cpp diff --git a/src/OpenSHC/Util/WideCharMultiByteState.func.hpp b/src/OpenSHC/Util/WideCharMultiByteState.func.hpp index bd28d4ad..808056fc 100644 --- a/src/OpenSHC/Util/WideCharMultiByteState.func.hpp +++ b/src/OpenSHC/Util/WideCharMultiByteState.func.hpp @@ -13,7 +13,7 @@ namespace Util { Address::SHC_3BB0A8C1_0x0046B080, &WideCharMultiByteState::wideCharToMultiByteComplete) wideCharToMultiByteComplete; - MACRO_FUNCTION_RESOLVER(void (WideCharMultiByteState::*)(LPWSTR, LPCSTR), false, + MACRO_FUNCTION_RESOLVER(int (WideCharMultiByteState::*)(LPWSTR, LPCSTR), false, Address::SHC_3BB0A8C1_0x0046B0D0, &WideCharMultiByteState::multiByteToWideCharacter) multiByteToWideCharacter; @@ -21,17 +21,17 @@ namespace Util { Address::SHC_3BB0A8C1_0x0046B110, &WideCharMultiByteState::wideCharToMultiByteWithSize) wideCharToMultiByteWithSize; - MACRO_FUNCTION_RESOLVER(void (WideCharMultiByteState::*)(LPWSTR, LPCSTR, int), false, - Address::SHC_3BB0A8C1_0x0046B140, &WideCharMultiByteState::multiByteToWideCharThunk) - multiByteToWideCharThunk; + MACRO_FUNCTION_RESOLVER(int (WideCharMultiByteState::*)(LPWSTR, LPCSTR, int), false, + Address::SHC_3BB0A8C1_0x0046B140, &WideCharMultiByteState::multiByteToWideCharWithSize) + multiByteToWideCharWithSize; MACRO_FUNCTION_RESOLVER(char (WideCharMultiByteState::*)(WCHAR), false, Address::SHC_3BB0A8C1_0x0046B170, - &WideCharMultiByteState::wideCharToByteUnk) - wideCharToByteUnk; + &WideCharMultiByteState::singleWideCharToMultiByte) + singleWideCharToMultiByte; - MACRO_FUNCTION_RESOLVER(void (WideCharMultiByteState::*)(char const), false, Address::SHC_3BB0A8C1_0x0046B1B0, - &WideCharMultiByteState::multiByteToWideCharThunk2) - multiByteToWideCharThunk2; + MACRO_FUNCTION_RESOLVER(WCHAR (WideCharMultiByteState::*)(char), false, Address::SHC_3BB0A8C1_0x0046B1B0, + &WideCharMultiByteState::singleMultiByteToWideChar) + singleMultiByteToWideChar; } // namespace WideCharMultiByteState_Func } // namespace Util diff --git a/src/OpenSHC/Util/WideCharMultiByteState.hpp b/src/OpenSHC/Util/WideCharMultiByteState.hpp index e2ec2173..448f3056 100644 --- a/src/OpenSHC/Util/WideCharMultiByteState.hpp +++ b/src/OpenSHC/Util/WideCharMultiByteState.hpp @@ -30,15 +30,15 @@ namespace Util { int wideCharToMultiByteComplete(LPSTR charOut, LPCWSTR wideCharIn); - void multiByteToWideCharacter(LPWSTR param_1, LPCSTR param_2); + int multiByteToWideCharacter(LPWSTR lpWideCharStr, LPCSTR lpMultiByteStr); int wideCharToMultiByteWithSize(LPSTR lpMultiByteStr, LPWSTR lpWideCharStr, int numOfSymbols); - void multiByteToWideCharThunk(LPWSTR param_1, LPCSTR param_2, int param_3); + int multiByteToWideCharWithSize(LPWSTR lpWideCharStr, LPCSTR lpMultiByteStr, int numberOfSymbols); - char wideCharToByteUnk(WCHAR wideChar); + char singleWideCharToMultiByte(WCHAR wideChar); - void multiByteToWideCharThunk2(char const param_1); + WCHAR singleMultiByteToWideChar(char character); }; static_assert_cpp98_obj(sizeof(WideCharMultiByteState) == 1, WideCharMultiByteState); diff --git a/src/OpenSHC/Util/WideCharMultiByteState/multiByteToWideCharWithSize.cpp b/src/OpenSHC/Util/WideCharMultiByteState/multiByteToWideCharWithSize.cpp new file mode 100644 index 00000000..316bcaa9 --- /dev/null +++ b/src/OpenSHC/Util/WideCharMultiByteState/multiByteToWideCharWithSize.cpp @@ -0,0 +1,19 @@ +#include "../WideCharMultiByteState.func.hpp" + +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace Util { + + // FUNCTION: STRONGHOLDCRUSADER 0x0046B140 + int WideCharMultiByteState::multiByteToWideCharWithSize( + LPWSTR lpWideCharStr, LPCSTR lpMultiByteStr, int numberOfSymbols) + { + int numberOfCharsWritten = MultiByteToWideChar(DAT_TextManagerObject::instance.codePage, MB_PRECOMPOSED, + lpMultiByteStr, numberOfSymbols, lpWideCharStr, numberOfSymbols); + lpWideCharStr[numberOfSymbols] = L'\0'; + return numberOfCharsWritten; + } + +} +} diff --git a/src/OpenSHC/Util/WideCharMultiByteState/multiByteToWideCharacter.cpp b/src/OpenSHC/Util/WideCharMultiByteState/multiByteToWideCharacter.cpp new file mode 100644 index 00000000..8157347a --- /dev/null +++ b/src/OpenSHC/Util/WideCharMultiByteState/multiByteToWideCharacter.cpp @@ -0,0 +1,17 @@ +#include "../WideCharMultiByteState.func.hpp" + +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace Util { + + // FUNCTION: STRONGHOLDCRUSADER 0x0046B0D0 + int WideCharMultiByteState::multiByteToWideCharacter(LPWSTR lpWideCharStr, LPCSTR lpMultiByteStr) + { + int const numberOfBytes = strlen(lpMultiByteStr) + 1; // includes null terminator + return MultiByteToWideChar(DAT_TextManagerObject::instance.codePage, MB_PRECOMPOSED, lpMultiByteStr, + numberOfBytes, lpWideCharStr, numberOfBytes); + } + +} +} diff --git a/src/OpenSHC/Util/WideCharMultiByteState/singleMultiByteToWideChar.cpp b/src/OpenSHC/Util/WideCharMultiByteState/singleMultiByteToWideChar.cpp new file mode 100644 index 00000000..de5f9911 --- /dev/null +++ b/src/OpenSHC/Util/WideCharMultiByteState/singleMultiByteToWideChar.cpp @@ -0,0 +1,16 @@ +#include "../WideCharMultiByteState.func.hpp" + +namespace OpenSHC { +namespace Util { + + // FUNCTION: STRONGHOLDCRUSADER 0x0046B1B0 + WCHAR WideCharMultiByteState::singleMultiByteToWideChar(char character) + { + WCHAR buffer[10]; + MACRO_CALL_MEMBER(OpenSHC::Util::WideCharMultiByteState_Func::multiByteToWideCharWithSize, this)( + buffer, &character, 1); + return buffer[0]; + } + +} +} diff --git a/src/OpenSHC/Util/WideCharMultiByteState/singleWideCharToMultiByte.cpp b/src/OpenSHC/Util/WideCharMultiByteState/singleWideCharToMultiByte.cpp new file mode 100644 index 00000000..d12a9b17 --- /dev/null +++ b/src/OpenSHC/Util/WideCharMultiByteState/singleWideCharToMultiByte.cpp @@ -0,0 +1,16 @@ +#include "../WideCharMultiByteState.func.hpp" + +namespace OpenSHC { +namespace Util { + + // FUNCTION: STRONGHOLDCRUSADER 0x0046B170 + char WideCharMultiByteState::singleWideCharToMultiByte(WCHAR wideChar) + { + char _byteBuffer[12]; + MACRO_CALL_MEMBER(OpenSHC::Util::WideCharMultiByteState_Func::wideCharToMultiByteWithSize, this)( + _byteBuffer, &wideChar, 1); + return _byteBuffer[0]; + } + +} +} diff --git a/src/OpenSHC/Util/WideCharMultiByteState/wideCharToMultiByteComplete.cpp b/src/OpenSHC/Util/WideCharMultiByteState/wideCharToMultiByteComplete.cpp new file mode 100644 index 00000000..591dace1 --- /dev/null +++ b/src/OpenSHC/Util/WideCharMultiByteState/wideCharToMultiByteComplete.cpp @@ -0,0 +1,17 @@ +#include "../WideCharMultiByteState.func.hpp" + +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace Util { + + // FUNCTION: STRONGHOLDCRUSADER 0x0046B080 + int WideCharMultiByteState::wideCharToMultiByteComplete(LPSTR charOut, LPCWSTR wideCharIn) + { + int numberOfWideChars = wcslen(wideCharIn) + 1; // +1 for null terminator + return WideCharToMultiByte(DAT_TextManagerObject::instance.codePage, NULL, wideCharIn, numberOfWideChars, + charOut, numberOfWideChars, NULL, NULL); + } + +} +} diff --git a/src/OpenSHC/Util/WideCharMultiByteState/wideCharToMultiByteWithSize.cpp b/src/OpenSHC/Util/WideCharMultiByteState/wideCharToMultiByteWithSize.cpp new file mode 100644 index 00000000..c5924f5d --- /dev/null +++ b/src/OpenSHC/Util/WideCharMultiByteState/wideCharToMultiByteWithSize.cpp @@ -0,0 +1,19 @@ +#include "../WideCharMultiByteState.func.hpp" + +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" + +namespace OpenSHC { +namespace Util { + + // FUNCTION: STRONGHOLDCRUSADER 0x0046B110 + int WideCharMultiByteState::wideCharToMultiByteWithSize( + LPSTR lpMultiByteStr, LPWSTR lpWideCharStr, int numOfSymbols) + { + int const _numOfBytesWritten = WideCharToMultiByte(DAT_TextManagerObject::instance.codePage, NULL, + lpWideCharStr, numOfSymbols, lpMultiByteStr, numOfSymbols, NULL, NULL); + lpMultiByteStr[numOfSymbols] = '\0'; + return _numOfBytesWritten; + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 9db18dd7..faf5175a 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -20729,17 +20729,17 @@ SHC_3BB0A8C1_0x0046AE80 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0046AEC0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0046B080 | 0.0% | Pending +SHC_3BB0A8C1_0x0046B080 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0046B0D0 | 0.0% | Pending +SHC_3BB0A8C1_0x0046B0D0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0046B110 | 0.0% | Pending +SHC_3BB0A8C1_0x0046B110 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0046B140 | 0.0% | Pending +SHC_3BB0A8C1_0x0046B140 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0046B170 | 0.0% | Pending +SHC_3BB0A8C1_0x0046B170 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0046B1B0 | 0.0% | Pending +SHC_3BB0A8C1_0x0046B1B0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0046B1F0 | 0.0% | Pending @@ -20971,7 +20971,7 @@ SHC_3BB0A8C1_0x0046CEC0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0046CED0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0046CEF0 | 0.0% | Pending +SHC_3BB0A8C1_0x0046CEF0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0046CF10 | 0.0% | Pending