diff options
author | Simon Howard | 2008-05-04 21:43:38 +0000 |
---|---|---|
committer | Simon Howard | 2008-05-04 21:43:38 +0000 |
commit | d190b596c566394717324296cbf6b46e67c64f5c (patch) | |
tree | 4dec8e4b7ae453ac11222b6da8f35f3e359d9665 | |
parent | 72680b42095864ec2d4affa55e0831e4d8712b6d (diff) | |
download | chocolate-doom-d190b596c566394717324296cbf6b46e67c64f5c.tar.gz chocolate-doom-d190b596c566394717324296cbf6b46e67c64f5c.tar.bz2 chocolate-doom-d190b596c566394717324296cbf6b46e67c64f5c.zip |
Remove Vanilla Doom reload hack.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 1140
-rw-r--r-- | src/p_setup.c | 3 | ||||
-rw-r--r-- | src/w_wad.c | 153 | ||||
-rw-r--r-- | src/w_wad.h | 6 |
3 files changed, 33 insertions, 129 deletions
diff --git a/src/p_setup.c b/src/p_setup.c index 446bba49..739a60b5 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -656,9 +656,6 @@ P_SetupLevel // UNUSED W_Profile (); P_InitThinkers (); - - // if working with a devlopment map, reload it - W_Reload (); // find map name if ( gamemode == commercial) diff --git a/src/w_wad.c b/src/w_wad.c index 0a9645a0..9425705c 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -128,37 +128,20 @@ unsigned int W_LumpNameHash(const char *s) // with multiple lumps. // Other files are single lumps with the base filename // for the lump name. -// -// If filename starts with a tilde, the file is handled -// specially to allow map reloads. -// But: the reload feature is a fragile hack... - -unsigned int reloadlump; -char* reloadname; - wad_file_t *W_AddFile (char *filename) { - wadinfo_t header; - lumpinfo_t* lump_p; - unsigned int i; - wad_file_t *wad_file; - int length; - int startlump; - filelump_t* fileinfo; - filelump_t* filerover; - wad_file_t *storehandle; + wadinfo_t header; + lumpinfo_t *lump_p; + unsigned int i; + wad_file_t *wad_file; + int length; + int startlump; + filelump_t *fileinfo; + filelump_t *filerover; // open the file and add to directory - // handle reload indicator. - if (filename[0] == '~') - { - filename++; - reloadname = filename; - reloadlump = numlumps; - } - wad_file = W_OpenFile(filename); if (wad_file == NULL) @@ -215,29 +198,29 @@ wad_file_t *W_AddFile (char *filename) } // Fill in lumpinfo - lumpinfo = realloc (lumpinfo, numlumps*sizeof(lumpinfo_t)); + lumpinfo = realloc(lumpinfo, numlumps * sizeof(lumpinfo_t)); - if (!lumpinfo) + if (lumpinfo == NULL) + { I_Error ("Couldn't realloc lumpinfo"); + } lump_p = &lumpinfo[startlump]; - storehandle = reloadname ? NULL : wad_file; - - for (i=startlump,filerover=fileinfo ; i<numlumps ; i++,lump_p++, filerover++) + filerover = fileinfo; + + for (i=startlump; i<numlumps; ++i) { - lump_p->wad_file = storehandle; + lump_p->wad_file = wad_file; lump_p->position = LONG(filerover->filepos); lump_p->size = LONG(filerover->size); lump_p->cache = NULL; strncpy(lump_p->name, filerover->name, 8); + + ++lump_p; + ++filerover; } - if (reloadname) - { - W_CloseFile(wad_file); - } - Z_Free(fileinfo); if (lumphash != NULL) @@ -251,62 +234,6 @@ wad_file_t *W_AddFile (char *filename) - -// -// W_Reload -// Flushes any of the reloadable lumps in memory -// and reloads the directory. -// -void W_Reload (void) -{ - wadinfo_t header; - int lumpcount; - lumpinfo_t* lump_p; - unsigned int i; - wad_file_t* wad_file; - int length; - filelump_t* fileinfo; - - if (reloadname == NULL) - { - return; - } - - wad_file = W_OpenFile(reloadname); - - if (wad_file == NULL) - { - I_Error ("W_Reload: couldn't open %s", reloadname); - } - - W_Read(wad_file, 0, &header, sizeof(header)); - lumpcount = LONG(header.numlumps); - header.infotableofs = LONG(header.infotableofs); - length = lumpcount*sizeof(filelump_t); - fileinfo = Z_Malloc(length, PU_STATIC, 0); - W_Read(wad_file, header.infotableofs, fileinfo, length); - - // Fill in lumpinfo - lump_p = &lumpinfo[reloadlump]; - - for (i=reloadlump; i<reloadlump+lumpcount; i++, lump_p++, fileinfo++) - { - if (lumpinfo[i].cache) - { - Z_Free (lumpinfo[i].cache); - } - - lump_p->position = LONG(fileinfo->filepos); - lump_p->size = LONG(fileinfo->size); - } - - W_CloseFile(wad_file); - - Z_Free(fileinfo); -} - - - // // W_NumLumps // @@ -378,9 +305,11 @@ int W_GetNumForName (char* name) i = W_CheckNumForName (name); - if (i == -1) - I_Error ("W_GetNumForName: %s not found!", name); - + if (i < 0) + { + I_Error ("W_GetNumForName: %s not found!", name); + } + return i; } @@ -392,7 +321,9 @@ int W_GetNumForName (char* name) int W_LumpLength (unsigned int lump) { if (lump >= numlumps) - I_Error ("W_LumpLength: %i >= numlumps",lump); + { + I_Error ("W_LumpLength: %i >= numlumps", lump); + } return lumpinfo[lump].size; } @@ -406,36 +337,19 @@ int W_LumpLength (unsigned int lump) // void W_ReadLump(unsigned int lump, void *dest) { - int c; - lumpinfo_t* l; - wad_file_t* wad_file; + int c; + lumpinfo_t *l; if (lump >= numlumps) { - I_Error ("W_ReadLump: %i >= numlumps",lump); + I_Error ("W_ReadLump: %i >= numlumps", lump); } l = lumpinfo+lump; I_BeginRead (); - if (l->wad_file == NULL) - { - // reloadable file, so use open / read / close - - wad_file = W_OpenFile(reloadname); - - if (wad_file == NULL) - { - I_Error ("W_ReadLump: couldn't open %s",reloadname); - } - } - else - { - wad_file = l->wad_file; - } - - c = W_Read(wad_file, l->position, dest, l->size); + c = W_Read(l->wad_file, l->position, dest, l->size); if (c < l->size) { @@ -443,11 +357,6 @@ void W_ReadLump(unsigned int lump, void *dest) c, l->size, lump); } - if (l->wad_file == NULL) - { - W_CloseFile(wad_file); - } - I_EndRead (); } diff --git a/src/w_wad.h b/src/w_wad.h index f28b5e37..d2626426 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -59,12 +59,10 @@ struct lumpinfo_s }; -extern void** lumpcache; -extern lumpinfo_t* lumpinfo; -extern unsigned int numlumps; +extern lumpinfo_t *lumpinfo; +extern unsigned int numlumps; wad_file_t *W_AddFile (char *filename); -void W_Reload (void); int W_CheckNumForName (char* name); int W_GetNumForName (char* name); |