1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-11-29 03:33:48 +00:00

preparations for gems save format update; not yet sure how to best do this so i'm leaving it at that

This commit is contained in:
fgenesis 2023-05-31 17:46:44 +02:00
parent 9047e5e083
commit 73c58b3153

View file

@ -2310,47 +2310,53 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
XMLElement *gems = doc.NewElement("Gems");
{
std::ostringstream os;
bool hasUserString = false;
os << this->gems.size() << " ";
for (Gems::iterator i = this->gems.begin(); i != this->gems.end(); i++)
// old gems format; used in 1.1.x <= 1.1.3
{
os << (*i).name << " " << (*i).pos.x << " " << (*i).pos.y << " ";
os << (*i).canMove << " ";
std::ostringstream os;
bool hasUserString = false;
os << this->gems.size() << " ";
for (Gems::iterator i = this->gems.begin(); i != this->gems.end(); i++)
{
os << (*i).name << " " << (*i).pos.x << " " << (*i).pos.y << " ";
os << (*i).canMove << " ";
hasUserString = !(*i).userString.empty();
hasUserString = !(*i).userString.empty();
os << hasUserString << " ";
os << hasUserString << " ";
if (hasUserString)
os << spacesToUnderscores((*i).userString) << " ";
if (hasUserString)
os << spacesToUnderscores((*i).userString) << " ";
}
gems->SetAttribute("c", os.str().c_str());
}
gems->SetAttribute("c", os.str().c_str());
// This is the format used in the android version. Keeping this commented out for now,
// but it should be used instead of the code above in some time -- FG
/*
os.str("");
bool hasMapName = false;
os << this->gems.size() << " ";
for (Gems::iterator i = this->gems.begin(); i != this->gems.end(); i++)
// This is the format used in the android version.
{
os << (*i).name << " ";
hasMapName = !(*i).mapName.empty();
os << hasMapName << " ";
if(hasMapName)
os << (*i).mapName << " "; // warning: this will fail to load if the map name contains whitespace
std::ostringstream os;
os << this->gems.size() << " ";
for (Gems::iterator i = this->gems.begin(); i != this->gems.end(); i++)
{
os << (*i).name << " ";
bool hasMapName = !(*i).mapName.empty();
os << hasMapName << " ";
if(hasMapName)
os << (*i).mapName << " "; // warning: this will fail to load if the map name contains whitespace
os << (*i).pos.x << " " << (*i).pos.y << " ";
os << (*i).canMove << " ";
os << (*i).pos.x << " " << (*i).pos.y << " ";
os << (*i).canMove << " ";
bool hasUserString = !(*i).userString.empty();
os << hasUserString << " ";
if (hasUserString)
os << spacesToUnderscores((*i).userString) << " ";
}
gems->SetAttribute("d", os.str().c_str());
}
// newest format; is aware if tile-relative position
{
hasUserString = !(*i).userString.empty();
os << hasUserString << " ";
if (hasUserString)
os << spacesToUnderscores((*i).userString) << " ";
}
gems->SetAttribute("d", os.str());
*/
}
doc.InsertEndChild(gems);