From fd5263b130335747cc1135b48cd277ee3bd9b38f Mon Sep 17 00:00:00 2001 From: viciious Date: Thu, 19 Oct 2023 13:17:39 +0300 Subject: [PATCH] Cleanup --- d_main.c | 6 +++--- doomdef.h | 3 +-- g_game.c | 2 +- in_main.c | 2 +- m_main.c | 2 +- marssound.c | 2 +- p_setup.c | 3 +-- w_wad.c | 24 +++++++----------------- 8 files changed, 16 insertions(+), 28 deletions(-) diff --git a/d_main.c b/d_main.c index da76da286..c8da30e7f 100644 --- a/d_main.c +++ b/d_main.c @@ -568,7 +568,7 @@ void START_Title(void) if (*l) { W_Push(); - W_ReadPWAD(); + W_LoadPWAD(); int lump = W_CheckNumForName(l); if (lump >= 0) @@ -624,7 +624,7 @@ static void START_Credits (void) return; W_Push(); - W_ReadPWAD(); + W_LoadPWAD(); /* build a temp in-memory PWAD */ for (i = 0; i < 2; i++) @@ -868,7 +868,7 @@ static void RunAttractDemos (void) W_Push(); - W_ReadPWAD(); + W_LoadPWAD(); demo = NULL; D_snprintf(demoname, sizeof(demoname), "DEMO%1d", i+1); diff --git a/doomdef.h b/doomdef.h index f55908dd0..1881ddb5a 100644 --- a/doomdef.h +++ b/doomdef.h @@ -686,8 +686,7 @@ void W_Init (void); int W_Push (void); int W_Pop (void); -void W_OpenPWAD (wadinfo_t *wad, void *ptr); -void W_ReadPWAD(void); +void W_LoadPWAD(void); void W_SetPWAD (wadinfo_t *wad, void *lumpinfo); lumpinfo_t *W_GetLumpInfo (void); int W_GetLumpInfoSubset(lumpinfo_t *out, const lumpinfo_t *in, int numlumps, int *lumps); diff --git a/g_game.c b/g_game.c index ceeb3d201..41eb0e9dd 100644 --- a/g_game.c +++ b/g_game.c @@ -385,7 +385,7 @@ void G_Init(void) // copy mapnumbers to a temp buffer, then free, then allocate again // to avoid zone memory fragmentation W_Push(); - W_ReadPWAD(); + W_LoadPWAD(); maplist = G_LoadMaplist(&mapcount, &gameinfo); if (mapcount > 99) diff --git a/in_main.c b/in_main.c index 3962c2013..a6ad16a68 100644 --- a/in_main.c +++ b/in_main.c @@ -368,7 +368,7 @@ void IN_Start (void) Z_FreeTags (mainzone); W_Push(); - W_ReadPWAD(); + W_LoadPWAD(); /* build a temp in-memory PWAD */ lumps[0] = W_CheckNumForName("INTERPIC"); diff --git a/m_main.c b/m_main.c index c9fb82fd9..367ed4436 100644 --- a/m_main.c +++ b/m_main.c @@ -103,7 +103,7 @@ void M_Start2 (boolean startup_) if (startup) { W_Push(); - W_ReadPWAD(); + W_LoadPWAD(); i = W_CheckNumForName("M_DOOM"); m_doom = i != -1 ? W_CacheLumpNum(i, PU_STATIC) : NULL; diff --git a/marssound.c b/marssound.c index 708788432..a644d9d6f 100644 --- a/marssound.c +++ b/marssound.c @@ -150,7 +150,7 @@ void S_Init(void) S_StopSong(); W_Push(); - W_ReadPWAD(); + W_LoadPWAD(); /* build an in-memory PWAD with all music */ start = W_CheckNumForName("M_START"); diff --git a/p_setup.c b/p_setup.c index 16ea2ef38..0e2191889 100644 --- a/p_setup.c +++ b/p_setup.c @@ -655,8 +655,7 @@ D_printf ("P_SetupLevel(%s,%i)\n",lumpname,skill); P_InitThinkers (); W_Push(); - - W_ReadPWAD(); + W_LoadPWAD(); lumpnum = W_GetNumForName(lumpname); if (lumpnum < 0) diff --git a/w_wad.c b/w_wad.c index b86c6173c..52999395b 100644 --- a/w_wad.c +++ b/w_wad.c @@ -10,7 +10,7 @@ /* GLOBALS */ /*============= */ -#define MAXWADS 3 /* IWAD + CD PWAD + virtual CD PWAD */ +#define MAXWADS 2 /* IWAD + CD PWAD + virtual CD PWAD */ typedef struct { @@ -107,6 +107,8 @@ static void W_InitCDPWAD (void) I_Error ("Wad file doesn't have PWAD id\n"); wad->numlumps = LITTLELONG(((wadinfo_t*)ptr)->numlumps); wad->infotableofs = LITTLELONG(((wadinfo_t*)ptr)->infotableofs); + + W_LoadPWAD(); } /* @@ -159,11 +161,11 @@ void W_SetPWAD (wadinfo_t *wadi, void *lumpinfo) /* ==================== = -= W_ReadPWAD += W_LoadPWAD = ==================== */ -void W_ReadPWAD (void) +void W_LoadPWAD (void) { int i, l; wadfile_t *wad = &wadfile[1]; @@ -171,15 +173,14 @@ void W_ReadPWAD (void) static int cache_size = -1; static int cache_num_lumps = 0; + I_OpenCDFileByOffset(wad->cdlength, wad->cdoffset); + if (cache_size != -1) { - I_OpenCDFileByOffset(wad->cdlength, wad->cdoffset); wad->numlumps = cache_num_lumps; wad->lumpinfo = I_GetCDFileCache(cache_size); return; } - I_OpenCDFileByOffset(wad->cdlength, wad->cdoffset); - I_SeekCDFile(wad->infotableofs, SEEK_SET); l = wad->numlumps*sizeof(lumpinfo_t); @@ -210,12 +211,6 @@ int W_Push (void) { if (wadnum >= MAXWADS-1) return -1; - - if (wadnum == 1) { - wadfile_t *wad = &wadfile[1]; - I_OpenCDFileByOffset(wad->cdlength, wad->cdoffset); - } - wadnum++; return 0; } @@ -231,11 +226,6 @@ int W_Pop (void) { if (wadnum == 0) return -1; - - if (wadnum == 1) { - - } - --wadnum; return 0; }