Fix some bugs in loading and saving new-format scenarios

This commit is contained in:
2015-06-01 17:23:15 -04:00
parent 5606f3e91e
commit 72add651a5
3 changed files with 4 additions and 1 deletions

View File

@@ -371,7 +371,7 @@ static void writeTerrainToXml(ticpp::Printer&& data) {
data.CloseElement("special");
data.OpenElement("editor");
if(ter.shortcut_key > 0)
if(ter.shortcut_key > 0 && ter.shortcut_key < '\x7f')
data.PushElement("shortcut", ter.shortcut_key);
if(ter.obj_num > 0) {
data.OpenElement("object");

View File

@@ -860,6 +860,7 @@ static void readTerrainFromXml(ticpp::Document&& data, cScenario& scenario) {
else if(num_flags == 2)
spec->GetText(&the_ter.flag3);
else throw xBadNode(type, spec->Row(), spec->Column(), fname);
num_flags++;
} else throw xBadNode(type, spec->Row(), spec->Column(), fname);
}
} else if(type == "transform") {
@@ -1730,6 +1731,7 @@ static void readSpecialNodesFromStream(std::istream& stream, std::vector<cSpecia
stream.seekg(0, std::ios::beg);
contents.assign(std::istreambuf_iterator<char>(stream), std::istreambuf_iterator<char>());
auto loaded = SpecialParser().parse(contents);
if(loaded.size() == 0) return; // If there were no nodes, we're already done here.
nodes.resize(loaded.rbegin()->first + 1);
for(auto p : loaded)
nodes[p.first] = p.second;

View File

@@ -64,6 +64,7 @@ void tarball::writeTo(std::ostream& out) {
entry.contents.seekg(0);
entry.header = generateTarHeader(entry.filename, size);
out.write((char*)&entry.header, sizeof(header_posix_ustar));
if(size == 0) continue;
out << entry.contents.rdbuf();
if(padLength < 512)
out.write(padding, padLength);