Fix saving of effects

master
per 2013-10-20 12:57:10 +02:00
parent 76edcb87fd
commit de42fd3547
3 changed files with 22 additions and 2 deletions

View File

@ -47,6 +47,11 @@
//*************************************************************************
void modelShutdown();
/// Get filename of model pointer. This is really slow, so do not abuse for logging
/// purposes, for example.
const QString &modelName(iIMDShape *model);
iIMDShape *modelGet(const QString &filename);
#endif

View File

@ -110,6 +110,7 @@ void modelShutdown()
{
iV_IMDRelease(i.value());
}
models.clear();
}
static bool tryLoad(const QString &path, const QString &filename)
@ -134,6 +135,20 @@ static bool tryLoad(const QString &path, const QString &filename)
return false;
}
const QString &modelName(iIMDShape *model)
{
for (MODELMAP::iterator i = models.begin(); i != models.end(); i = models.erase(i))
{
if (i.value() == model)
{
return i.key();
}
}
ASSERT(false, "An IMD pointer could not be backtraced to a filename!");
static QString error;
return error;
}
iIMDShape *modelGet(const QString &filename)
{
QString name(filename.toLower());

View File

@ -2537,8 +2537,8 @@ bool writeFXData(const char *fileName)
ini.setValue("lifeSpan", it->lifeSpan);
ini.setValue("radius", it->radius);
const char *imd_name = resGetNamefromData("IMD", it->imd);
if (imd_name && *imd_name)
const QString &imd_name = modelName(it->imd);
if (!imd_name.isEmpty())
{
ini.setValue("imd_name", imd_name);
}