Exit if data dir is not specified nor found automatically

Fixes #6883.
This commit is contained in:
tofilwiktor 2023-06-13 19:21:20 +02:00 committed by GitHub
parent 639fb7158e
commit 5cd12df0af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -89,6 +89,7 @@
#include <boost/iostreams/filtering_stream.hpp> // for filtering_stream
#include <boost/program_options/errors.hpp> // for error
#include <boost/algorithm/string/predicate.hpp> // for checking cmdline options
#include <optional>
#include <algorithm> // for transform
@ -1157,6 +1158,18 @@ int main(int argc, char** argv)
PLAIN_LOG << "Automatically found a possible data directory at: " << auto_dir;
}
game_config::path = std::move(auto_dir);
} else if(game_config::path.empty()) {
bool data_dir_specified = false;
for(int i=0;i<argc;i++) {
if(std::string(argv[i]) == "--data-dir" || boost::algorithm::starts_with(argv[i], "--data-dir=")) {
data_dir_specified = true;
break;
}
}
if (!data_dir_specified) {
PLAIN_LOG << "Cannot find a data directory. Specify one with --data-dir";
return 1;
}
}
}