gl_texmgr.c (TexMgr_ReloadImage): reduced the hunk memory usage during

reloading of images from the bsp by not loading the whole file but by
opening the file, fseek()ing and allocating only the necessary amount.
This way, I can load and reload a save of ne_ruins with just the default
64 Mb of memory on x86 and with only 68.5 Mb of memory (-heapsize 70000)
on x86_64.

git-svn-id: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@633 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
sezero 2012-02-11 14:30:19 +00:00
parent f3efdba768
commit 69a35ba645

View file

@ -1235,10 +1235,21 @@ void TexMgr_ReloadImage (gltexture_t *glt, int shirt, int pants)
if (glt->source_file[0] && glt->source_offset) if (glt->source_file[0] && glt->source_offset)
{ {
//lump inside file //lump inside file
data = COM_LoadHunkFile (glt->source_file, NULL); long size;
if (!data) FILE *f;
COM_FOpenFile(glt->source_file, &f, NULL);
if (!f)
goto invalid; goto invalid;
data += glt->source_offset; fseek (f, glt->source_offset, SEEK_CUR);
size = (long) (glt->source_width * glt->source_height);
/* should be SRC_INDEXED, but no harm being paranoid: */
if (glt->source_format == SRC_RGBA)
size *= 4;
else if (glt->source_format == SRC_LIGHTMAP)
size *= lightmap_bytes;
data = Hunk_Alloc (size);
fread (data, 1, size, f);
fclose (f);
} }
else if (glt->source_file[0] && !glt->source_offset) else if (glt->source_file[0] && !glt->source_offset)
data = Image_LoadImage (glt->source_file, (int *)&glt->source_width, (int *)&glt->source_height); //simple file data = Image_LoadImage (glt->source_file, (int *)&glt->source_width, (int *)&glt->source_height); //simple file