debug builds look for scenarios in test/replays/scenarios
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
class cScenario;
|
class cScenario;
|
||||||
class cUniverse;
|
class cUniverse;
|
||||||
|
|
||||||
|
std::vector<fs::path> all_scen_dirs();
|
||||||
fs::path locate_scenario(std::string scen_name);
|
fs::path locate_scenario(std::string scen_name);
|
||||||
bool load_scenario(fs::path file_to_load, cScenario& scenario, bool only_header = false);
|
bool load_scenario(fs::path file_to_load, cScenario& scenario, bool only_header = false);
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,26 @@ static std::string get_file_error() {
|
|||||||
return sout.str();
|
return sout.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Debug builds run from working directory "build/Blades of Exile"
|
||||||
|
// should helpfully let you enter replay test scenarios.
|
||||||
|
|
||||||
|
// Support for multiple scenario directories will also help with how I plan
|
||||||
|
// to handle scenario packaging/distribution for my fork's release.
|
||||||
|
// - Nat
|
||||||
|
std::vector<fs::path> all_scen_dirs() {
|
||||||
|
std::vector<fs::path> scen_dirs = { scenDir };
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
fs::path replay_scenarios_dir = boost::filesystem::current_path();
|
||||||
|
replay_scenarios_dir = replay_scenarios_dir/".."/".."/"test"/"replays"/"scenarios";
|
||||||
|
if(fs::is_directory(replay_scenarios_dir)){
|
||||||
|
scen_dirs.push_back(replay_scenarios_dir);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return scen_dirs;
|
||||||
|
}
|
||||||
|
|
||||||
fs::path locate_scenario(std::string scen_name) {
|
fs::path locate_scenario(std::string scen_name) {
|
||||||
fs::create_directories(scenDir);
|
fs::create_directories(scenDir);
|
||||||
std::transform(scen_name.begin(), scen_name.end(), scen_name.begin(), tolower);
|
std::transform(scen_name.begin(), scen_name.end(), scen_name.begin(), tolower);
|
||||||
@@ -70,6 +90,8 @@ fs::path locate_scenario(std::string scen_name) {
|
|||||||
if(base_name == "valleydy" || base_name == "stealth" || base_name == "zakhazi"/* || base_name == "busywork" */)
|
if(base_name == "valleydy" || base_name == "stealth" || base_name == "zakhazi"/* || base_name == "busywork" */)
|
||||||
return progDir/"Blades of Exile Scenarios"/scen_name;
|
return progDir/"Blades of Exile Scenarios"/scen_name;
|
||||||
fs::path scenPath;
|
fs::path scenPath;
|
||||||
|
|
||||||
|
for(fs::path scenDir : all_scen_dirs()){
|
||||||
for(fs::recursive_directory_iterator iter(scenDir); iter != fs::recursive_directory_iterator(); iter++) {
|
for(fs::recursive_directory_iterator iter(scenDir); iter != fs::recursive_directory_iterator(); iter++) {
|
||||||
fs::file_status stat = iter->status();
|
fs::file_status stat = iter->status();
|
||||||
std::string fname = iter->path().filename().string().c_str();
|
std::string fname = iter->path().filename().string().c_str();
|
||||||
@@ -97,6 +119,10 @@ fs::path locate_scenario(std::string scen_name) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!scenPath.empty())
|
||||||
|
break;
|
||||||
|
}
|
||||||
return scenPath;
|
return scenPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -336,9 +336,9 @@ void start_data_dump() {
|
|||||||
extern fs::path scenDir;
|
extern fs::path scenDir;
|
||||||
std::vector<scen_header_type> build_scen_headers() {
|
std::vector<scen_header_type> build_scen_headers() {
|
||||||
fs::create_directories(scenDir);
|
fs::create_directories(scenDir);
|
||||||
std::cout << progDir << '\n' << scenDir << std::endl;
|
|
||||||
|
std::cout << progDir << std::endl;
|
||||||
std::vector<scen_header_type> scen_headers;
|
std::vector<scen_header_type> scen_headers;
|
||||||
fs::recursive_directory_iterator iter(scenDir);
|
|
||||||
set_cursor(watch_curs);
|
set_cursor(watch_curs);
|
||||||
|
|
||||||
if(replaying){
|
if(replaying){
|
||||||
@@ -361,6 +361,9 @@ std::vector<scen_header_type> build_scen_headers() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
for(fs::path scenDir : all_scen_dirs()){
|
||||||
|
std::cout << scenDir << std::endl;
|
||||||
|
fs::recursive_directory_iterator iter(scenDir);
|
||||||
while(iter != fs::recursive_directory_iterator()) {
|
while(iter != fs::recursive_directory_iterator()) {
|
||||||
fs::file_status stat = iter->status();
|
fs::file_status stat = iter->status();
|
||||||
if(stat.type() == fs::regular_file) {
|
if(stat.type() == fs::regular_file) {
|
||||||
@@ -370,9 +373,8 @@ std::vector<scen_header_type> build_scen_headers() {
|
|||||||
}
|
}
|
||||||
iter++;
|
iter++;
|
||||||
}
|
}
|
||||||
if(scen_headers.size() == 0) { // no scens present
|
}
|
||||||
// TODO: Should something be done here?
|
if(!scen_headers.empty()){
|
||||||
} else {
|
|
||||||
std::sort(scen_headers.begin(), scen_headers.end(), [](scen_header_type hdr_a, scen_header_type hdr_b) -> bool {
|
std::sort(scen_headers.begin(), scen_headers.end(), [](scen_header_type hdr_a, scen_header_type hdr_b) -> bool {
|
||||||
std::string a = hdr_a.name, b = hdr_b.name;
|
std::string a = hdr_a.name, b = hdr_b.name;
|
||||||
std::transform(a.begin(), a.end(), a.begin(), tolower);
|
std::transform(a.begin(), a.end(), a.begin(), tolower);
|
||||||
|
|||||||
Reference in New Issue
Block a user