From 2ed18863a765f44667d15443d146f32261f74d35 Mon Sep 17 00:00:00 2001 From: Cvolton Date: Fri, 22 Nov 2024 17:41:12 +0100 Subject: [PATCH] force update to 4.0.1 on forward compat --- loader/src/load.cpp | 17 +++++++++-------- loader/src/loader/updater.cpp | 20 +++++++++++++++++--- loader/src/platform/windows/console.cpp | 6 +++++- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/loader/src/load.cpp b/loader/src/load.cpp index 11ca5216..7af7c329 100644 --- a/loader/src/load.cpp +++ b/loader/src/load.cpp @@ -68,14 +68,15 @@ void tryShowForwardCompat() { LoaderImpl::get()->getGameVersion()) return; - // TODO: change text later - console::messageBox( - "Forward Compatibility Warning", - "Geode is running in a newer version of GD than Geode targets.\n" - "UI is going to be disabled, platform console is forced on and crashes can be more common.\n" - "However, if your game crashes, it is probably caused by an outdated mod and not Geode itself.", - Severity::Warning - ); + /*Loader::get()->queueInMainThread([]{ + console::messageBox( + "Forward Compatibility Warning", + "This version of Geode is for an older version of GD.\n" + "Please wait a few minutes for Geode to update\n" + "and then restart the game.", + Severity::Warning + ); + });*/ Mod::get()->setSavedValue( "last-forward-compat-warn-popup-ver", diff --git a/loader/src/loader/updater.cpp b/loader/src/loader/updater.cpp index 1f040cd3..fac88294 100644 --- a/loader/src/loader/updater.cpp +++ b/loader/src/loader/updater.cpp @@ -52,6 +52,11 @@ void updater::fetchLatestGithubRelease( return then(s_latestGithubRelease.value()); } + //quick hack to make sure it always attempts an update check in forward compat + if(Loader::get()->isForwardCompatMode()) { + force = true; + } + auto version = VersionInfo::parse( Mod::get()->getSavedValue("latest-version-auto-update-check", std::string("0.0.0")) ); @@ -68,9 +73,14 @@ void updater::fetchLatestGithubRelease( auto req = web::WebRequest(); req.header("If-Modified-Since", modifiedSince); req.userAgent("github_api/1.0"); + //Force fetching v4.0.1 as the latest release for forward compat mode RUNNING_REQUESTS.emplace( "@loaderAutoUpdateCheck", - req.get("https://api.github.com/repos/geode-sdk/geode/releases/latest").map( + req.get( + Loader::get()->isForwardCompatMode() + ? "https://api.github.com/repos/geode-sdk/geode/releases/tags/v4.0.1" + : "https://api.github.com/repos/geode-sdk/geode/releases/latest" + ).map( [expect = std::move(expect), then = std::move(then)](web::WebResponse* response) { if (response->ok()) { if (response->data().empty()) { @@ -318,6 +328,10 @@ void updater::downloadLoaderUpdate(std::string const& url) { if (ok) { s_isNewUpdateDownloaded = true; LoaderUpdateEvent(UpdateFinished()).post(); + if( + Loader::get()->isForwardCompatMode() + && CCScene::get()->getChildByType(0) + ) utils::game::restart(); } else { LoaderUpdateEvent( @@ -382,8 +396,8 @@ void updater::checkForLoaderUpdates() { return; } - // don't auto-update major versions - if (ver.getMajor() > Loader::get()->getVersion().getMajor()) { + // don't auto-update major versions when not on forward compat + if (!Loader::get()->isForwardCompatMode() && ver.getMajor() > Loader::get()->getVersion().getMajor()) { return; } diff --git a/loader/src/platform/windows/console.cpp b/loader/src/platform/windows/console.cpp index 59b76e3a..7fd94501 100644 --- a/loader/src/platform/windows/console.cpp +++ b/loader/src/platform/windows/console.cpp @@ -218,5 +218,9 @@ void console::messageBox(char const* title, std::string const& info, Severity se icon = MB_ICONERROR; break; } - MessageBoxA(nullptr, info.c_str(), title, icon); + + //run in another thread so auto update can run in the background + std::thread([info, title, icon]{ + MessageBoxA(nullptr, info.c_str(), title, icon | MB_SETFOREGROUND); + }).detach(); }