Skip to content

Commit

Permalink
Merge pull request #5092 from myk002/myk_cleanup
Browse files Browse the repository at this point in the history
startup output cleanup
  • Loading branch information
myk002 authored Dec 9, 2024
2 parents 16117b3 + 9ed2926 commit 730ae37
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
8 changes: 6 additions & 2 deletions library/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1653,9 +1653,11 @@ bool Core::InitMainThread() {
// to faciliate the linux symbol discovery process (which runs without any symbols)
// or if --skip-size-check is discovered on the command line

if (df::global::global_table && df::global::game &&
df::global::game->command_line.original.find("--skip-size-check") == std::string::npos)
if (!df::global::global_table || !df::global::game ||
df::global::game->command_line.original.find("--skip-size-check") != std::string::npos)
{
std::cerr << "Skipping structure size verification check." << std::endl;
} else {
std::stringstream msg;
bool gt_error = false;
static const std::map<const std::string, const size_t> sizechecks{
Expand Down Expand Up @@ -1684,6 +1686,8 @@ bool Core::InitMainThread() {
errorstate = true;
return false;
}

std::cerr << "Structure size verification check passed." << std::endl;
}

perf_counters.reset();
Expand Down
12 changes: 9 additions & 3 deletions library/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,25 @@ DFhackCExport const int32_t dfhooks_priority = 100;
// and the main event loop is initiated
DFhackCExport void dfhooks_init() {
if (getenv("DFHACK_DISABLE")) {
fprintf(stdout, "dfhack: DFHACK_DISABLE detected in environment; disabling\n");
fprintf(stderr, "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) {
disabled = true;
return;
}

const std::string & cmdline = df::global::game->command_line.original;
if (cmdline.find("--disable-dfhack") != std::string::npos) {
fprintf(stdout, "dfhack: --disable-dfhack specified on commandline; disabling\n");
fprintf(stderr, "dfhack: --disable-dfhack specified on commandline; disabling\n");
disabled = true;
return;
}

fprintf(stderr, "DFHack pre-init successful.\n");
}

// called from the main thread after the main event loops exits
Expand Down
16 changes: 12 additions & 4 deletions library/modules/DFSDL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,24 @@ using std::vector;
static DFLibrary *g_sdl_handle = nullptr;
static DFLibrary *g_sdl_image_handle = nullptr;
static const vector<string> SDL_LIBS {
"SDL2.dll",
#ifdef WIN32
"SDL2.dll"
#elif defined(_DARWIN)
"SDL.framework/Versions/A/SDL",
"SDL.framework/SDL",
"SDL.framework/SDL"
#else
"libSDL2-2.0.so.0"
#endif
};
static const vector<string> SDL_IMAGE_LIBS {
"SDL2_image.dll",
#ifdef WIN32
"SDL2_image.dll"
#elif defined(_DARWIN)
"SDL_image.framework/Versions/A/SDL_image",
"SDL_image.framework/SDL_image",
"SDL_image.framework/SDL_image"
#else
"libSDL2_image-2.0.so.0"
#endif
};

SDL_Surface * (*g_IMG_Load)(const char *) = nullptr;
Expand Down
8 changes: 6 additions & 2 deletions library/modules/DFSteam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ static const int DFHACK_STEAM_APPID = 2346660;
static bool g_steam_initialized = false;
static DFLibrary* g_steam_handle = nullptr;
static const std::vector<std::string> STEAM_LIBS {
"steam_api64.dll",
"libsteam_api.so",
#ifdef WIN32
"steam_api64.dll"
#elif defined(_DARWIN)
"steam_api" // TODO: validate this on OSX
#else
"libsteam_api.so"
#endif
};

bool (*g_SteamAPI_Init)() = nullptr;
Expand Down

0 comments on commit 730ae37

Please sign in to comment.