Skip to content

Commit 9ed2926

Browse files
committed
add more instrumentation to hooks init
and disable DFHack if core init fails
1 parent 60db26d commit 9ed2926

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

library/Hooks.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,25 @@ DFhackCExport const int32_t dfhooks_priority = 100;
1111
// and the main event loop is initiated
1212
DFhackCExport void dfhooks_init() {
1313
if (getenv("DFHACK_DISABLE")) {
14-
fprintf(stdout, "dfhack: DFHACK_DISABLE detected in environment; disabling\n");
14+
fprintf(stderr, "dfhack: DFHACK_DISABLE detected in environment; disabling\n");
1515
disabled = true;
1616
return;
1717
}
1818

1919
// we need to init DF globals before we can check the commandline
20-
if (!DFHack::Core::getInstance().InitMainThread() || !df::global::game)
20+
if (!DFHack::Core::getInstance().InitMainThread() || !df::global::game) {
21+
disabled = true;
2122
return;
23+
}
24+
2225
const std::string & cmdline = df::global::game->command_line.original;
2326
if (cmdline.find("--disable-dfhack") != std::string::npos) {
24-
fprintf(stdout, "dfhack: --disable-dfhack specified on commandline; disabling\n");
27+
fprintf(stderr, "dfhack: --disable-dfhack specified on commandline; disabling\n");
2528
disabled = true;
29+
return;
2630
}
31+
32+
fprintf(stderr, "DFHack pre-init successful.\n");
2733
}
2834

2935
// called from the main thread after the main event loops exits

0 commit comments

Comments
 (0)