Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/wesnoth/wesnoth
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeck88 committed Jun 13, 2014
2 parents 8531dde + 75f1345 commit b339cc2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelog
Expand Up @@ -190,6 +190,8 @@ Version 1.13.0-dev:
* Wesnoth reports an error if it evalutes [if] and finds no [then], [else], [elseif]
children, as a chat message from lua.
* Fix bug #22134: Campaign prefix not used in mp campaign saves
* Made the error messages sent to stderr when the core data dir is
incorrectly set more helpful.

Version 1.11.11:
* Add-ons server:
Expand Down
8 changes: 7 additions & 1 deletion src/font.cpp
Expand Up @@ -1258,7 +1258,13 @@ bool load_font_config()
//config when changing languages
config cfg;
try {
scoped_istream stream = preprocess_file(get_wml_location("hardwired/fonts.cfg"));
const std::string& cfg_path = get_wml_location("hardwired/fonts.cfg");
if(cfg_path.empty()) {
ERR_FT << "could not resolve path to fonts.cfg, file not found\n";
return false;
}

scoped_istream stream = preprocess_file(cfg_path);
read(cfg, *stream);
} catch(config::error &e) {
ERR_FT << "could not read fonts.cfg:\n"
Expand Down
20 changes: 20 additions & 0 deletions src/game.cpp
Expand Up @@ -419,6 +419,24 @@ static void init_locale() {
textdomain (PACKAGE);
}

/**
* Print an alert and instructions to stderr about early initialization errors.
*
* This is provided as an aid for users dealing with potential data dir
* configuration issues. The first code to read core WML *has* the
* responsibility to call this function in the event of a problem, to inform
* the user of the most likely possible cause and suggest a course of action
* to solve the issue.
*/
static void warn_early_init_failure()
{
// NOTE: wrap output to 80 columns.
std::cerr << '\n'
<< "An error at this point during initialization usually indicates that the data\n"
<< "directory above was not correctly set or detected. Try passing the correct path\n"
<< "in the command line with the --config-dir switch or as the only argument.\n";
}

/**
* Setups the game environment and enters
* the titlescreen or game loops.
Expand Down Expand Up @@ -448,6 +466,8 @@ static int do_gameloop(int argc, char** argv)
res = font::load_font_config();
if(res == false) {
std::cerr << "could not initialize fonts\n";
// The most common symptom of a bogus data dir path -- warn the user.
warn_early_init_failure();
return 1;
}

Expand Down

0 comments on commit b339cc2

Please sign in to comment.