Correctly handle saving a scenario that was loaded in unpacked form

This commit is contained in:
2015-02-14 13:35:26 -05:00
parent 0aaa299642
commit 7ba874f1d2
3 changed files with 17 additions and 0 deletions

View File

@@ -977,6 +977,19 @@ void save_scenario(fs::path toFile) {
writeDialogueToXml(ticpp::Printer("talk.xml", town_talk), scenario.towns[i]->talking, i);
}
// Alright. At this point, check to see if the scenario was unpacked.
if(fs::is_directory(toFile)) {
// If it was, we just need to save each file to its respective location
// There's no need to worry about custom graphics or sounds, either.
// And if it's unpacked, it can't possibly be legacy, so graphics don't need conversion.
for(auto& file : scen_file) {
std::string fname = file.filename.substr(9);
std::ofstream fout((toFile/fname).string());
fout << file.contents.rdbuf();
}
return;
}
// Now, custom graphics.
if(spec_scen_g.is_old) {
spec_scen_g.convert_sheets();
@@ -1055,6 +1068,7 @@ void save_scenario(fs::path toFile) {
fname.replace(dot,4,".boes");
else fname += ".boes";
}
scenario.scen_file = fname;
toFile = toFile.parent_path()/fname;
// Now write to zip file.

View File

@@ -1762,6 +1762,7 @@ bool load_scenario_v2(fs::path file_to_load, cScenario& scenario) {
#pragma clang diagnostic pop
#endif
};
scenario.scen_file = file_to_load;
// From here on, we don't have to care about whether it's packed or unpacked.
TiXmlBase::SetCondenseWhiteSpace(true); // Make sure this is enabled, because the dialog engine disables it
{

View File

@@ -53,6 +53,8 @@ public:
void newDirectory(std::string dname);
std::istream& getFile(std::string fname);
bool hasFile(std::string fname);
std::deque<tarfile>::iterator begin() {return files.begin();}
std::deque<tarfile>::iterator end() {return files.end();}
};