Bugfixes
- Fix uninitialized data in scenario details (especially rating) - Fix case-sensitive comparison for scenario file extensions
This commit is contained in:
@@ -498,7 +498,9 @@ bool load_scenario_header(fs::path file/*,short header_entry*/){
|
|||||||
int dot = fname.find_first_of('.');
|
int dot = fname.find_first_of('.');
|
||||||
if(dot == std::string::npos)
|
if(dot == std::string::npos)
|
||||||
return false; // If it has no file extension, it's not a valid scenario.
|
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);
|
std::ifstream fin(file.string(), std::ios::binary);
|
||||||
if(fin.fail()) return false;
|
if(fin.fail()) return false;
|
||||||
scenario_header_flags curScen;
|
scenario_header_flags curScen;
|
||||||
@@ -510,7 +512,7 @@ bool load_scenario_header(fs::path file/*,short header_entry*/){
|
|||||||
file_ok = true; // Legacy Windows scenario
|
file_ok = true; // Legacy Windows scenario
|
||||||
else if(curScen.flag1 == 'O' && curScen.flag2 == 'B' && curScen.flag3 == 'O' && curScen.flag4 == 'E')
|
else if(curScen.flag1 == 'O' && curScen.flag2 == 'B' && curScen.flag3 == 'O' && curScen.flag4 == 'E')
|
||||||
file_ok = true; // Unpacked OBoE scenario
|
file_ok = true; // Unpacked OBoE scenario
|
||||||
} else if(fname.substr(dot) == ".boes") {
|
} else if(file_ext == ".boes") {
|
||||||
if(fs::is_directory(file)) {
|
if(fs::is_directory(file)) {
|
||||||
if(fs::exists(file/"header.exs"))
|
if(fs::exists(file/"header.exs"))
|
||||||
return load_scenario_header(file/"header.exs");
|
return load_scenario_header(file/"header.exs");
|
||||||
|
|||||||
@@ -61,6 +61,9 @@ cScenario::cScenario() {
|
|||||||
where_start.x = 24;
|
where_start.x = 24;
|
||||||
where_start.y = 24;
|
where_start.y = 24;
|
||||||
out_start = where_start;
|
out_start = where_start;
|
||||||
|
rating = 0;
|
||||||
|
difficulty = 0;
|
||||||
|
intro_pic = intro_mess_pic = 0;
|
||||||
bg_out = 10;
|
bg_out = 10;
|
||||||
bg_fight = 4;
|
bg_fight = 4;
|
||||||
bg_town = 13;
|
bg_town = 13;
|
||||||
|
|||||||
Reference in New Issue
Block a user