Restrict saved version to 95.0 if signs with macros are present
This commit is contained in:
parent
c6f653ac3c
commit
4f01130ecc
@ -2457,6 +2457,20 @@ char * GameSave::serialiseOPS(unsigned int & dataLength)
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < signs.size(); i++)
|
||||
{
|
||||
if(signs[i].text.length() && signs[i].x>=0 && signs[i].x<=fullW && signs[i].y>=0 && signs[i].y<=fullH)
|
||||
{
|
||||
int x, y, w, h;
|
||||
bool v95 = false;
|
||||
signs[i].getDisplayText(nullptr, x, y, w, h, true, &v95);
|
||||
if (v95)
|
||||
{
|
||||
RESTRICTVERSION(95, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bson b;
|
||||
b.data = NULL;
|
||||
auto bson_deleter = [](bson * b) { bson_destroy(b); };
|
||||
|
@ -11,7 +11,7 @@ sign::sign(String text_, int x_, int y_, Justification justification_):
|
||||
{
|
||||
}
|
||||
|
||||
String sign::getDisplayText(Simulation *sim, int &x0, int &y0, int &w, int &h, bool colorize)
|
||||
String sign::getDisplayText(Simulation *sim, int &x0, int &y0, int &w, int &h, bool colorize, bool *v95)
|
||||
{
|
||||
String drawable_text;
|
||||
auto si = std::make_pair(0, Type::Normal);
|
||||
@ -31,7 +31,7 @@ String sign::getDisplayText(Simulation *sim, int &x0, int &y0, int &w, int &h, b
|
||||
Particle const *part = nullptr;
|
||||
float pressure = 0.0f;
|
||||
float aheat = 0.0f;
|
||||
if (x >= 0 && x < XRES && y >= 0 && y < YRES)
|
||||
if (sim && x >= 0 && x < XRES && y >= 0 && y < YRES)
|
||||
{
|
||||
if (sim->photons[y][x])
|
||||
{
|
||||
@ -58,34 +58,54 @@ String sign::getDisplayText(Simulation *sim, int &x0, int &y0, int &w, int &h, b
|
||||
if (between_curlies == "t" || between_curlies == "temp")
|
||||
{
|
||||
formatted_text << Format::Precision(Format::ShowPoint(part ? part->temp - 273.15f : 0.0f), 2);
|
||||
// * We would really only need to do this if the sign used the new
|
||||
// keyword "temp" or if the text was more than just "{t}", but 95.0
|
||||
// upgrades such signs at load time anyway.
|
||||
// * The same applies to "{p}" and "{aheat}" signs.
|
||||
if (v95)
|
||||
*v95 = true;
|
||||
}
|
||||
else if (between_curlies == "p" || between_curlies == "pres")
|
||||
{
|
||||
formatted_text << Format::Precision(Format::ShowPoint(pressure), 2);
|
||||
if (v95)
|
||||
*v95 = true;
|
||||
}
|
||||
else if (between_curlies == "a" || between_curlies == "aheat")
|
||||
{
|
||||
formatted_text << Format::Precision(Format::ShowPoint(aheat), 2);
|
||||
if (v95)
|
||||
*v95 = true;
|
||||
}
|
||||
else if (between_curlies == "type")
|
||||
{
|
||||
formatted_text << (part ? sim->BasicParticleInfo(*part) : (formatted_text.Size() ? String::Build("empty") : String::Build("Empty")));
|
||||
if (v95)
|
||||
*v95 = true;
|
||||
}
|
||||
else if (between_curlies == "ctype")
|
||||
{
|
||||
formatted_text << (part ? ((part->ctype && sim->IsValidElement(part->ctype)) ? sim->ElementResolve(part->ctype, -1) : String::Build(part->ctype)) : (formatted_text.Size() ? String::Build("empty") : String::Build("Empty")));
|
||||
if (v95)
|
||||
*v95 = true;
|
||||
}
|
||||
else if (between_curlies == "life")
|
||||
{
|
||||
formatted_text << (part ? part->life : 0);
|
||||
if (v95)
|
||||
*v95 = true;
|
||||
}
|
||||
else if (between_curlies == "tmp")
|
||||
{
|
||||
formatted_text << (part ? part->tmp : 0);
|
||||
if (v95)
|
||||
*v95 = true;
|
||||
}
|
||||
else if (between_curlies == "tmp2")
|
||||
{
|
||||
formatted_text << (part ? part->tmp2 : 0);
|
||||
if (v95)
|
||||
*v95 = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -31,7 +31,7 @@ struct sign
|
||||
String text;
|
||||
|
||||
sign(String text_, int x_, int y_, Justification justification_);
|
||||
String getDisplayText(Simulation *sim, int &x, int &y, int &w, int &h, bool colorize = true);
|
||||
String getDisplayText(Simulation *sim, int &x, int &y, int &w, int &h, bool colorize = true, bool *v95 = nullptr);
|
||||
std::pair<int, Type> split();
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user