Skip to content

Commit 061c335

Browse files
committed
allow not saving data in game::restart and game::exit, fix crashlog's restart button saving data
1 parent 023274b commit 061c335

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

loader/include/Geode/utils/general.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,10 @@ namespace geode::utils::clipboard {
181181
}
182182

183183
namespace geode::utils::game {
184-
GEODE_DLL void exit();
185-
GEODE_DLL void restart();
184+
GEODE_DLL void exit(); // TODO: left for abi compat
185+
GEODE_DLL void exit(bool saveData /* = true */);
186+
GEODE_DLL void restart(); // TODO: left for abi compat
187+
GEODE_DLL void restart(bool saveData /* = true */);
186188
GEODE_DLL void launchLoaderUninstaller(bool deleteSaveData);
187189
}
188190

loader/src/platform/windows/crashlogWindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
195195
} else if (id == ID_BUTTON_COPY_CLIPBOARD) {
196196
geode::utils::clipboard::write(g_crashlogText);
197197
} else if (id == ID_BUTTON_RESTART_GAME) {
198-
geode::utils::game::restart();
198+
geode::utils::game::restart(false);
199199
}
200200
} break;
201201

loader/src/platform/windows/util.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ std::filesystem::path dirs::getModRuntimeDir() {
201201
return dirs::getGeodeDir() / "unzipped";
202202
}
203203

204-
void geode::utils::game::exit() {
204+
void geode::utils::game::exit(bool saveData) {
205205
// TODO: mat
206206
#if 0
207207
if (CCApplication::sharedApplication() &&
@@ -212,13 +212,20 @@ void geode::utils::game::exit() {
212212
#endif
213213

214214
// If this breaks down the read, uhhh blame Cvolton or something
215-
if (AppDelegate::get()) {
216-
AppDelegate::get()->trySaveGame(true);
215+
if (saveData) {
216+
if (AppDelegate::get()) {
217+
AppDelegate::get()->trySaveGame(true);
218+
}
217219
}
220+
218221
std::exit(0);
219222
}
220223

221-
void geode::utils::game::restart() {
224+
void geode::utils::game::exit() {
225+
exit(true);
226+
}
227+
228+
void geode::utils::game::restart(bool saveData) {
222229
// TODO: mat
223230
// TODO: be VERY careful before enabling this again, this function is called in platform/windows/main.cpp,
224231
// before we even check if we are in forward compatibility mode or not.
@@ -240,7 +247,11 @@ void geode::utils::game::restart() {
240247
const auto updaterPath = (workingDir / "GeodeUpdater.exe").string();
241248
ShellExecuteA(nullptr, "open", updaterPath.c_str(), gdName.c_str(), workingDir.string().c_str(), false);
242249

243-
exit();
250+
exit(saveData);
251+
}
252+
253+
void geode::utils::game::restart() {
254+
restart(true);
244255
}
245256

246257
void geode::utils::game::launchLoaderUninstaller(bool deleteSaveData) {

0 commit comments

Comments
 (0)