ref: 717ca7f67c77b09c9fc6f36936fbc6bdc4ff8e98
parent: 2fb5056878a2d5a29d8bb9597e2f458b46862ddd
author: Simon Howard <fraggle@gmail.com>
date: Fri Sep 26 12:25:24 EDT 2008
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
--- a/src/heretic/g_game.c
+++ b/src/heretic/g_game.c
@@ -1797,7 +1797,7 @@
if (singledemo)
I_Quit();
- Z_ChangeTag(demobuffer, PU_CACHE);
+ W_ReleaseLumpName(defdemoname);
demoplayback = false;
D_AdvanceDemo();
return true;
--- a/src/heretic/in_lude.c
+++ b/src/heretic/in_lude.c
@@ -299,13 +299,9 @@
}
}
-//========================================================================
-//
-// IN_LoadPics
-//
-//========================================================================
-
-void IN_LoadPics(void)
+static void IN_LoadUnloadPics(void (*callback)(char *lumpname,
+ int lumpnum,
+ patch_t **ptr))
{
int i;
@@ -312,31 +308,58 @@
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);
+}
- FontBSlash = W_CacheLumpName("FONTB15", PU_STATIC);
- FontBPercent = W_CacheLumpName("FONTB05", PU_STATIC);
+//========================================================================
+//
+// IN_LoadPics
+//
+//========================================================================
+
+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_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);
}
//========================================================================
--- a/src/heretic/p_setup.c
+++ b/src/heretic/p_setup.c
@@ -95,7 +95,7 @@
li->y = SHORT(ml->y) << FRACBITS;
}
- Z_Free(data);
+ W_ReleaseLumpNum(lump);
}
@@ -142,7 +142,7 @@
li->backsector = 0;
}
- Z_Free(data);
+ W_ReleaseLumpNum(lump);
}
@@ -174,7 +174,7 @@
ss->firstline = SHORT(ms->firstseg);
}
- Z_Free(data);
+ W_ReleaseLumpNum(lump);
}
@@ -212,7 +212,7 @@
ss->thinglist = NULL;
}
- Z_Free(data);
+ W_ReleaseLumpNum(lump);
}
@@ -251,7 +251,7 @@
}
}
- Z_Free(data);
+ W_ReleaseLumpNum(lump);
}
@@ -285,7 +285,7 @@
P_SpawnMapThing(mt);
}
- Z_Free(data);
+ W_ReleaseLumpNum(lump);
}
@@ -367,7 +367,7 @@
ld->backsector = 0;
}
- Z_Free(data);
+ W_ReleaseLumpNum(lump);
}
@@ -403,7 +403,7 @@
sd->sector = §ors[SHORT(msd->sector)];
}
- Z_Free(data);
+ W_ReleaseLumpNum(lump);
}
--- a/src/heretic/r_data.c
+++ b/src/heretic/r_data.c
@@ -327,7 +327,7 @@
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 @@
totalwidth += texture->width;
}
- Z_Free(maptex1);
+ W_ReleaseLumpName("TEXTURE1");
if (maptex2)
- Z_Free(maptex2);
+ {
+ W_ReleaseLumpName("TEXTURE2");
+ }
//
// precalculate whatever possible
--- a/src/heretic/r_plane.c
+++ b/src/heretic/r_plane.c
@@ -379,6 +379,7 @@
visplane_t *pl;
int light;
int x, stop;
+ int lumpnum;
int angle;
byte *tempSource;
@@ -454,9 +455,10 @@
//
// 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)
{
case 25:
@@ -512,6 +514,6 @@
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);
}
}