mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-27 17:26:23 +00:00
Consider <exe loc or cwd>/../ as a candidate for data dir autodetection
Makes it so <exe location>/../ (non-Windows) or <current working dir>/../ (Windows) are also considered possible data directories if they contain a data/_main.cfg file. This is mostly intended to help people running cmake builds so they don't have to type out .. in the Wesnoth command line every time or use a hard link sitting on the data dir. Notice that scons people already benefited from the simpler version of this autodetection, which only considered <exe loc or cwd>/./ as a candidate. This has been the case since version 1.5.4 (more specifically, commit 43431bc3a79d8be4fef2c102167e5982a74aa71a). Because of this, most of the code for this feature was already in place and I only rearranged it to add some helpful annotations.
This commit is contained in:
parent
ffbf683eb0
commit
ad58361e6e
@ -227,6 +227,9 @@ Version 1.13.0-dev:
|
||||
* Fix an inefficient implementation of unit::invisible, in an effort to address slow performance problems:
|
||||
http://forums.wesnoth.org/viewtopic.php?f=4&t=12139&start=180#p569931
|
||||
(Also see gfgtdf's commits trying to optimize the minimap loop)
|
||||
* Made it so <exe location>/../ (non-Windows) or <current working dir>/../
|
||||
(Windows) are also considered possible data directories if they contain a
|
||||
data/_main.cfg file, intended to help with cmake builds.
|
||||
|
||||
Version 1.11.11:
|
||||
* Add-ons server:
|
||||
|
@ -791,11 +791,28 @@ int main(int argc, char** argv)
|
||||
const time_t t = time(NULL);
|
||||
std::cerr << "Started on " << ctime(&t) << "\n";
|
||||
|
||||
const std::string exe_dir = get_exe_dir();
|
||||
if(!exe_dir.empty() && file_exists(exe_dir + "/data/_main.cfg")) {
|
||||
std::cerr << "Automatically found a possible data directory at "
|
||||
<< exe_dir << '\n';
|
||||
game_config::path = exe_dir;
|
||||
const std::string& exe_dir = get_exe_dir();
|
||||
if(!exe_dir.empty()) {
|
||||
// Try to autodetect the location of the game data dir. Note that
|
||||
// the root of the source tree currently doubles as the data dir.
|
||||
std::string auto_dir;
|
||||
|
||||
// scons leaves the resulting binaries at the root of the source
|
||||
// tree by default.
|
||||
if(file_exists(exe_dir + "/data/_main.cfg")) {
|
||||
auto_dir = exe_dir;
|
||||
}
|
||||
// cmake encourages creating a subdir at the root of the source
|
||||
// tree for the build, and the resulting binaries are found in it.
|
||||
else if(file_exists(exe_dir + "/../data/_main.cfg")) {
|
||||
auto_dir = normalize_path(exe_dir + "/..");
|
||||
}
|
||||
|
||||
if(!auto_dir.empty()) {
|
||||
std::cerr << "Automatically found a possible data directory at "
|
||||
<< auto_dir << '\n';
|
||||
game_config::path = auto_dir;
|
||||
}
|
||||
}
|
||||
|
||||
const int res = do_gameloop(argc,argv);
|
||||
|
Loading…
x
Reference in New Issue
Block a user