File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change
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
You can’t perform that action at this time.
0 commit comments