improve virtual resource management
This commit is contained in:
1 parent
8f195530b5
commit
b7e77e10b6
3 files changed
+32
-8
No files matched your search
+18
-8
@@ -109,6 +109,8 @@ INT32 numstarposts;
|
||||
boolean levelloading;
|
||||
UINT8 levelfadecol;
|
||||
|
||||
virtres_t *curmapvirt;
|
||||
|
||||
// BLOCKMAP
|
||||
// Created from axis aligned bounding box
|
||||
// of the map, a rectangular array of
|
||||
@@ -2337,20 +2339,26 @@ static void P_MakeMapMD5(virtres_t *virt, void *dest)
|
||||
|
||||
static void P_LoadMapFromFile(void)
|
||||
{
|
||||
virtres_t *virt = vres_GetMap(lastloadedmaplumpnum);
|
||||
|
||||
P_LoadMapData(virt);
|
||||
P_LoadMapBSP(virt);
|
||||
P_LoadMapLUT(virt);
|
||||
P_LoadMapData(curmapvirt);
|
||||
P_LoadMapBSP(curmapvirt);
|
||||
P_LoadMapLUT(curmapvirt);
|
||||
|
||||
P_LoadLineDefs2();
|
||||
P_GroupLines();
|
||||
|
||||
P_PrepareRawThings(vres_Find(virt, "THINGS")->data);
|
||||
P_PrepareRawThings(vres_Find(curmapvirt, "THINGS")->data);
|
||||
|
||||
P_MakeMapMD5(virt, &mapmd5);
|
||||
P_MakeMapMD5(curmapvirt, &mapmd5);
|
||||
|
||||
vres_Free(virt);
|
||||
// We do the following silly
|
||||
// construction because vres_Free
|
||||
// no-sells deletions of pointers
|
||||
// that are == curmapvirt.
|
||||
{
|
||||
virtres_t *temp = curmapvirt;
|
||||
curmapvirt = NULL;
|
||||
vres_Free(temp);
|
||||
}
|
||||
}
|
||||
|
||||
static void P_RunLevelScript(const char *scriptname)
|
||||
@@ -2803,6 +2811,8 @@ boolean P_SetupLevel(boolean skipprecip)
|
||||
if (lastloadedmaplumpnum == INT16_MAX)
|
||||
I_Error("Map %s not found.\n", maplumpname);
|
||||
|
||||
curmapvirt = vres_GetMap(lastloadedmaplumpnum);
|
||||
|
||||
R_ReInitColormaps(mapheaderinfo[gamemap-1]->palette,
|
||||
(encoremode ? W_CheckNumForName(va("%sE", maplumpname)) : LUMPERROR));
|
||||
CON_SetupBackColormap();
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "doomdata.h"
|
||||
#include "doomstat.h"
|
||||
#include "r_defs.h"
|
||||
#include "w_wad.h"
|
||||
|
||||
extern SINT8 midgamejoin;
|
||||
|
||||
@@ -32,6 +33,7 @@ extern boolean levelloading;
|
||||
extern UINT8 levelfadecol;
|
||||
|
||||
extern lumpnum_t lastloadedmaplumpnum; // for comparative savegame
|
||||
extern virtres_t *curmapvirt;
|
||||
//
|
||||
// MAP used flats lookup table
|
||||
//
|
||||
|
||||
+12
@@ -2132,6 +2132,12 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
|
||||
virtlump_t* vlumps = NULL;
|
||||
size_t numlumps = 0;
|
||||
|
||||
if (lastloadedmaplumpnum == lumpnum && curmapvirt != NULL)
|
||||
{
|
||||
// Avoid duplicating all our hard work.
|
||||
return curmapvirt;
|
||||
}
|
||||
|
||||
if (W_IsLumpWad(lumpnum))
|
||||
{
|
||||
UINT32 realentry;
|
||||
@@ -2208,6 +2214,12 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
|
||||
*/
|
||||
void vres_Free(virtres_t* vres)
|
||||
{
|
||||
if (vres == curmapvirt)
|
||||
{
|
||||
// No-sell multiple references.
|
||||
return;
|
||||
}
|
||||
|
||||
while (vres->numlumps--)
|
||||
Z_Free(vres->vlumps[vres->numlumps].data);
|
||||
Z_Free(vres->vlumps);
|
||||
|
||||
Reference in new issue
Block a user