mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Support reading PICTURE/MINIMAP/ENCORE/TWEAKMAP lumps from a map resource
This supersedes the header-based method of fetching those lumps.
This commit is contained in:
parent
556aa1c4c0
commit
c64f36309a
12 changed files with 126 additions and 128 deletions
22
src/d_main.c
22
src/d_main.c
|
|
@ -353,7 +353,7 @@ static void D_Display(void)
|
|||
if (gamestate != GS_LEVEL && rendermode != render_none)
|
||||
{
|
||||
V_SetPaletteLump("PLAYPAL"); // Reset the palette
|
||||
R_ReInitColormaps(0, LUMPERROR);
|
||||
R_ReInitColormaps(0, NULL, 0);
|
||||
}
|
||||
|
||||
F_WipeStartScreen();
|
||||
|
|
@ -1194,6 +1194,8 @@ void D_SRB2Main(void)
|
|||
INT32 i;
|
||||
UINT16 wadnum;
|
||||
char *name;
|
||||
virtres_t *virtmap;
|
||||
virtlump_t *minimap, *thumbnailPic;
|
||||
|
||||
INT32 p;
|
||||
|
||||
|
|
@ -1455,6 +1457,24 @@ void D_SRB2Main(void)
|
|||
for (i = 0; i < numbasemapheaders; ++i)
|
||||
{
|
||||
name = mapheaderinfo[i]->lumpname;
|
||||
mapheaderinfo[i]->lumpnum = W_CheckNumForMap(name);
|
||||
|
||||
// Get map thumbnail and minimap
|
||||
virtmap = vres_GetMap(mapheaderinfo[i]->lumpnum);
|
||||
thumbnailPic = vres_Find(virtmap, "PICTURE");
|
||||
minimap = vres_Find(virtmap, "MINIMAP");
|
||||
|
||||
if (thumbnailPic)
|
||||
{
|
||||
mapheaderinfo[i]->thumbnailPic = vres_GetPatch(thumbnailPic, PU_CACHE);
|
||||
}
|
||||
|
||||
if (minimap)
|
||||
{
|
||||
mapheaderinfo[i]->minimapPic = vres_GetPatch(minimap, PU_HUDGFX);
|
||||
}
|
||||
|
||||
vres_Free(virtmap);
|
||||
|
||||
if (W_CheckNumForMapPwad(name, wadnum, 0) != INT16_MAX)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1275,22 +1275,6 @@ void readlevelheader(MYFILE *f, char * name)
|
|||
}
|
||||
|
||||
// Strings that can be truncated
|
||||
else if (fastcmp(word, "THUMBNAIL"))
|
||||
{
|
||||
mapheaderinfo[num-1]->thumbnailLump = Z_StrDup(word2);
|
||||
}
|
||||
else if (fastcmp(word, "MINIMAP"))
|
||||
{
|
||||
mapheaderinfo[num-1]->minimapLump = Z_StrDup(word2);
|
||||
}
|
||||
else if (fastcmp(word, "ENCOREMAP"))
|
||||
{
|
||||
mapheaderinfo[num-1]->encoreLump = Z_StrDup(word2);
|
||||
}
|
||||
else if (fastcmp(word, "TWEAKMAP"))
|
||||
{
|
||||
mapheaderinfo[num-1]->tweakLump = Z_StrDup(word2);
|
||||
}
|
||||
else if (fastcmp(word, "NEXTLEVEL"))
|
||||
{
|
||||
mapheaderinfo[num-1]->nextlevel = Z_StrDup(word2);
|
||||
|
|
|
|||
|
|
@ -25,6 +25,9 @@
|
|||
// We need the player data structure as well.
|
||||
#include "d_player.h"
|
||||
|
||||
// For lumpnum_t.
|
||||
#include "w_wad.h"
|
||||
|
||||
// =============================
|
||||
// Selected map etc.
|
||||
// =============================
|
||||
|
|
@ -338,11 +341,12 @@ typedef struct
|
|||
typedef struct
|
||||
{
|
||||
char * lumpname; ///< Lump name can be really long
|
||||
lumpnum_t lumpnum; ///< Lump number for the map, used by vres_GetMap
|
||||
|
||||
char * thumbnailLump; ///< Lump name for the level select thumbnail.
|
||||
char * minimapLump; ///< Lump name for the minimap graphic.
|
||||
char * encoreLump; ///< Lump name for the Encore Mode remap.
|
||||
char * tweakLump; ///< Lump name for the palette tweak remap.
|
||||
void * thumbnailPic; ///< Lump data for the level select thumbnail.
|
||||
void * minimapPic; ///< Lump data for the minimap graphic.
|
||||
void * encoreLump; ///< Lump data for the Encore Mode remap.
|
||||
void * tweakLump; ///< Lump data for the palette tweak remap.
|
||||
|
||||
char lvlttl[22]; ///< Level name without "Zone". (21 character limit instead of 32, 21 characters can display on screen max anyway)
|
||||
char subttl[33]; ///< Subtitle for level
|
||||
|
|
|
|||
13
src/k_hud.c
13
src/k_hud.c
|
|
@ -3395,7 +3395,6 @@ static void K_drawKartMinimapIcon(fixed_t objx, fixed_t objy, INT32 hudx, INT32
|
|||
|
||||
static void K_drawKartMinimap(void)
|
||||
{
|
||||
lumpnum_t lumpnum = LUMPERROR;
|
||||
patch_t *AutomapPic;
|
||||
INT32 i = 0;
|
||||
INT32 x, y;
|
||||
|
|
@ -3418,20 +3417,14 @@ static void K_drawKartMinimap(void)
|
|||
// Maybe move this somewhere else where this won't be a concern?
|
||||
if (stplyr != &players[displayplayers[0]])
|
||||
return;
|
||||
#if 0
|
||||
if (mapheaderinfo[gamemap-1])
|
||||
{
|
||||
lumpnum = W_CheckNumForLongName(mapheaderinfo[gamemap-1]->minimapLump);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (lumpnum == LUMPERROR)
|
||||
AutomapPic = mapheaderinfo[gamemap-1]->minimapPic;
|
||||
|
||||
if (!AutomapPic)
|
||||
{
|
||||
return; // no pic, just get outta here
|
||||
}
|
||||
|
||||
AutomapPic = W_CachePatchNum(lumpnum, PU_HUDGFX);
|
||||
|
||||
if (r_splitscreen < 2) // 1/2P right aligned
|
||||
{
|
||||
splitflags = (V_SLIDEIN|V_SNAPTORIGHT);
|
||||
|
|
|
|||
|
|
@ -1847,17 +1847,14 @@ static void M_DrawCupPreview(INT16 y, cupheader_t *cup)
|
|||
while (x < BASEVIDWIDTH + pad)
|
||||
{
|
||||
INT32 cupLevelNum = G_MapNumber(cup->levellist[i]);
|
||||
lumpnum_t lumpnum = LUMPERROR;
|
||||
patch_t *PictureOfLevel;
|
||||
patch_t *PictureOfLevel = NULL;
|
||||
|
||||
if (mapheaderinfo[cupLevelNum])
|
||||
{
|
||||
lumpnum = W_CheckNumForLongName(mapheaderinfo[cupLevelNum]->thumbnailLump);
|
||||
PictureOfLevel = mapheaderinfo[cupLevelNum]->thumbnailPic;
|
||||
}
|
||||
|
||||
if (lumpnum != LUMPERROR)
|
||||
PictureOfLevel = W_CachePatchNum(lumpnum, PU_CACHE);
|
||||
else
|
||||
if (!PictureOfLevel)
|
||||
PictureOfLevel = W_CachePatchName("BLANKLVL", PU_CACHE);
|
||||
|
||||
V_DrawSmallScaledPatch(x + 1, y+2, 0, PictureOfLevel);
|
||||
|
|
@ -2078,8 +2075,7 @@ static void M_DrawHighLowLevelTitle(INT16 x, INT16 y, INT16 map)
|
|||
|
||||
static void M_DrawLevelSelectBlock(INT16 x, INT16 y, INT16 map, boolean redblink, boolean greyscale)
|
||||
{
|
||||
lumpnum_t lumpnum = LUMPERROR;
|
||||
patch_t *PictureOfLevel;
|
||||
patch_t *PictureOfLevel = NULL;
|
||||
UINT8 *colormap = NULL;
|
||||
|
||||
if (greyscale)
|
||||
|
|
@ -2087,12 +2083,10 @@ static void M_DrawLevelSelectBlock(INT16 x, INT16 y, INT16 map, boolean redblink
|
|||
|
||||
if (mapheaderinfo[map])
|
||||
{
|
||||
lumpnum = W_CheckNumForLongName(mapheaderinfo[map]->thumbnailLump);
|
||||
PictureOfLevel = mapheaderinfo[map]->thumbnailPic;
|
||||
}
|
||||
|
||||
if (lumpnum != LUMPERROR)
|
||||
PictureOfLevel = W_CachePatchNum(lumpnum, PU_CACHE);
|
||||
else
|
||||
if (!PictureOfLevel)
|
||||
PictureOfLevel = W_CachePatchName("BLANKLVL", PU_CACHE);
|
||||
|
||||
if (redblink)
|
||||
|
|
@ -2155,7 +2149,7 @@ void M_DrawTimeAttack(void)
|
|||
INT16 rightedge = 149+t+155;
|
||||
INT16 opty = 140;
|
||||
INT32 w;
|
||||
lumpnum_t lumpnum = LUMPERROR;
|
||||
patch_t *minimap = NULL;
|
||||
UINT8 i;
|
||||
consvar_t *cv;
|
||||
|
||||
|
|
@ -2169,11 +2163,11 @@ void M_DrawTimeAttack(void)
|
|||
{
|
||||
if (mapheaderinfo[map])
|
||||
{
|
||||
lumpnum = W_CheckNumForName(mapheaderinfo[map]->minimapLump);
|
||||
minimap = mapheaderinfo[map]->minimapPic;
|
||||
}
|
||||
|
||||
if (lumpnum != LUMPERROR)
|
||||
V_DrawScaledPatch(24-t, 82, 0, W_CachePatchNum(lumpnum, PU_CACHE));
|
||||
if (!minimap)
|
||||
V_DrawScaledPatch(24-t, 82, 0, minimap);
|
||||
|
||||
V_DrawRightAlignedString(rightedge-12, 82, highlightflags, "BEST LAP:");
|
||||
K_drawKartTimestamp(0, 162+t, 88, 0, 2);
|
||||
|
|
@ -3838,8 +3832,7 @@ void M_DrawPlaybackMenu(void)
|
|||
#define SCALEDVIEWHEIGHT (vid.height/vid.dupy)
|
||||
void M_DrawReplayHutReplayInfo(void)
|
||||
{
|
||||
lumpnum_t lumpnum = LUMPERROR;
|
||||
patch_t *patch;
|
||||
patch_t *patch = NULL;
|
||||
UINT8 *colormap;
|
||||
INT32 x, y, w, h;
|
||||
|
||||
|
|
@ -3868,12 +3861,10 @@ void M_DrawReplayHutReplayInfo(void)
|
|||
|
||||
if (mapheaderinfo[extrasmenu.demolist[dir_on[menudepthleft]].map])
|
||||
{
|
||||
lumpnum = W_CheckNumForName(mapheaderinfo[extrasmenu.demolist[dir_on[menudepthleft]].map]->thumbnailLump);
|
||||
patch = mapheaderinfo[extrasmenu.demolist[dir_on[menudepthleft]].map]->thumbnailPic;
|
||||
}
|
||||
|
||||
if (lumpnum != LUMPERROR)
|
||||
patch = W_CachePatchNum(lumpnum, PU_CACHE);
|
||||
else
|
||||
if (!patch)
|
||||
patch = W_CachePatchName("M_NOLVL", PU_CACHE);
|
||||
|
||||
if (!(extrasmenu.demolist[dir_on[menudepthleft]].kartspeed & DF_ENCORE))
|
||||
|
|
|
|||
|
|
@ -600,7 +600,6 @@ static int libd_drawOnMinimap(lua_State *L)
|
|||
huddrawlist_h list;
|
||||
|
||||
// variables used to replicate k_kart's mmap drawer:
|
||||
lumpnum_t lumpnum = LUMPERROR;
|
||||
patch_t *AutomapPic;
|
||||
INT32 mx, my;
|
||||
INT32 splitflags, minimaptrans;
|
||||
|
|
@ -686,18 +685,13 @@ static int libd_drawOnMinimap(lua_State *L)
|
|||
if (stplyr != &players[displayplayers[0]])
|
||||
return 0;
|
||||
|
||||
if (mapheaderinfo[gamemap-1])
|
||||
{
|
||||
lumpnum = W_CheckNumForLongName(mapheaderinfo[gamemap-1]->minimapLump);
|
||||
}
|
||||
AutomapPic = mapheaderinfo[gamemap-1]->minimapPic;
|
||||
|
||||
if (lumpnum == LUMPERROR)
|
||||
if (!AutomapPic)
|
||||
{
|
||||
return 0; // no pic, just get outta here
|
||||
}
|
||||
|
||||
AutomapPic = W_CachePatchNum(lumpnum, PU_HUDGFX);
|
||||
|
||||
mx = MM_X - (AutomapPic->width/2);
|
||||
my = MM_Y - (AutomapPic->height/2);
|
||||
|
||||
|
|
|
|||
102
src/p_setup.c
102
src/p_setup.c
|
|
@ -134,6 +134,8 @@ boolean stoppedclock;
|
|||
boolean levelloading;
|
||||
UINT8 levelfadecol;
|
||||
|
||||
virtres_t *curmapvirt;
|
||||
|
||||
// BLOCKMAP
|
||||
// Created from axis aligned bounding box
|
||||
// of the map, a rectangular array of
|
||||
|
|
@ -361,28 +363,16 @@ static void P_ClearSingleMapHeaderInfo(INT16 i)
|
|||
{
|
||||
const INT16 num = (INT16)(i-1);
|
||||
|
||||
if (mapheaderinfo[num]->thumbnailLump)
|
||||
if (mapheaderinfo[num]->thumbnailPic)
|
||||
{
|
||||
Z_Free(mapheaderinfo[num]->thumbnailLump);
|
||||
mapheaderinfo[num]->thumbnailLump = NULL;
|
||||
Z_Free(mapheaderinfo[num]->thumbnailPic);
|
||||
mapheaderinfo[num]->thumbnailPic = NULL;
|
||||
}
|
||||
|
||||
if (mapheaderinfo[num]->minimapLump)
|
||||
if (mapheaderinfo[num]->minimapPic)
|
||||
{
|
||||
Z_Free(mapheaderinfo[num]->minimapLump);
|
||||
mapheaderinfo[num]->minimapLump = NULL;
|
||||
}
|
||||
|
||||
if (mapheaderinfo[num]->encoreLump)
|
||||
{
|
||||
Z_Free(mapheaderinfo[num]->encoreLump);
|
||||
mapheaderinfo[num]->encoreLump = NULL;
|
||||
}
|
||||
|
||||
if (mapheaderinfo[num]->tweakLump)
|
||||
{
|
||||
Z_Free(mapheaderinfo[num]->tweakLump);
|
||||
mapheaderinfo[num]->tweakLump = NULL;
|
||||
Z_Free(mapheaderinfo[num]->minimapPic);
|
||||
mapheaderinfo[num]->minimapPic = NULL;
|
||||
}
|
||||
|
||||
if (mapheaderinfo[num]->nextlevel)
|
||||
|
|
@ -469,11 +459,10 @@ void P_AllocMapHeader(INT16 i)
|
|||
if (!mapheaderinfo[i])
|
||||
{
|
||||
mapheaderinfo[i] = Z_Malloc(sizeof(mapheader_t), PU_STATIC, NULL);
|
||||
mapheaderinfo[i]->lumpnum = LUMPERROR;
|
||||
mapheaderinfo[i]->lumpname = NULL;
|
||||
mapheaderinfo[i]->thumbnailLump = NULL;
|
||||
mapheaderinfo[i]->minimapLump = NULL;
|
||||
mapheaderinfo[i]->encoreLump = NULL;
|
||||
mapheaderinfo[i]->tweakLump = NULL;
|
||||
mapheaderinfo[i]->thumbnailPic = NULL;
|
||||
mapheaderinfo[i]->minimapPic = NULL;
|
||||
mapheaderinfo[i]->nextlevel = NULL;
|
||||
mapheaderinfo[i]->marathonnext = NULL;
|
||||
mapheaderinfo[i]->flickies = NULL;
|
||||
|
|
@ -3600,15 +3589,14 @@ static void P_MakeMapMD5(virtres_t *virt, void *dest)
|
|||
|
||||
static boolean P_LoadMapFromFile(void)
|
||||
{
|
||||
virtres_t *virt = vres_GetMap(lastloadedmaplumpnum);
|
||||
virtlump_t *textmap = vres_Find(virt, "TEXTMAP");
|
||||
virtlump_t *textmap = vres_Find(curmapvirt, "TEXTMAP");
|
||||
size_t i;
|
||||
udmf = textmap != NULL;
|
||||
|
||||
if (!P_LoadMapData(virt))
|
||||
if (!P_LoadMapData(curmapvirt))
|
||||
return false;
|
||||
P_LoadMapBSP(virt);
|
||||
P_LoadMapLUT(virt);
|
||||
P_LoadMapBSP(curmapvirt);
|
||||
P_LoadMapLUT(curmapvirt);
|
||||
|
||||
P_LinkMapData();
|
||||
|
||||
|
|
@ -3633,9 +3621,9 @@ static boolean P_LoadMapFromFile(void)
|
|||
if (sectors[i].tags.count)
|
||||
spawnsectors[i].tags.tags = memcpy(Z_Malloc(sectors[i].tags.count*sizeof(mtag_t), PU_LEVEL, NULL), sectors[i].tags.tags, sectors[i].tags.count*sizeof(mtag_t));
|
||||
|
||||
P_MakeMapMD5(virt, &mapmd5);
|
||||
P_MakeMapMD5(curmapvirt, &mapmd5);
|
||||
|
||||
vres_Free(virt);
|
||||
vres_Free(curmapvirt);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -4129,6 +4117,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
|
|||
// Map header should always be in place at this point
|
||||
INT32 i, ranspecialwipe = 0;
|
||||
sector_t *ss;
|
||||
virtlump_t *encoreLump = NULL;
|
||||
|
||||
levelloading = true;
|
||||
|
||||
|
|
@ -4355,24 +4344,27 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
|
|||
if (lastloadedmaplumpnum == LUMPERROR)
|
||||
I_Error("Map %s not found.\n", maplumpname);
|
||||
|
||||
curmapvirt = vres_GetMap(lastloadedmaplumpnum);
|
||||
|
||||
if (mapheaderinfo[gamemap-1])
|
||||
{
|
||||
INT32 encoreLump = LUMPERROR;
|
||||
|
||||
#if 0
|
||||
if (mapheaderinfo[gamemap-1])
|
||||
if (encoremode)
|
||||
{
|
||||
if (encoremode)
|
||||
{
|
||||
encoreLump = W_CheckNumForLongName(mapheaderinfo[gamemap-1]->encoreLump);
|
||||
}
|
||||
else
|
||||
{
|
||||
encoreLump = W_CheckNumForLongName(mapheaderinfo[gamemap-1]->tweakLump);
|
||||
}
|
||||
encoreLump = vres_Find(curmapvirt, "ENCORE");
|
||||
}
|
||||
else
|
||||
{
|
||||
encoreLump = vres_Find(curmapvirt, "TWEAKMAP");
|
||||
}
|
||||
}
|
||||
|
||||
R_ReInitColormaps(mapheaderinfo[gamemap-1]->palette, encoreLump);
|
||||
#endif
|
||||
if (encoreLump)
|
||||
{
|
||||
R_ReInitColormaps(mapheaderinfo[gamemap-1]->palette, encoreLump->data, encoreLump->size);
|
||||
}
|
||||
else
|
||||
{
|
||||
R_ReInitColormaps(mapheaderinfo[gamemap-1]->palette, NULL, 0);
|
||||
}
|
||||
CON_SetupBackColormap();
|
||||
|
||||
|
|
@ -4677,6 +4669,8 @@ boolean P_AddWadFile(const char *wadfilename)
|
|||
UINT16 numlumps, wadnum;
|
||||
char *name;
|
||||
lumpinfo_t *lumpinfo;
|
||||
virtres_t *virtmap;
|
||||
virtlump_t *minimap, *thumbnailPic;
|
||||
|
||||
//boolean texturechange = false; ///\todo Useless; broken when back-frontporting PK3 changes?
|
||||
boolean mapsadded = false;
|
||||
|
|
@ -4834,6 +4828,28 @@ boolean P_AddWadFile(const char *wadfilename)
|
|||
{
|
||||
name = mapheaderinfo[map]->lumpname;
|
||||
|
||||
if (mapheaderinfo[i]->lumpnum != W_CheckNumForMap(name))
|
||||
{
|
||||
mapheaderinfo[i]->lumpnum = W_CheckNumForMap(name);
|
||||
|
||||
// Get map thumbnail and minimap
|
||||
virtmap = vres_GetMap(mapheaderinfo[i]->lumpnum);
|
||||
thumbnailPic = vres_Find(virtmap, "PICTURE");
|
||||
minimap = vres_Find(virtmap, "MINIMAP");
|
||||
|
||||
if (thumbnailPic)
|
||||
{
|
||||
mapheaderinfo[i]->thumbnailPic = vres_GetPatch(thumbnailPic, PU_CACHE);
|
||||
}
|
||||
|
||||
if (minimap)
|
||||
{
|
||||
mapheaderinfo[i]->minimapPic = vres_GetPatch(minimap, PU_HUDGFX);
|
||||
}
|
||||
|
||||
vres_Free(virtmap);
|
||||
}
|
||||
|
||||
if (W_CheckNumForMapPwad(name, wadnum, 0) != INT16_MAX)
|
||||
{
|
||||
G_SetGameModified(multiplayer, true); // oops, double-defined - no record attack privileges for you
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ void R_InitColormaps(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
void R_ReInitColormaps(UINT16 num, lumpnum_t newencoremap)
|
||||
void R_ReInitColormaps(UINT16 num, void *newencoremap, size_t encoremapsize)
|
||||
{
|
||||
char colormap[9] = "COLORMAP";
|
||||
lumpnum_t lump;
|
||||
|
|
@ -309,13 +309,13 @@ void R_ReInitColormaps(UINT16 num, lumpnum_t newencoremap)
|
|||
W_ReadLumpHeader(lump, colormaps, W_LumpLength(basecolormaplump), 0U);
|
||||
|
||||
// Encore mode.
|
||||
if (newencoremap != LUMPERROR)
|
||||
if (newencoremap)
|
||||
{
|
||||
lighttable_t *colormap_p, *colormap_p2;
|
||||
size_t p, i;
|
||||
|
||||
encoremap = Z_MallocAlign(256 + 10, PU_LEVEL, NULL, 8);
|
||||
W_ReadLump(newencoremap, encoremap);
|
||||
M_Memcpy(encoremap, newencoremap, encoremapsize);
|
||||
colormap_p = colormap_p2 = colormaps;
|
||||
colormap_p += COLORMAP_REMAPOFFSET;
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ extern size_t flatmemory, spritememory, texturememory;
|
|||
//#define COLORMAPREVERSELIST
|
||||
|
||||
void R_InitColormaps(void);
|
||||
void R_ReInitColormaps(UINT16 num, lumpnum_t newencoremap);
|
||||
void R_ReInitColormaps(UINT16 num, void *newencoremap, size_t encoremapsize);
|
||||
void R_ClearColormaps(void);
|
||||
extracolormap_t *R_CreateDefaultColormap(boolean lighttable);
|
||||
extracolormap_t *R_GetDefaultColormap(void);
|
||||
|
|
|
|||
24
src/w_wad.c
24
src/w_wad.c
|
|
@ -1771,7 +1771,7 @@ void *W_CacheLumpName(const char *name, INT32 tag)
|
|||
// Cache a patch into heap memory, convert the patch format as necessary
|
||||
//
|
||||
|
||||
static void MakePatch(void *lumpdata, size_t size, INT32 tag, void *cache)
|
||||
static void *MakePatch(void *lumpdata, size_t size, INT32 tag, void *cache)
|
||||
{
|
||||
void *ptr, *dest;
|
||||
size_t len = size;
|
||||
|
|
@ -1786,9 +1786,10 @@ static void MakePatch(void *lumpdata, size_t size, INT32 tag, void *cache)
|
|||
#endif
|
||||
|
||||
dest = Z_Calloc(sizeof(patch_t), tag, cache);
|
||||
|
||||
Patch_Create(ptr, len, dest);
|
||||
|
||||
Z_Free(ptr);
|
||||
return dest;
|
||||
}
|
||||
|
||||
void *W_CacheSoftwarePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag)
|
||||
|
|
@ -1809,6 +1810,7 @@ void *W_CacheSoftwarePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag)
|
|||
W_ReadLumpHeaderPwad(wad, lump, lumpdata, 0, 0);
|
||||
|
||||
MakePatch(lumpdata, len, tag, &lumpcache[lump]);
|
||||
Z_Free(lumpdata);
|
||||
}
|
||||
else
|
||||
Z_ChangeTag(lumpcache[lump], tag);
|
||||
|
|
@ -2289,7 +2291,6 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
|
|||
vlumps[i].name[8] = '\0';
|
||||
vlumps[i].data = Z_Malloc(vlumps[i].size, PU_LEVEL, NULL); // This is memory inefficient, sorry about that.
|
||||
memcpy(vlumps[i].data, wadData + (fileinfo + i)->filepos, vlumps[i].size);
|
||||
vlumps[i].cache = NULL;
|
||||
}
|
||||
|
||||
Z_Free(wadData);
|
||||
|
|
@ -2310,7 +2311,6 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
|
|||
memcpy(vlumps[i].name, W_CheckNameForNum(lumpnum), 8);
|
||||
vlumps[i].name[8] = '\0';
|
||||
vlumps[i].data = W_CacheLumpNum(lumpnum, PU_LEVEL);
|
||||
vlumps[i].cache = NULL;
|
||||
}
|
||||
}
|
||||
vres = Z_Malloc(sizeof(virtres_t), PU_LEVEL, NULL);
|
||||
|
|
@ -2327,7 +2327,12 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
|
|||
void vres_Free(virtres_t* vres)
|
||||
{
|
||||
while (vres->numlumps--)
|
||||
Z_Free(vres->vlumps[vres->numlumps].data);
|
||||
{
|
||||
if (vres->vlumps[vres->numlumps].data)
|
||||
{
|
||||
Z_Free(vres->vlumps[vres->numlumps].data);
|
||||
}
|
||||
}
|
||||
Z_Free(vres->vlumps);
|
||||
Z_Free(vres);
|
||||
}
|
||||
|
|
@ -2372,14 +2377,7 @@ void *vres_GetPatch(virtlump_t *vlump, INT32 tag)
|
|||
if (!vlump)
|
||||
return NULL;
|
||||
|
||||
if (!vlump->cache)
|
||||
{
|
||||
MakePatch(vlump->data, vlump->size, tag, &vlump->cache);
|
||||
}
|
||||
else
|
||||
Z_ChangeTag(vlump->cache, tag);
|
||||
|
||||
patch = vlump->cache;
|
||||
patch = MakePatch(vlump->data, vlump->size, tag, NULL);
|
||||
|
||||
#ifdef HWRENDER
|
||||
// Software-only compile cache the data without conversion
|
||||
|
|
|
|||
|
|
@ -82,7 +82,6 @@ typedef struct {
|
|||
char name[9];
|
||||
UINT8* data;
|
||||
size_t size;
|
||||
void *cache;
|
||||
} virtlump_t;
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -93,7 +92,7 @@ typedef struct {
|
|||
virtres_t* vres_GetMap(lumpnum_t);
|
||||
void vres_Free(virtres_t*);
|
||||
virtlump_t* vres_Find(const virtres_t*, const char*);
|
||||
void* vres_GetPatch(virtlump_t *vlump, INT32 tag);
|
||||
void* vres_GetPatch(virtlump_t *vlump, INT32);
|
||||
|
||||
// =========================================================================
|
||||
// DYNAMIC WAD LOADING
|
||||
|
|
|
|||
|
|
@ -1490,8 +1490,6 @@ void Y_StartVote(void)
|
|||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
lumpnum_t lumpnum = LUMPERROR;
|
||||
|
||||
// set up the encore
|
||||
levelinfo[i].encore = (votelevels[i][1] & 0x80);
|
||||
votelevels[i][1] &= ~0x80;
|
||||
|
|
@ -1534,13 +1532,14 @@ void Y_StartVote(void)
|
|||
levelinfo[i].gts = NULL;
|
||||
|
||||
// set up the pic
|
||||
patch_t *thumbnailPic = NULL;
|
||||
if (mapheaderinfo[votelevels[i][0]+1])
|
||||
{
|
||||
lumpnum = W_CheckNumForLongName(mapheaderinfo[votelevels[i][0]]->thumbnailLump);
|
||||
thumbnailPic = mapheaderinfo[votelevels[i][0]]->thumbnailPic;
|
||||
}
|
||||
|
||||
if (lumpnum != LUMPERROR)
|
||||
levelinfo[i].pic = W_CachePatchNum(lumpnum, PU_STATIC);
|
||||
if (thumbnailPic)
|
||||
levelinfo[i].pic = thumbnailPic;
|
||||
else
|
||||
levelinfo[i].pic = W_CachePatchName("BLANKLVL", PU_STATIC);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue