Fix crash when GL nodes file cannot be opened for writing

Report errors to console if nodes file cannot be opened or written
This commit is contained in:
alexey.lysiuk 2014-06-02 10:44:29 +03:00 committed by Christoph Oelckers
parent 9cd074ddf3
commit 3e7b0c2916
1 changed files with 15 additions and 2 deletions

View File

@ -1168,8 +1168,21 @@ static void CreateCachedNodes(MapData *map)
FString path = CreateCacheName(map, true);
FILE *f = fopen(path, "wb");
fwrite(compressed, 1, outlen+offset, f);
fclose(f);
if (f != NULL)
{
if (fwrite(compressed, outlen+offset, 1, f) != 1)
{
Printf("Error saving nodes to file %s\n", path.GetChars());
}
fclose(f);
}
else
{
Printf("Cannot open nodes file %s for writing\n", path.GetChars());
}
delete [] compressed;
}