Something wrong with folowing code (besch/writer/vehicle_writer.cc)
uint8 upgrades = 0;
do {
char buf[40];
sprintf(buf, "upgrade[%d]", upgrades);
str = obj.get(buf);
found = str.size() > 0;
if (found)
{
if (upgrades == 0 && !STRICMP(str.c_str(), "none"))
{
if (!STRICMP(str.c_str(), "none"))
{
str = "";
}
xref_writer_t::instance()->write_obj(fp, node, obj_vehicle, str.c_str(), false);
upgrades++;
}
}
} while (found);
!STRICMP(str.c_str(), "none") == false for first iteration so upgrades never incremented and we have infinite loop.
Thank you for pointing this out. Would this be an appropriate fix, do you think?
// Upgrades: these are the vehicle types to which this vehicle
// can be upgraded. "None" means that it cannot be upgraded.
// @author: jamespetts
uint8 upgrades = 0;
do {
char buf[40];
sprintf(buf, "upgrade[%d]", upgrades);
str = obj.get(buf);
found = str.size() > 0;
if (found)
{
if (upgrades == 0 && !STRICMP(str.c_str(), "none"))
{
if (!STRICMP(str.c_str(), "none"))
{
str = "";
}
xref_writer_t::instance()->write_obj(fp, node, obj_vehicle, str.c_str(), false);
}
upgrades++;
}
} while (found);
It is merge error, i think.
I don't really understand why we need check for upgrades == 0 and why !STRICMP(str.c_str(), "none") checked twice.
just
uint8 upgrades = 0;
do {
char buf[40];
sprintf(buf, "upgrade[%d]", upgrades);
str = obj.get(buf);
found = str.size() > 0;
if (found)
{
if (!STRICMP(str.c_str(), "none"))
{
str = "";
}
else
{
xref_writer_t::instance()->write_obj(fp, node, obj_vehicle, str.c_str(), false);
upgrades++;
}
}
} while (found);
will be fine?
That looks very different - I must confess, I can't remember precisely how the code was intended now (and, yes, I think that you're right that it was a merge error). Have you tested your version?
Yes. No problem so far.
Lovely - thank you very much!