add DFHACK_DISABLE env var

develop
Myk Taylor 2023-05-15 18:15:46 -07:00
parent 9f997eaade
commit a62993b90b
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
2 changed files with 12 additions and 0 deletions

@ -336,6 +336,11 @@ on UNIX-like systems:
DFHACK_SOME_VAR=1 ./dfhack DFHACK_SOME_VAR=1 ./dfhack
- ``DFHACK_DISABLE``: if set, DFHack will not initialize, not even to redirect
:file:`stdout.txt` or :file:`stderr.txt`. This is provided as an alternative
to the ``--disable-dfhack`` commandline parameter above for when environment
variables are more convenient.
- ``DFHACK_PORT``: the port to use for the RPC server (used by ``dfhack-run`` - ``DFHACK_PORT``: the port to use for the RPC server (used by ``dfhack-run``
and `remotefortressreader` among others) instead of the default ``5000``. As and `remotefortressreader` among others) instead of the default ``5000``. As
with the default, if this port cannot be used, the server is not started. with the default, if this port cannot be used, the server is not started.

@ -8,6 +8,13 @@ static bool disabled = false;
// called from the main thread before the simulation thread is started // called from the main thread before the simulation thread is started
// and the main event loop is initiated // and the main event loop is initiated
DFhackCExport void dfhooks_init() { DFhackCExport void dfhooks_init() {
if (getenv("DFHACK_DISABLE")) {
fprintf(stdout, "dfhack: DFHACK_DISABLE detected in environment; disabling\n");
disabled = true;
return;
}
// we need to init DF globals before we can check the commandline
if (!DFHack::Core::getInstance().InitMainThread() || !df::global::game) if (!DFHack::Core::getInstance().InitMainThread() || !df::global::game)
return; return;
const std::string & cmdline = df::global::game->command_line.original; const std::string & cmdline = df::global::game->command_line.original;