fix crash on failed write in writemapmodelattributes

This commit is contained in:
ac-stef
2016-07-27 12:24:58 +02:00
parent 3c2cac6121
commit 611303b890
+12 -9
View File
@@ -342,17 +342,20 @@ int mmasort2(mapmodelattributes **a, mapmodelattributes **b)
void writemapmodelattributes()
{
stream *f = openfile("config" PATHDIVS "mapmodelattributes.cfg", "w");
vector<mapmodelattributes *> mmas;
enumerate(mdlregistry, mapmodelattributes *, m, mmas.add(m));
mmas.sort(mmasort);
f->printf("// automatically written on exit. this is cached information extracted from model configs. no point in editing it.\n// [path %s]\n", conc(mdlattrnames, MMA_NUM, true)); // memory leak, but w/e
loopv(mmas)
if(f)
{
f->printf("\nmapmodelregister %s", mmas[i]->name);
loopj(MMA_NUM) f->printf(" %s", escapestring(mmas[i]->n[j])); // escapestring can handle NULL
vector<mapmodelattributes *> mmas;
enumerate(mdlregistry, mapmodelattributes *, m, mmas.add(m));
mmas.sort(mmasort);
f->printf("// automatically written on exit. this is cached information extracted from model configs. no point in editing it.\n// [path %s]\n", conc(mdlattrnames, MMA_NUM, true)); // memory leak, but w/e
loopv(mmas)
{
f->printf("\nmapmodelregister %s", mmas[i]->name);
loopj(MMA_NUM) f->printf(" %s", escapestring(mmas[i]->n[j])); // escapestring can handle NULL
}
f->printf("\n\n");
delete f;
}
f->printf("\n\n");
delete f;
}
void listallmapmodelattributes(char **args, int numargs) // create a list of mapmodel paths and selected attributes