ref: 968c30b02484585d03ed757b317a39b2f6a15556
parent: 9dbacdc2ec9b4d496173cdf34d23caa182625cf0
author: Simon Howard <[email protected]>
date: Sat Oct 8 14:22:46 EDT 2005
Store the cache as part of the lumpinfo_t struct. Add W_AddFile prototype to header. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 167
--- a/src/w_wad.c
+++ b/src/w_wad.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: w_wad.c 58 2005-08-30 22:15:11Z fraggle $
+// $Id: w_wad.c 167 2005-10-08 18:22:46Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -22,6 +22,10 @@
// 02111-1307, USA.
//
// $Log$
+// Revision 1.8 2005/10/08 18:22:46 fraggle
+// Store the cache as part of the lumpinfo_t struct. Add W_AddFile prototype
+// to header.
+//
// Revision 1.7 2005/08/30 22:15:11 fraggle
// More Windows fixes
//
@@ -51,7 +55,7 @@
static const char
-rcsid[] = "$Id: w_wad.c 58 2005-08-30 22:15:11Z fraggle $";
+rcsid[] = "$Id: w_wad.c 167 2005-10-08 18:22:46Z fraggle $";
#include <ctype.h>
@@ -80,9 +84,6 @@
lumpinfo_t* lumpinfo;
int numlumps;
-void** lumpcache;
-
-
#define strcmpi strcasecmp
void string_to_upper (char* s)
@@ -244,6 +245,7 @@
lump_p->handle = storehandle;
lump_p->position = LONG(filerover->filepos);
lump_p->size = LONG(filerover->size);
+ lump_p->cache = NULL;
strncpy (lump_p->name, filerover->name, 8);
}
@@ -292,8 +294,8 @@
i<reloadlump+lumpcount ;
i++,lump_p++, fileinfo++)
{
- if (lumpcache[i])
- Z_Free (lumpcache[i]);
+ if (lumpinfo[i].cache)
+ Z_Free (lumpinfo[i].cache);
lump_p->position = LONG(fileinfo->filepos);
lump_p->size = LONG(fileinfo->size);
@@ -334,15 +336,6 @@
if (!numlumps)
I_Error ("W_InitFiles: no files found");
-
- // set up caching
- size = numlumps * sizeof(*lumpcache);
- lumpcache = malloc (size);
-
- if (!lumpcache)
- I_Error ("Couldn't allocate lumpcache");
-
- memset (lumpcache,0, size);
}
@@ -512,21 +505,21 @@
if ((unsigned)lump >= numlumps)
I_Error ("W_CacheLumpNum: %i >= numlumps",lump);
- if (!lumpcache[lump])
+ if (!lumpinfo[lump].cache)
{
// read the lump in
//printf ("cache miss on lump %i\n",lump);
- ptr = Z_Malloc (W_LumpLength (lump), tag, &lumpcache[lump]);
- W_ReadLump (lump, lumpcache[lump]);
+ ptr = Z_Malloc (W_LumpLength (lump), tag, &lumpinfo[lump].cache);
+ W_ReadLump (lump, lumpinfo[lump].cache);
}
else
{
//printf ("cache hit on lump %i\n",lump);
- Z_ChangeTag (lumpcache[lump],tag);
+ Z_ChangeTag (lumpinfo[lump].cache,tag);
}
- return lumpcache[lump];
+ return lumpinfo[lump].cache;
}
@@ -562,7 +555,7 @@
for (i=0 ; i<numlumps ; i++)
{
- ptr = lumpcache[i];
+ ptr = lumpinfo[i].cache;
if (!ptr)
{
ch = ' ';
--- a/src/w_wad.h
+++ b/src/w_wad.h
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: w_wad.h 16 2005-07-23 18:54:06Z fraggle $
+// $Id: w_wad.h 167 2005-10-08 18:22:46Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -64,6 +64,7 @@
FILE *handle;
int position;
int size;
+ void *cache;
} lumpinfo_t;
@@ -71,6 +72,7 @@
extern lumpinfo_t* lumpinfo;
extern int numlumps;
+void W_AddFile (char *filename);
void W_InitMultipleFiles (char** filenames);
void W_Reload (void);
@@ -90,6 +92,10 @@
//-----------------------------------------------------------------------------
//
// $Log$
+// Revision 1.4 2005/10/08 18:22:46 fraggle
+// Store the cache as part of the lumpinfo_t struct. Add W_AddFile prototype
+// to header.
+//
// Revision 1.3 2005/07/23 18:54:06 fraggle
// Use standard C functions for WAD code
//