mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-14 16:01:44 +00:00
W_LoadWadFile: Just use COM_LoadMallocFile(). Some minor cleanup.
git-svn-id: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@362 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
82c069c4d3
commit
49708d88bd
1 changed files with 6 additions and 12 deletions
18
Quake/wad.c
18
Quake/wad.c
|
@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
int wad_numlumps;
|
int wad_numlumps;
|
||||||
lumpinfo_t *wad_lumps;
|
lumpinfo_t *wad_lumps;
|
||||||
byte *wad_base = NULL; //johnfitz -- set to null
|
byte *wad_base = NULL;
|
||||||
|
|
||||||
void SwapPic (qpic_t *pic);
|
void SwapPic (qpic_t *pic);
|
||||||
|
|
||||||
|
@ -68,28 +68,22 @@ void W_LoadWadFile (void) //johnfitz -- filename is now hard-coded for honesty
|
||||||
{
|
{
|
||||||
lumpinfo_t *lump_p;
|
lumpinfo_t *lump_p;
|
||||||
wadinfo_t *header;
|
wadinfo_t *header;
|
||||||
unsigned i;
|
int i;
|
||||||
int infotableofs;
|
int infotableofs;
|
||||||
const char *filename = WADFILENAME;
|
const char *filename = WADFILENAME;
|
||||||
|
|
||||||
//johnfitz -- modified to use malloc
|
//johnfitz -- modified to use malloc
|
||||||
//TODO: use cache_alloc
|
//TODO: use cache_alloc
|
||||||
int h, len;
|
|
||||||
|
|
||||||
if (wad_base)
|
if (wad_base)
|
||||||
free (wad_base);
|
free (wad_base);
|
||||||
len = COM_OpenFile (filename, &h);
|
wad_base = COM_LoadMallocFile (filename);
|
||||||
if (h == -1)
|
if (!wad_base)
|
||||||
Sys_Error ("W_LoadWadFile: couldn't load %s", filename);
|
Sys_Error ("W_LoadWadFile: couldn't load %s", filename);
|
||||||
wad_base = (unsigned char *)malloc (len);
|
|
||||||
Sys_FileRead (h, wad_base, len);
|
|
||||||
COM_CloseFile (h);
|
|
||||||
//johnfitz
|
|
||||||
|
|
||||||
header = (wadinfo_t *)wad_base;
|
header = (wadinfo_t *)wad_base;
|
||||||
|
|
||||||
if (header->identification[0] != 'W' || header->identification[1] != 'A'
|
if (header->identification[0] != 'W' || header->identification[1] != 'A'
|
||||||
|| header->identification[2] != 'D' || header->identification[3] != '2')
|
|| header->identification[2] != 'D' || header->identification[3] != '2')
|
||||||
Sys_Error ("Wad file %s doesn't have WAD2 id\n",filename);
|
Sys_Error ("Wad file %s doesn't have WAD2 id\n",filename);
|
||||||
|
|
||||||
wad_numlumps = LittleLong(header->numlumps);
|
wad_numlumps = LittleLong(header->numlumps);
|
||||||
|
|
Loading…
Reference in a new issue