Fix some bugs in loading and saving new-format scenarios
This commit is contained in:
@@ -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");
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user