Skip to content

Commit 7b877db

Browse files
committed
Squashed commit of the following:
commit 6b494f5 Merge: b21a00f 826b95b Author: Jasmine <[email protected]> Date: Mon Apr 21 13:40:01 2025 -0400 Merge branch 'main' of https://github.com/geode-sdk/geode into what commit b21a00f Author: Jasmine <[email protected]> Date: Sun Apr 20 07:44:44 2025 -0400 Add pause commit 9a4be39 Merge: da66c3e 023274b Author: Jasmine <[email protected]> Date: Fri Apr 18 15:43:24 2025 -0400 Merge branch 'main' of https://github.com/geode-sdk/geode into what commit da66c3e Merge: 482f200 d2e7fb6 Author: Jasmine <[email protected]> Date: Tue Apr 15 10:16:30 2025 -0400 Merge branch 'main' of https://github.com/geode-sdk/geode into what commit 482f200 Author: Jasmine <[email protected]> Date: Tue Apr 15 10:06:43 2025 -0400 Use ObjcHook instead commit 2f7874b Author: Jasmine <[email protected]> Date: Tue Apr 15 09:28:48 2025 -0400 macOS shutdown fix
1 parent 982183c commit 7b877db

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

loader/src/hooks/ShutdownFix.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <Geode/platform/cplatform.h>
2+
#ifdef GEODE_IS_MACOS
3+
#include <Geode/utils/ObjcHook.hpp>
4+
#include <objc/runtime.h>
5+
6+
using namespace geode::prelude;
7+
8+
// This fixes a crash on macOS when the game is closed,
9+
// where the game tries to call Steam API functions
10+
// after the Steam API has been shut down.
11+
12+
static void(*s_originalShutdownGame)(void* self, SEL sel);
13+
14+
void shutdownGameHook(void* self, SEL sel) {
15+
auto director = CCDirector::sharedDirector();
16+
director->pause();
17+
director->getScheduler()->unscheduleAll();
18+
s_originalShutdownGame(self, sel);
19+
}
20+
21+
$execute {
22+
if (auto original = hook::replaceObjcMethod("AppController", "shutdownGame", reinterpret_cast<void*>(&shutdownGameHook))) {
23+
s_originalShutdownGame = reinterpret_cast<decltype(s_originalShutdownGame)>(original.unwrap());
24+
}
25+
};
26+
#endif

0 commit comments

Comments
 (0)