Skip to content

Commit 116e795

Browse files
committed
include DFHack version in version mismatch error message
1 parent 2345bc8 commit 116e795

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

library/Core.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,7 +1493,7 @@ Core::Core() :
14931493
color_ostream::log_errors_to_stderr = true;
14941494
};
14951495

1496-
void Core::fatal (std::string output)
1496+
void Core::fatal (std::string output, const char * title)
14971497
{
14981498
errorstate = true;
14991499
std::stringstream out;
@@ -1510,7 +1510,9 @@ void Core::fatal (std::string output)
15101510
fprintf(stderr, "%s\n", out.str().c_str());
15111511
out << "Check file stderr.log for details.\n";
15121512
std::cout << "DFHack fatal error: " << out.str() << std::endl;
1513-
DFSDL::DFSDL_ShowSimpleMessageBox(0x10 /* SDL_MESSAGEBOX_ERROR */, "DFHack error!", out.str().c_str(), NULL);
1513+
if (!title)
1514+
title = "DFHack error!";
1515+
DFSDL::DFSDL_ShowSimpleMessageBox(0x10 /* SDL_MESSAGEBOX_ERROR */, title, out.str().c_str(), NULL);
15141516

15151517
bool is_headless = bool(getenv("DFHACK_HEADLESS"));
15161518
if (is_headless)
@@ -1613,15 +1615,16 @@ bool Core::InitMainThread() {
16131615
else
16141616
{
16151617
std::stringstream msg;
1616-
msg << "Not a known DF version.\n"
1618+
msg << "Not a supported DF version.\n"
16171619
"\n"
1618-
"Please make sure that you have a version\n"
1619-
"of DFHack installed that matches the version\n"
1620-
"of Dwarf Fortress.\n"
1620+
"Please make sure that you have a version of DFHack installed that\n"
1621+
"matches the version of Dwarf Fortress.\n"
1622+
"\n"
1623+
"DFHack version: " << Version::dfhack_version() << "\n"
16211624
"\n";
16221625
auto supported_versions = vif->getVersionInfosForCurOs();
16231626
if (supported_versions.size()) {
1624-
msg << "DF releases supported by this version of DFHack:\n\n";
1627+
msg << "Dwarf Fortress releases supported by this version of DFHack:\n\n";
16251628
for (auto & sv : supported_versions) {
16261629
string ver = sv->getVersion();
16271630
if (ver.starts_with("v0.")) { // translate "v0.50" to the standard format: "v50"
@@ -1631,7 +1634,7 @@ bool Core::InitMainThread() {
16311634
}
16321635
msg << "\n";
16331636
}
1634-
fatal(msg.str());
1637+
fatal(msg.str(), "DFHack version mismatch");
16351638
}
16361639
errorstate = true;
16371640
return false;

library/include/Core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ namespace DFHack
269269
void operator=(Core const&); // Don't implement
270270

271271
// report error to user while failing
272-
void fatal (std::string output);
272+
void fatal (std::string output, const char * title = NULL);
273273

274274
// 1 = fatal failure
275275
bool errorstate;

0 commit comments

Comments
 (0)