diff --git a/src/scenario/scenario.cpp b/src/scenario/scenario.cpp index 2a6adc4b2..679441979 100644 --- a/src/scenario/scenario.cpp +++ b/src/scenario/scenario.cpp @@ -605,3 +605,11 @@ std::string cScenario::get_feature_flag(std::string flag) { if(iter == this->feature_flags.end()) return ""; return iter->second; } + +std::string cScenario::get_sdf_name(int col, int row) { + if(sdf_names.find(col) == sdf_names.end()) + return ""; + if(sdf_names[col].find(row) == sdf_names[col].end()) + return ""; + return sdf_names[col][row]; +} \ No newline at end of file diff --git a/src/scenario/scenario.hpp b/src/scenario/scenario.hpp index 2ce6de3bf..cdef3f24c 100644 --- a/src/scenario/scenario.hpp +++ b/src/scenario/scenario.hpp @@ -104,6 +104,8 @@ class cScenario { std::vector ic_names; std::vector itf_names; std::map> sdf_names; + std::string get_sdf_name(int col, int row); + bool adjust_diff; bool is_legacy; fs::path scen_file; // transient diff --git a/src/scenedit/scen.fileio.cpp b/src/scenedit/scen.fileio.cpp index 96a5aca4b..fe68a0bec 100644 --- a/src/scenedit/scen.fileio.cpp +++ b/src/scenedit/scen.fileio.cpp @@ -417,7 +417,7 @@ void writeScenarioToXml(ticpp::Printer&& data, cScenario& scenario) { } for(int x = 0; x < SDF_COLUMNS; x++) { for(int y = 0; y < SDF_ROWS; y++) { - if(scenario.sdf_names[x][y].empty()) continue; + if(scenario.get_sdf_name(x, y).empty()) continue; data.OpenElement("sdf"); data.PushAttribute("row", x); data.PushAttribute("col", y); diff --git a/src/scenedit/scen.sdfpicker.cpp b/src/scenedit/scen.sdfpicker.cpp index 8202df7ae..75e18f312 100644 --- a/src/scenedit/scen.sdfpicker.cpp +++ b/src/scenedit/scen.sdfpicker.cpp @@ -119,7 +119,7 @@ void cStuffDonePicker::fill_names() { location sdf = viewport; sdf.x += x; sdf.y += y; - field.setText(scenario.sdf_names[sdf.x][sdf.y]); + field.setText(scenario.get_sdf_name(sdf.x, sdf.y)); if(x == 0) { // Add row labels row_labels->getChild("row", 0, y).setTextToNum(sdf.y); @@ -139,7 +139,8 @@ void cStuffDonePicker::save_names() { location sdf = viewport; sdf.x += x; sdf.y += y; - scenario.sdf_names[sdf.x][sdf.y] = field.getText(); + if(!field.getText().empty()) + scenario.sdf_names[sdf.x][sdf.y] = field.getText(); } } }