Compare commits

..

1 Commits

Author SHA1 Message Date
DeaTh-G 460bc583a5 Respect update check timeout without the same session too 2026-02-01 19:35:54 +01:00
4 changed files with 9 additions and 30 deletions
+3
View File
@@ -1,5 +1,8 @@
#pragma once #pragma once
// 6 hour long timeout between checks.
static constexpr double g_timeBetweenUpdateChecksInSeconds = 6 * 60 * 60;
struct UpdateChecker struct UpdateChecker
{ {
enum class Result enum class Result
+3 -3
View File
@@ -307,11 +307,11 @@ int main(int argc, char *argv[])
} }
#endif #endif
// Check the time since the last time an update was checked. Store the new time if the difference is more than six hours. // Check the time since the last time an update was checked.
constexpr double TimeBetweenUpdateChecksInSeconds = 6 * 60 * 60; // Store the new time if the difference is more than g_timeBetweenUpdateChecksInSeconds hours.
time_t timeNow = std::time(nullptr); time_t timeNow = std::time(nullptr);
double timeDifferenceSeconds = difftime(timeNow, Config::LastChecked); double timeDifferenceSeconds = difftime(timeNow, Config::LastChecked);
if (timeDifferenceSeconds > TimeBetweenUpdateChecksInSeconds) if (timeDifferenceSeconds > g_timeBetweenUpdateChecksInSeconds)
{ {
UpdateChecker::initialize(); UpdateChecker::initialize();
UpdateChecker::start(); UpdateChecker::start();
@@ -129,7 +129,9 @@ PPC_FUNC(sub_822C55B0)
void PressStartSaveLoadThreadMidAsmHook() void PressStartSaveLoadThreadMidAsmHook()
{ {
if (UpdateChecker::check() == UpdateChecker::Result::UpdateAvailable) time_t timeNow = std::time(nullptr);
double timeDifferenceSeconds = difftime(timeNow, Config::LastChecked);
if (UpdateChecker::check() == UpdateChecker::Result::UpdateAvailable && timeDifferenceSeconds > g_timeBetweenUpdateChecksInSeconds)
{ {
g_updateAvailableMessageOpen = true; g_updateAvailableMessageOpen = true;
g_updateAvailableMessageOpen.wait(true); g_updateAvailableMessageOpen.wait(true);
-26
View File
@@ -193,29 +193,3 @@ PPC_FUNC(sub_824EE620)
ctx.r3.u32 = PersistentStorageManager::ShouldDisplayDLCMessage(true); ctx.r3.u32 = PersistentStorageManager::ShouldDisplayDLCMessage(true);
} }
// This is a constructor for some struct that constructed inside CTownManContext::CTownManContext()
// and within the calls contained in CTownManBase::ProcMsgSetTownManRetryTimeTable().
//
// Within the constructor of the CTownManContext, the second member of this struct is initialized to -1
// after this call happens inside CTownManContext::CTownManContext() at pretty much the very of that function call.
//
// This initialization of the member variable is however not executed when this constructor for the struct
// is called from someplace else in the game's code, as such it remains with unitialized data for that field.
//
// Ensuring that this member variable is initialized to 0 anytime this constructor is called fixes an issue with
// Tails not disappearing when giving you the camera after Rooftop Run Act 1 (Night). This setting of it to 0 won't
// break the behaviour created by the call to it from CTownManContext::CTownManContext() as that itself sets it to -1 later on.
// It only affects other instance of the call.
//
// NOTE: ctx.r3.u32 + 0 is also unitialized by this constructor, however both instances of this function being called
// initialized the said variable later on before being used.
//
// NOTE: ctx.r3.u32 + 20 is also unitialized, however I could not find any uses for this. Since this is already
// quite a big change due to the amount of NPCs in the game, I would rather not touch this unless an issue is found.
PPC_FUNC_IMPL(__imp__sub_8297C630);
PPC_FUNC(sub_8297C630)
{
PPC_STORE_U32(ctx.r3.u32 + 4, 0);
__imp__sub_8297C630(ctx, base);
}