- Fix uninitialized data in scenario details (especially rating)
- Fix case-sensitive comparison for scenario file extensions
This commit is contained in:
2015-06-20 13:07:12 -04:00
parent d0bfd64550
commit d3e6af6cc9
2 changed files with 7 additions and 2 deletions

View File

@@ -498,7 +498,9 @@ bool load_scenario_header(fs::path file/*,short header_entry*/){
int dot = fname.find_first_of('.');
if(dot == std::string::npos)
return false; // If it has no file extension, it's not a valid scenario.
if(fname.substr(dot) == ".exs") {
std::string file_ext = fname.substr(dot);
std::transform(file_ext.begin(), file_ext.end(), file_ext.begin(), tolower);
if(file_ext == ".exs") {
std::ifstream fin(file.string(), std::ios::binary);
if(fin.fail()) return false;
scenario_header_flags curScen;
@@ -510,7 +512,7 @@ bool load_scenario_header(fs::path file/*,short header_entry*/){
file_ok = true; // Legacy Windows scenario
else if(curScen.flag1 == 'O' && curScen.flag2 == 'B' && curScen.flag3 == 'O' && curScen.flag4 == 'E')
file_ok = true; // Unpacked OBoE scenario
} else if(fname.substr(dot) == ".boes") {
} else if(file_ext == ".boes") {
if(fs::is_directory(file)) {
if(fs::exists(file/"header.exs"))
return load_scenario_header(file/"header.exs");

View File

@@ -61,6 +61,9 @@ cScenario::cScenario() {
where_start.x = 24;
where_start.y = 24;
out_start = where_start;
rating = 0;
difficulty = 0;
intro_pic = intro_mess_pic = 0;
bg_out = 10;
bg_fight = 4;
bg_town = 13;