force update to 4.0.1 on forward compat

This commit is contained in:
Cvolton 2024-11-22 17:41:12 +01:00
parent 480b12e86c
commit 2ed18863a7
3 changed files with 31 additions and 12 deletions

View file

@ -68,14 +68,15 @@ void tryShowForwardCompat() {
LoaderImpl::get()->getGameVersion()) LoaderImpl::get()->getGameVersion())
return; return;
// TODO: change text later /*Loader::get()->queueInMainThread([]{
console::messageBox( console::messageBox(
"Forward Compatibility Warning", "Forward Compatibility Warning",
"Geode is running in a newer version of GD than Geode targets.\n" "This version of Geode is for an older version of GD.\n"
"UI is going to be disabled, platform console is forced on and crashes can be more common.\n" "Please wait a few minutes for Geode to update\n"
"However, if your game crashes, it is probably caused by an outdated mod and not Geode itself.", "and then restart the game.",
Severity::Warning Severity::Warning
); );
});*/
Mod::get()->setSavedValue<std::string>( Mod::get()->setSavedValue<std::string>(
"last-forward-compat-warn-popup-ver", "last-forward-compat-warn-popup-ver",

View file

@ -52,6 +52,11 @@ void updater::fetchLatestGithubRelease(
return then(s_latestGithubRelease.value()); 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( auto version = VersionInfo::parse(
Mod::get()->getSavedValue("latest-version-auto-update-check", std::string("0.0.0")) Mod::get()->getSavedValue("latest-version-auto-update-check", std::string("0.0.0"))
); );
@ -68,9 +73,14 @@ void updater::fetchLatestGithubRelease(
auto req = web::WebRequest(); auto req = web::WebRequest();
req.header("If-Modified-Since", modifiedSince); req.header("If-Modified-Since", modifiedSince);
req.userAgent("github_api/1.0"); req.userAgent("github_api/1.0");
//Force fetching v4.0.1 as the latest release for forward compat mode
RUNNING_REQUESTS.emplace( RUNNING_REQUESTS.emplace(
"@loaderAutoUpdateCheck", "@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) { [expect = std::move(expect), then = std::move(then)](web::WebResponse* response) {
if (response->ok()) { if (response->ok()) {
if (response->data().empty()) { if (response->data().empty()) {
@ -318,6 +328,10 @@ void updater::downloadLoaderUpdate(std::string const& url) {
if (ok) { if (ok) {
s_isNewUpdateDownloaded = true; s_isNewUpdateDownloaded = true;
LoaderUpdateEvent(UpdateFinished()).post(); LoaderUpdateEvent(UpdateFinished()).post();
if(
Loader::get()->isForwardCompatMode()
&& CCScene::get()->getChildByType<MenuLayer>(0)
) utils::game::restart();
} }
else { else {
LoaderUpdateEvent( LoaderUpdateEvent(
@ -382,8 +396,8 @@ void updater::checkForLoaderUpdates() {
return; return;
} }
// don't auto-update major versions // don't auto-update major versions when not on forward compat
if (ver.getMajor() > Loader::get()->getVersion().getMajor()) { if (!Loader::get()->isForwardCompatMode() && ver.getMajor() > Loader::get()->getVersion().getMajor()) {
return; return;
} }

View file

@ -218,5 +218,9 @@ void console::messageBox(char const* title, std::string const& info, Severity se
icon = MB_ICONERROR; icon = MB_ICONERROR;
break; 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();
} }