MCPcopy Create free account
hub / github.com/DFHack/dfhack / dfhooks_init

Function dfhooks_init

library/Hooks.cpp:45–66  ·  view source on GitHub ↗

called from the main thread before the simulation thread is started and the main event loop is initiated

Source from the content-addressed store, hash-verified

43// called from the main thread before the simulation thread is started
44// and the main event loop is initiated
45DFhackCExport void dfhooks_init() {
46 if (getenv("DFHACK_DISABLE")) {
47 fprintf(stderr, "dfhack: DFHACK_DISABLE detected in environment; disabling\n");
48 disabled = true;
49 return;
50 }
51
52 // we need to init DF globals before we can check the commandline
53 if (!DFHack::Core::getInstance().InitMainThread(std::filesystem::canonical(basepath)) || !df::global::game) {
54 // we don't set disabled to true here so symbol generation can work
55 return;
56 }
57
58 const std::string & cmdline = df::global::game->command_line.original;
59 if (cmdline.find("--disable-dfhack") != std::string::npos) {
60 fprintf(stderr, "dfhack: --disable-dfhack specified on commandline; disabling\n");
61 disabled = true;
62 return;
63 }
64
65 fprintf(stderr, "DFHack pre-init successful.\n");
66}
67
68// called from the main thread after the main event loops exits
69DFhackCExport void dfhooks_shutdown() {

Callers

nothing calls this directly

Calls 2

InitMainThreadMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected