From 717ca7f67c77b09c9fc6f36936fbc6bdc4ff8e98 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 26 Sep 2008 16:25:24 +0000 Subject: Fix up Heretic code for mmaped WAD I/O. Call W_ReleaseLump* instead of Z_Free/Z_ChangeTag. Subversion-branch: /branches/raven-branch Subversion-revision: 1288 --- src/heretic/g_game.c | 2 +- src/heretic/in_lude.c | 79 ++++++++++++++++++++++++++++++++------------------- src/heretic/p_setup.c | 16 +++++------ src/heretic/r_data.c | 8 ++++-- src/heretic/r_plane.c | 8 ++++-- 5 files changed, 69 insertions(+), 44 deletions(-) (limited to 'src/heretic') diff --git a/src/heretic/g_game.c b/src/heretic/g_game.c index 3a27a63e..70c19761 100644 --- a/src/heretic/g_game.c +++ b/src/heretic/g_game.c @@ -1797,7 +1797,7 @@ boolean G_CheckDemoStatus(void) if (singledemo) I_Quit(); - Z_ChangeTag(demobuffer, PU_CACHE); + W_ReleaseLumpName(defdemoname); demoplayback = false; D_AdvanceDemo(); return true; diff --git a/src/heretic/in_lude.c b/src/heretic/in_lude.c index 38c84631..3eb40e9c 100644 --- a/src/heretic/in_lude.c +++ b/src/heretic/in_lude.c @@ -299,44 +299,67 @@ void IN_InitStats(void) } } -//======================================================================== -// -// IN_LoadPics -// -//======================================================================== - -void IN_LoadPics(void) +static void IN_LoadUnloadPics(void (*callback)(char *lumpname, + int lumpnum, + patch_t **ptr)) { int i; switch (gameepisode) { case 1: - patchINTERPIC = W_CacheLumpName("MAPE1", PU_STATIC); + callback("MAPE1", 0, &patchINTERPIC); break; case 2: - patchINTERPIC = W_CacheLumpName("MAPE2", PU_STATIC); + callback("MAPE2", 0, &patchINTERPIC); break; case 3: - patchINTERPIC = W_CacheLumpName("MAPE3", PU_STATIC); + callback("MAPE3", 0, &patchINTERPIC); break; default: break; } - patchBEENTHERE = W_CacheLumpName("IN_X", PU_STATIC); - patchGOINGTHERE = W_CacheLumpName("IN_YAH", PU_STATIC); + + callback("IN_X", 0, &patchBEENTHERE); + callback("IN_YAH", 0, &patchGOINGTHERE); + callback("FONTB13", 0, &FontBNegative); + + callback("FONTB15", 0, &FontBSlash); + callback("FONTB05", 0, &FontBPercent); + FontBLumpBase = W_GetNumForName("FONTB16"); + for (i = 0; i < 10; i++) { - FontBNumbers[i] = W_CacheLumpNum(FontBLumpBase + i, PU_STATIC); + callback(NULL, FontBLumpBase + i, &FontBNumbers[i]); } - FontBLump = W_GetNumForName("FONTB_S") + 1; - FontBNegative = W_CacheLumpName("FONTB13", PU_STATIC); +} + +//======================================================================== +// +// IN_LoadPics +// +//======================================================================== - FontBSlash = W_CacheLumpName("FONTB15", PU_STATIC); - FontBPercent = W_CacheLumpName("FONTB05", PU_STATIC); +static void LoadLumpCallback(char *lumpname, int lumpnum, patch_t **ptr) +{ + if (lumpname == NULL) + { + lumpnum = W_GetNumForName(lumpname); + } + + // Cache the lump + + *ptr = W_CacheLumpNum(lumpnum, PU_STATIC); +} + +void IN_LoadPics(void) +{ + FontBLump = W_GetNumForName("FONTB_S") + 1; patchFaceOkayBase = W_GetNumForName("FACEA0"); patchFaceDeadBase = W_GetNumForName("FACEB0"); + + IN_LoadUnloadPics(LoadLumpCallback); } //======================================================================== @@ -345,23 +368,21 @@ void IN_LoadPics(void) // //======================================================================== -void IN_UnloadPics(void) +static void UnloadLumpCallback(char *lumpname, int lumpnum, patch_t **ptr) { - int i; - - if (patchINTERPIC) + if (lumpname != NULL) { - Z_ChangeTag(patchINTERPIC, PU_CACHE); + W_ReleaseLumpName(lumpname); } - Z_ChangeTag(patchBEENTHERE, PU_CACHE); - Z_ChangeTag(patchGOINGTHERE, PU_CACHE); - for (i = 0; i < 10; i++) + else { - Z_ChangeTag(FontBNumbers[i], PU_CACHE); + W_ReleaseLumpNum(lumpnum); } - Z_ChangeTag(FontBNegative, PU_CACHE); - Z_ChangeTag(FontBSlash, PU_CACHE); - Z_ChangeTag(FontBPercent, PU_CACHE); +} + +void IN_UnloadPics(void) +{ + IN_LoadUnloadPics(UnloadLumpCallback); } //======================================================================== diff --git a/src/heretic/p_setup.c b/src/heretic/p_setup.c index 78836f42..b1a4f2ce 100644 --- a/src/heretic/p_setup.c +++ b/src/heretic/p_setup.c @@ -95,7 +95,7 @@ void P_LoadVertexes(int lump) li->y = SHORT(ml->y) << FRACBITS; } - Z_Free(data); + W_ReleaseLumpNum(lump); } @@ -142,7 +142,7 @@ void P_LoadSegs(int lump) li->backsector = 0; } - Z_Free(data); + W_ReleaseLumpNum(lump); } @@ -174,7 +174,7 @@ void P_LoadSubsectors(int lump) ss->firstline = SHORT(ms->firstseg); } - Z_Free(data); + W_ReleaseLumpNum(lump); } @@ -212,7 +212,7 @@ void P_LoadSectors(int lump) ss->thinglist = NULL; } - Z_Free(data); + W_ReleaseLumpNum(lump); } @@ -251,7 +251,7 @@ void P_LoadNodes(int lump) } } - Z_Free(data); + W_ReleaseLumpNum(lump); } @@ -285,7 +285,7 @@ void P_LoadThings(int lump) P_SpawnMapThing(mt); } - Z_Free(data); + W_ReleaseLumpNum(lump); } @@ -367,7 +367,7 @@ void P_LoadLineDefs(int lump) ld->backsector = 0; } - Z_Free(data); + W_ReleaseLumpNum(lump); } @@ -403,7 +403,7 @@ void P_LoadSideDefs(int lump) sd->sector = §ors[SHORT(msd->sector)]; } - Z_Free(data); + W_ReleaseLumpNum(lump); } diff --git a/src/heretic/r_data.c b/src/heretic/r_data.c index 16f6ca9f..ebd89018 100644 --- a/src/heretic/r_data.c +++ b/src/heretic/r_data.c @@ -327,7 +327,7 @@ void R_InitTextures(void) strncpy(name, name_p + i * 8, 8); patchlookup[i] = W_CheckNumForName(name); } - Z_Free(names); + W_ReleaseLumpName("PNAMES"); // // load the map texture definitions from textures.lmp @@ -420,9 +420,11 @@ void R_InitTextures(void) totalwidth += texture->width; } - Z_Free(maptex1); + W_ReleaseLumpName("TEXTURE1"); if (maptex2) - Z_Free(maptex2); + { + W_ReleaseLumpName("TEXTURE2"); + } // // precalculate whatever possible diff --git a/src/heretic/r_plane.c b/src/heretic/r_plane.c index 28c109a4..8c56dad5 100644 --- a/src/heretic/r_plane.c +++ b/src/heretic/r_plane.c @@ -379,6 +379,7 @@ void R_DrawPlanes(void) visplane_t *pl; int light; int x, stop; + int lumpnum; int angle; byte *tempSource; @@ -454,8 +455,9 @@ void R_DrawPlanes(void) // // regular flat // - tempSource = W_CacheLumpNum(firstflat + - flattranslation[pl->picnum], PU_STATIC); + lumpnum = firstflat + flattranslation[pl->picnum]; + + tempSource = W_CacheLumpNum(lumpnum, PU_STATIC); switch (pl->special) { @@ -512,6 +514,6 @@ void R_DrawPlanes(void) R_MakeSpans(x, pl->top[x - 1], pl->bottom[x - 1], pl->top[x], pl->bottom[x]); - Z_ChangeTag(tempSource, PU_CACHE); + W_ReleaseLumpNum(lumpnum); } } -- cgit v1.2.3