still making things better

This commit is contained in:
Jaime Passos 2019-09-08 21:37:24 -03:00
parent 61a16d43f5
commit 11077c2bac
20 changed files with 224 additions and 152 deletions

View file

@ -1585,12 +1585,15 @@ void CON_Drawer(void)
if (needpatchrecache) if (needpatchrecache)
{ {
W_FlushCachedPatches(); Z_FlushCachedPatches();
HU_LoadGraphics(); HU_LoadGraphics();
} }
if (con_recalc) if (con_recalc)
{
CON_RecalcSize(); CON_RecalcSize();
CON_ClearHUD();
}
if (con_curlines > 0) if (con_curlines > 0)
CON_DrawConsole(); CON_DrawConsole();

View file

@ -1451,21 +1451,21 @@ void F_GameEndTicker(void)
// ============== // ==============
static void F_CacheTitleScreen(void) static void F_CacheTitleScreen(void)
{ {
ttbanner = W_CachePatchName("TTBANNER", PU_LEVEL); ttbanner = W_CachePatchName("TTBANNER", PU_PATCH);
ttwing = W_CachePatchName("TTWING", PU_LEVEL); ttwing = W_CachePatchName("TTWING", PU_PATCH);
ttsonic = W_CachePatchName("TTSONIC", PU_LEVEL); ttsonic = W_CachePatchName("TTSONIC", PU_PATCH);
ttswave1 = W_CachePatchName("TTSWAVE1", PU_LEVEL); ttswave1 = W_CachePatchName("TTSWAVE1", PU_PATCH);
ttswave2 = W_CachePatchName("TTSWAVE2", PU_LEVEL); ttswave2 = W_CachePatchName("TTSWAVE2", PU_PATCH);
ttswip1 = W_CachePatchName("TTSWIP1", PU_LEVEL); ttswip1 = W_CachePatchName("TTSWIP1", PU_PATCH);
ttsprep1 = W_CachePatchName("TTSPREP1", PU_LEVEL); ttsprep1 = W_CachePatchName("TTSPREP1", PU_PATCH);
ttsprep2 = W_CachePatchName("TTSPREP2", PU_LEVEL); ttsprep2 = W_CachePatchName("TTSPREP2", PU_PATCH);
ttspop1 = W_CachePatchName("TTSPOP1", PU_LEVEL); ttspop1 = W_CachePatchName("TTSPOP1", PU_PATCH);
ttspop2 = W_CachePatchName("TTSPOP2", PU_LEVEL); ttspop2 = W_CachePatchName("TTSPOP2", PU_PATCH);
ttspop3 = W_CachePatchName("TTSPOP3", PU_LEVEL); ttspop3 = W_CachePatchName("TTSPOP3", PU_PATCH);
ttspop4 = W_CachePatchName("TTSPOP4", PU_LEVEL); ttspop4 = W_CachePatchName("TTSPOP4", PU_PATCH);
ttspop5 = W_CachePatchName("TTSPOP5", PU_LEVEL); ttspop5 = W_CachePatchName("TTSPOP5", PU_PATCH);
ttspop6 = W_CachePatchName("TTSPOP6", PU_LEVEL); ttspop6 = W_CachePatchName("TTSPOP6", PU_PATCH);
ttspop7 = W_CachePatchName("TTSPOP7", PU_LEVEL); ttspop7 = W_CachePatchName("TTSPOP7", PU_PATCH);
} }
void F_StartTitleScreen(void) void F_StartTitleScreen(void)

View file

@ -835,8 +835,10 @@ static INT32 SolveTProblem(void)
return 0; return 0;
CONS_Debug(DBG_RENDER, "Solving T-joins. This may take a while. Please wait...\n"); CONS_Debug(DBG_RENDER, "Solving T-joins. This may take a while. Please wait...\n");
#ifdef HWR_LOADING_SCREEN
CON_Drawer(); //let the user know what we are doing CON_Drawer(); //let the user know what we are doing
I_FinishUpdate(); // page flip or blit buffer I_FinishUpdate(); // page flip or blit buffer
#endif
numsplitpoly = 0; numsplitpoly = 0;
@ -963,9 +965,9 @@ void HWR_CreatePlanePolygons(INT32 bspnum)
CONS_Debug(DBG_RENDER, "Creating polygons, please wait...\n"); CONS_Debug(DBG_RENDER, "Creating polygons, please wait...\n");
#ifdef HWR_LOADING_SCREEN #ifdef HWR_LOADING_SCREEN
ls_count = ls_percent = 0; // reset the loading status ls_count = ls_percent = 0; // reset the loading status
#endif
CON_Drawer(); //let the user know what we are doing CON_Drawer(); //let the user know what we are doing
I_FinishUpdate(); // page flip or blit buffer I_FinishUpdate(); // page flip or blit buffer
#endif
HWR_ClearPolys(); HWR_ClearPolys();

View file

@ -571,9 +571,18 @@ static void FreeMipmapColormap(INT32 patchnum, void *patch)
} }
} }
void HWR_FreeTextureCache(void) void HWR_FreeColormaps(void)
{ {
INT32 i; INT32 i;
// Alam: free the Z_Blocks before freeing it's users
// free all skin after each level: must be done after pfnClearMipMapCache!
for (i = 0; i < numwadfiles; i++)
M_AATreeIterate(wadfiles[i]->hwrcache, FreeMipmapColormap);
}
void HWR_FreeTextureCache(void)
{
// free references to the textures // free references to the textures
HWD.pfnClearMipMapCache(); HWD.pfnClearMipMapCache();
@ -582,15 +591,6 @@ void HWR_FreeTextureCache(void)
Z_FreeTags(PU_HWRCACHE, PU_HWRCACHE); Z_FreeTags(PU_HWRCACHE, PU_HWRCACHE);
Z_FreeTags(PU_HWRCACHE_UNLOCKED, PU_HWRCACHE_UNLOCKED); Z_FreeTags(PU_HWRCACHE_UNLOCKED, PU_HWRCACHE_UNLOCKED);
// Alam: free the Z_Blocks before freeing it's users
// free all skin after each level: must be done after pfnClearMipMapCache!
// temp fix, idk why this crashes
// is it because the colormaps were already freed anyway?
if (!needpatchrecache)
for (i = 0; i < numwadfiles; i++)
M_AATreeIterate(wadfiles[i]->hwrcache, FreeMipmapColormap);
// now the heap don't have any 'user' pointing to our // now the heap don't have any 'user' pointing to our
// texturecache info, we can free it // texturecache info, we can free it
if (gr_textures) if (gr_textures)
@ -713,7 +713,7 @@ void HWR_GetFlat(lumpnum_t flatlumpnum)
GLMipmap_t *grmip; GLMipmap_t *grmip;
if (needpatchflush) if (needpatchflush)
W_FlushCachedPatches(); Z_FlushCachedPatches();
grmip = &HWR_GetCachedGLPatch(flatlumpnum)->mipmap; grmip = &HWR_GetCachedGLPatch(flatlumpnum)->mipmap;
@ -752,7 +752,7 @@ static void HWR_LoadMappedPatch(GLMipmap_t *grmip, GLPatch_t *gpatch)
void HWR_GetPatch(GLPatch_t *gpatch) void HWR_GetPatch(GLPatch_t *gpatch)
{ {
if (needpatchflush) if (needpatchflush)
W_FlushCachedPatches(); Z_FlushCachedPatches();
// is it in hardware cache // is it in hardware cache
if (!gpatch->mipmap.downloaded && !gpatch->mipmap.grInfo.data) if (!gpatch->mipmap.downloaded && !gpatch->mipmap.grInfo.data)
@ -782,7 +782,7 @@ void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap)
GLMipmap_t *grmip, *newmip; GLMipmap_t *grmip, *newmip;
if (needpatchflush) if (needpatchflush)
W_FlushCachedPatches(); Z_FlushCachedPatches();
if (colormap == colormaps || colormap == NULL) if (colormap == colormaps || colormap == NULL)
{ {
@ -910,7 +910,7 @@ GLPatch_t *HWR_GetPic(lumpnum_t lumpnum)
GLPatch_t *grpatch; GLPatch_t *grpatch;
if (needpatchflush) if (needpatchflush)
W_FlushCachedPatches(); Z_FlushCachedPatches();
grpatch = HWR_GetCachedGLPatch(lumpnum); grpatch = HWR_GetCachedGLPatch(lumpnum);
@ -1110,7 +1110,7 @@ void HWR_GetFadeMask(lumpnum_t fademasklumpnum)
GLMipmap_t *grmip; GLMipmap_t *grmip;
if (needpatchflush) if (needpatchflush)
W_FlushCachedPatches(); Z_FlushCachedPatches();
grmip = &HWR_GetCachedGLPatch(fademasklumpnum)->mipmap; grmip = &HWR_GetCachedGLPatch(fademasklumpnum)->mipmap;

View file

@ -98,6 +98,7 @@ void HWR_FreePolyPool(void);
// -------- // --------
void HWR_InitTextureCache(void); void HWR_InitTextureCache(void);
void HWR_FreeTextureCache(void); void HWR_FreeTextureCache(void);
void HWR_FreeColormaps(void);
void HWR_FreeExtraSubsectors(void); void HWR_FreeExtraSubsectors(void);
void HWR_GetFlat(lumpnum_t flatlumpnum); void HWR_GetFlat(lumpnum_t flatlumpnum);

View file

@ -6461,6 +6461,7 @@ void HWR_Shutdown(void)
HWR_FreeExtraSubsectors(); HWR_FreeExtraSubsectors();
HWR_FreePolyPool(); HWR_FreePolyPool();
HWR_FreeTextureCache(); HWR_FreeTextureCache();
HWR_FreeColormaps();
HWD.pfnFlushScreenTextures(); HWD.pfnFlushScreenTextures();
} }

View file

@ -857,7 +857,7 @@ void HWR_InitMD2(void)
} }
} }
// no sprite/player skin name found?!? // no sprite/player skin name found?!?
CONS_Printf("Unknown sprite/player skin %s detected in md2.dat\n", name); //CONS_Printf("Unknown sprite/player skin %s detected in md2.dat\n", name);
md2found: md2found:
// move on to next line... // move on to next line...
continue; continue;

View file

@ -334,7 +334,7 @@ static int libd_patchExists(lua_State *L)
static int libd_cachePatch(lua_State *L) static int libd_cachePatch(lua_State *L)
{ {
HUDONLY HUDONLY
LUA_PushUserdata(L, W_CachePatchName(luaL_checkstring(L, 1), PU_STATIC), META_PATCH); LUA_PushUserdata(L, W_CachePatchName(luaL_checkstring(L, 1), PU_PATCH), META_PATCH);
return 1; return 1;
} }

View file

@ -2481,6 +2481,9 @@ void M_Drawer(void)
if (currentMenu == &MessageDef) if (currentMenu == &MessageDef)
menuactive = true; menuactive = true;
if (needpatchrecache)
R_ReloadHUDGraphics();
if (menuactive) if (menuactive)
{ {
// now that's more readable with a faded background (yeah like Quake...) // now that's more readable with a faded background (yeah like Quake...)
@ -5709,7 +5712,7 @@ static void M_DrawLevelStats(void)
V_DrawCenteredString(BASEVIDWIDTH/2, 24, V_YELLOWMAP, "PAGE 2 OF 2"); V_DrawCenteredString(BASEVIDWIDTH/2, 24, V_YELLOWMAP, "PAGE 2 OF 2");
V_DrawString(72, 48, 0, va("x %d/%d", M_CountEmblems(), numemblems+numextraemblems)); V_DrawString(72, 48, 0, va("x %d/%d", M_CountEmblems(), numemblems+numextraemblems));
V_DrawScaledPatch(40, 48-4, 0, W_CachePatchName("EMBLICON", PU_STATIC)); V_DrawScaledPatch(40, 48-4, 0, W_CachePatchName("EMBLICON", PU_PATCH));
M_DrawStatsMaps(statsLocation); M_DrawStatsMaps(statsLocation);
} }

View file

@ -1424,7 +1424,6 @@ static void P_LoadRawSideDefs2(void *data)
case 606: //SoM: 4/4/2000: Just colormap transfer case 606: //SoM: 4/4/2000: Just colormap transfer
// SoM: R_CreateColormap will only create a colormap in software mode... // SoM: R_CreateColormap will only create a colormap in software mode...
// Perhaps we should just call it instead of doing the calculations here. // Perhaps we should just call it instead of doing the calculations here.
if (rendermode == render_soft || rendermode == render_none)
{ {
if (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#') if (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#')
{ {
@ -1447,11 +1446,6 @@ static void P_LoadRawSideDefs2(void *data)
else else
sd->bottomtexture = num; sd->bottomtexture = num;
} }
break;
}
#ifdef HWRENDER
else
{
// for now, full support of toptexture only // for now, full support of toptexture only
if ((msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6]) if ((msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6])
|| (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6])) || (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6]))
@ -1503,26 +1497,8 @@ static void P_LoadRawSideDefs2(void *data)
#undef ALPHA2INT #undef ALPHA2INT
#undef HEX2INT #undef HEX2INT
} }
else
{
if ((num = R_CheckTextureNumForName(msd->toptexture)) == -1)
sd->toptexture = 0;
else
sd->toptexture = num;
if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1)
sd->midtexture = 0;
else
sd->midtexture = num;
if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1)
sd->bottomtexture = 0;
else
sd->bottomtexture = num;
}
break; break;
} }
#endif
case 413: // Change music case 413: // Change music
{ {
@ -2967,6 +2943,12 @@ boolean P_SetupLevel(boolean skipprecip)
globalweather = mapheaderinfo[gamemap-1]->weather; globalweather = mapheaderinfo[gamemap-1]->weather;
#ifdef HWRENDER // not win32 only 19990829 by Kin #ifdef HWRENDER // not win32 only 19990829 by Kin
// gotta free this regardless of rendermode.
// maybe we're not in opengl anymore.......
if (extrasubsectors)
free(extrasubsectors);
extrasubsectors = NULL;
// stuff like HWR_CreatePlanePolygons is called there
if (rendermode == render_opengl) if (rendermode == render_opengl)
HWR_SetupLevel(); HWR_SetupLevel();
#endif #endif
@ -3116,7 +3098,10 @@ boolean P_SetupLevel(boolean skipprecip)
// preload graphics // preload graphics
#ifdef HWRENDER // not win32 only 19990829 by Kin #ifdef HWRENDER // not win32 only 19990829 by Kin
if (rendermode == render_opengl) if (rendermode == render_opengl)
{
HWR_PrepLevelCache(numtextures); HWR_PrepLevelCache(numtextures);
//HWR_FreeColormaps();
}
#endif #endif
P_MapEnd(); P_MapEnd();
@ -3180,6 +3165,8 @@ void HWR_SetupLevel(void)
#endif #endif
// Correct missing sidedefs & deep water trick // Correct missing sidedefs & deep water trick
HWR_CorrectSWTricks(); HWR_CorrectSWTricks();
// don't do it twice...
if (!extrasubsectors)
HWR_CreatePlanePolygons((INT32)numnodes - 1); HWR_CreatePlanePolygons((INT32)numnodes - 1);
} }
#endif #endif

View file

@ -95,8 +95,6 @@ size_t numspritelumps, max_spritelumps;
// textures // textures
INT32 numtextures = 0; // total number of textures found, INT32 numtextures = 0; // total number of textures found,
boolean needpatchflush = false;
boolean needpatchrecache = false;
// size of following tables // size of following tables
texture_t **textures = NULL; texture_t **textures = NULL;

View file

@ -96,7 +96,5 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3);
const char *R_ColormapNameForNum(INT32 num); const char *R_ColormapNameForNum(INT32 num);
extern INT32 numtextures; extern INT32 numtextures;
extern boolean needpatchflush;
extern boolean needpatchrecache;
#endif #endif

View file

@ -1353,7 +1353,7 @@ void R_InitHardwareMode(void)
void R_ReloadHUDGraphics(void) void R_ReloadHUDGraphics(void)
{ {
W_FlushCachedPatches(); Z_FlushCachedPatches();
ST_LoadGraphics(); ST_LoadGraphics();
HU_LoadGraphics(); HU_LoadGraphics();
ST_ReloadSkinFaceGraphics(); ST_ReloadSkinFaceGraphics();

View file

@ -73,8 +73,9 @@ consvar_t cv_scr_depth = {"scr_depth", "16 bits", CV_SAVE, scr_depth_cons_t, NUL
consvar_t cv_renderview = {"renderview", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_renderview = {"renderview", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
static void SCR_ChangeRenderer(void); static void SCR_ChangeRenderer(void);
static void SCR_ActuallyChangeRenderer(void);
static CV_PossibleValue_t cv_renderer_t[] = {{1, "Software"}, {2, "OpenGL"}, {0, NULL}}; static CV_PossibleValue_t cv_renderer_t[] = {{1, "Software"}, {2, "OpenGL"}, {0, NULL}};
consvar_t cv_renderer = {"renderer", "Software", CV_CALL, cv_renderer_t, SCR_ChangeRenderer, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_renderer = {"renderer", "Software", CV_SAVE|CV_CALL, cv_renderer_t, SCR_ChangeRenderer, 0, NULL, NULL, 0, 0, NULL};
static void SCR_ChangeFullscreen(void); static void SCR_ChangeFullscreen(void);
@ -376,6 +377,8 @@ void SCR_CheckDefaultMode(void)
// see note above // see note above
setmodeneeded = VID_GetModeForSize(cv_scr_width.value, cv_scr_height.value) + 1; setmodeneeded = VID_GetModeForSize(cv_scr_width.value, cv_scr_height.value) + 1;
} }
SCR_ActuallyChangeRenderer();
} }
// sets the modenum as the new default video mode to be saved in the config file // sets the modenum as the new default video mode to be saved in the config file
@ -405,12 +408,28 @@ void SCR_ChangeFullscreen(void)
#endif #endif
} }
static int target_renderer = 0;
void SCR_ActuallyChangeRenderer(void)
{
setrenderneeded = target_renderer;
// setting the same renderer twice WILL crash your game, so let's not, please
if (rendermode == setrenderneeded)
setrenderneeded = 0;
}
void SCR_ChangeRenderer(void) void SCR_ChangeRenderer(void)
{ {
setrenderneeded = 0; setrenderneeded = 0;
if (con_startup) if (con_startup)
{ {
target_renderer = cv_renderer.value;
if (M_CheckParm("-opengl"))
target_renderer = rendermode = render_opengl;
else if (M_CheckParm("-software"))
target_renderer = rendermode = render_soft;
// set cv_renderer back
if (rendermode == render_soft) if (rendermode == render_soft)
CV_StealthSetValue(&cv_renderer, 1); CV_StealthSetValue(&cv_renderer, 1);
else if (rendermode == render_opengl) else if (rendermode == render_opengl)
@ -419,13 +438,10 @@ void SCR_ChangeRenderer(void)
} }
if (cv_renderer.value == 1) if (cv_renderer.value == 1)
setrenderneeded = render_soft; target_renderer = render_soft;
else if (cv_renderer.value == 2) else if (cv_renderer.value == 2)
setrenderneeded = render_opengl; target_renderer = render_opengl;
SCR_ActuallyChangeRenderer();
// setting the same renderer twice WILL crash your game, so let's not, please
if (rendermode == setrenderneeded)
setrenderneeded = 0;
} }
boolean SCR_IsAspectCorrect(INT32 width, INT32 height) boolean SCR_IsAspectCorrect(INT32 width, INT32 height)

View file

@ -139,7 +139,6 @@ static SDL_bool borderlesswindow = SDL_FALSE;
// SDL2 vars // SDL2 vars
SDL_Window *window; SDL_Window *window;
SDL_Renderer *renderer; SDL_Renderer *renderer;
static int renderflags;
static SDL_Texture *texture; static SDL_Texture *texture;
static SDL_bool havefocus = SDL_TRUE; static SDL_bool havefocus = SDL_TRUE;
static const char *fallback_resolution_name = "Fallback"; static const char *fallback_resolution_name = "Fallback";
@ -1261,7 +1260,7 @@ void VID_PrepareModeList(void)
#endif #endif
} }
static SDL_bool Impl_CreateContext(int flags) static SDL_bool Impl_CreateContext(void)
{ {
// Renderer-specific stuff // Renderer-specific stuff
#ifdef HWRENDER #ifdef HWRENDER
@ -1280,7 +1279,7 @@ static SDL_bool Impl_CreateContext(int flags)
#endif #endif
if (rendermode == render_soft) if (rendermode == render_soft)
{ {
flags = 0; // Use this to set SDL_RENDERER_* flags now int flags = 0; // Use this to set SDL_RENDERER_* flags now
if (usesdl2soft) if (usesdl2soft)
flags |= SDL_RENDERER_SOFTWARE; flags |= SDL_RENDERER_SOFTWARE;
else if (cv_vidwait.value) else if (cv_vidwait.value)
@ -1300,10 +1299,13 @@ static SDL_bool Impl_CreateContext(int flags)
void VID_CheckRenderer(void) void VID_CheckRenderer(void)
{ {
if (dedicated)
return;
if (setrenderneeded) if (setrenderneeded)
{ {
rendermode = setrenderneeded; rendermode = setrenderneeded;
Impl_CreateContext(renderflags); Impl_CreateContext();
} }
SDLSetMode(vid.width, vid.height, USE_FULLSCREEN); SDLSetMode(vid.width, vid.height, USE_FULLSCREEN);
@ -1335,29 +1337,15 @@ INT32 VID_SetMode(INT32 modeNum)
vid.recalc = 1; vid.recalc = 1;
vid.bpp = 1; vid.bpp = 1;
if (modeNum >= 0 && modeNum < MAXWINMODES) if (modeNum < 0)
{ modeNum = 0;
if (modeNum >= MAXWINMODES)
modeNum = MAXWINMODES-1;
vid.width = windowedModes[modeNum][0]; vid.width = windowedModes[modeNum][0];
vid.height = windowedModes[modeNum][1]; vid.height = windowedModes[modeNum][1];
vid.modenum = modeNum; vid.modenum = modeNum;
}
else
{
// just set the desktop resolution as a fallback
SDL_DisplayMode mode;
SDL_GetWindowDisplayMode(window, &mode);
if (mode.w >= 2048)
{
vid.width = 1920;
vid.height = 1200;
}
else
{
vid.width = mode.w;
vid.height = mode.h;
}
vid.modenum = -1;
}
//Impl_SetWindowName("SRB2 "VERSIONSTRING); //Impl_SetWindowName("SRB2 "VERSIONSTRING);
VID_CheckRenderer(); VID_CheckRenderer();
return SDL_TRUE; return SDL_TRUE;
@ -1394,8 +1382,7 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen)
return SDL_FALSE; return SDL_FALSE;
} }
renderflags = flags; return Impl_CreateContext();
return Impl_CreateContext(flags);
} }
/* /*

View file

@ -831,7 +831,10 @@ void W_UnloadWadFile(UINT16 num)
numwadfiles--; numwadfiles--;
#ifdef HWRENDER #ifdef HWRENDER
if (rendermode != render_soft && rendermode != render_none) if (rendermode != render_soft && rendermode != render_none)
{
HWR_FreeTextureCache(); HWR_FreeTextureCache();
HWR_FreeColormaps();
}
M_AATreeFree(delwad->hwrcache); M_AATreeFree(delwad->hwrcache);
#endif #endif
if (*lumpcache) if (*lumpcache)
@ -1503,21 +1506,6 @@ void *W_CacheLumpName(const char *name, INT32 tag)
// Cache a patch into heap memory, convert the patch format as necessary // Cache a patch into heap memory, convert the patch format as necessary
// //
void W_FlushCachedPatches(void)
{
if (needpatchflush)
{
Z_FreeTag(PU_CACHE);
Z_FreeTag(PU_PATCH);
Z_FreeTag(PU_HUDGFX);
Z_FreeTag(PU_HWRPATCHINFO);
Z_FreeTag(PU_HWRPATCHCOLMIPMAP);
Z_FreeTag(PU_HWRCACHE);
Z_FreeTags(PU_HWRCACHE_UNLOCKED, PU_HWRPATCHINFO_UNLOCKED);
}
needpatchflush = false;
}
// Software-only compile cache the data without conversion // Software-only compile cache the data without conversion
#ifdef HWRENDER #ifdef HWRENDER
static inline void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) static inline void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag)
@ -1525,7 +1513,7 @@ static inline void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag)
GLPatch_t *grPatch; GLPatch_t *grPatch;
if (needpatchflush) if (needpatchflush)
W_FlushCachedPatches(); Z_FlushCachedPatches();
if (rendermode == render_soft || rendermode == render_none) if (rendermode == render_soft || rendermode == render_none)
return W_CacheLumpNumPwad(wad, lump, tag); return W_CacheLumpNumPwad(wad, lump, tag);

View file

@ -183,7 +183,6 @@ void *W_CachePatchNum(lumpnum_t lumpnum, INT32 tag); // return a patch_t
#endif #endif
void W_UnlockCachedPatch(void *patch); void W_UnlockCachedPatch(void *patch);
void W_FlushCachedPatches(void);
void W_VerifyFileMD5(UINT16 wadfilenum, const char *matchmd5); void W_VerifyFileMD5(UINT16 wadfilenum, const char *matchmd5);

View file

@ -144,6 +144,7 @@ static patch_t *interpic = NULL; // custom picture defined in map header
static boolean usetile; static boolean usetile;
boolean usebuffer = false; boolean usebuffer = false;
static boolean useinterpic; static boolean useinterpic;
static boolean safetorender = true;
static INT32 timer; static INT32 timer;
static INT32 intertic; static INT32 intertic;
@ -158,6 +159,7 @@ static void Y_CalculateTimeRaceWinners(void);
static void Y_CalculateMatchWinners(void); static void Y_CalculateMatchWinners(void);
static void Y_FollowIntermission(void); static void Y_FollowIntermission(void);
static void Y_UnloadData(void); static void Y_UnloadData(void);
static void Y_CleanupData(void);
// Stuff copy+pasted from st_stuff.c // Stuff copy+pasted from st_stuff.c
static INT32 SCX(INT32 x) static INT32 SCX(INT32 x)
@ -187,9 +189,18 @@ void Y_IntermissionDrawer(void)
if (intertype == int_none || rendermode == render_none) if (intertype == int_none || rendermode == render_none)
return; return;
if (!usebuffer) if (needpatchrecache)
{
Y_CleanupData();
R_ReloadHUDGraphics();
safetorender = false;
}
if (!usebuffer || !safetorender)
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31);
if (safetorender)
{
if (useinterpic) if (useinterpic)
V_DrawScaledPatch(0, 0, 0, interpic); V_DrawScaledPatch(0, 0, 0, interpic);
else if (!usetile) else if (!usetile)
@ -212,6 +223,7 @@ void Y_IntermissionDrawer(void)
} }
else else
V_DrawPatchFill(bgtile); V_DrawPatchFill(bgtile);
}
if (intertype == int_coop) if (intertype == int_coop)
{ {
@ -249,19 +261,22 @@ void Y_IntermissionDrawer(void)
V_DrawLevelTitle(data.coop.passedx1, 49, 0, data.coop.passed1); V_DrawLevelTitle(data.coop.passedx1, 49, 0, data.coop.passed1);
V_DrawLevelTitle(data.coop.passedx2, 49+V_LevelNameHeight(data.coop.passed2)+2, 0, data.coop.passed2); V_DrawLevelTitle(data.coop.passedx2, 49+V_LevelNameHeight(data.coop.passed2)+2, 0, data.coop.passed2);
if (mapheaderinfo[gamemap-1]->actnum) if (mapheaderinfo[gamemap-1]->actnum && safetorender)
V_DrawScaledPatch(244, 57, 0, data.coop.ttlnum); V_DrawScaledPatch(244, 57, 0, data.coop.ttlnum);
bonusy = 150; bonusy = 150;
// Total // Total
if (safetorender)
{
V_DrawScaledPatch(152, bonusy, 0, data.coop.ptotal); V_DrawScaledPatch(152, bonusy, 0, data.coop.ptotal);
V_DrawTallNum(BASEVIDWIDTH - 68, bonusy + 1, 0, data.coop.total); V_DrawTallNum(BASEVIDWIDTH - 68, bonusy + 1, 0, data.coop.total);
}
bonusy -= (3*SHORT(tallnum[0]->height)/2) + 1; bonusy -= (3*SHORT(tallnum[0]->height)/2) + 1;
// Draw bonuses // Draw bonuses
for (i = 3; i >= 0; --i) for (i = 3; i >= 0; --i)
{ {
if (data.coop.bonuses[i].display) if (data.coop.bonuses[i].display && safetorender)
{ {
V_DrawScaledPatch(152, bonusy, 0, data.coop.bonuspatches[i]); V_DrawScaledPatch(152, bonusy, 0, data.coop.bonuspatches[i]);
V_DrawTallNum(BASEVIDWIDTH - 68, bonusy + 1, 0, data.coop.bonuses[i].points); V_DrawTallNum(BASEVIDWIDTH - 68, bonusy + 1, 0, data.coop.bonuses[i].points);
@ -340,13 +355,16 @@ void Y_IntermissionDrawer(void)
} }
} }
if (safetorender)
{
V_DrawScaledPatch(152, 108, 0, data.spec.bonuspatch); V_DrawScaledPatch(152, 108, 0, data.spec.bonuspatch);
V_DrawTallNum(BASEVIDWIDTH - 68, 109, 0, data.spec.bonus.points); V_DrawTallNum(BASEVIDWIDTH - 68, 109, 0, data.spec.bonus.points);
V_DrawScaledPatch(152, 124, 0, data.spec.pscore); V_DrawScaledPatch(152, 124, 0, data.spec.pscore);
V_DrawTallNum(BASEVIDWIDTH - 68, 125, 0, data.spec.score); V_DrawTallNum(BASEVIDWIDTH - 68, 125, 0, data.spec.score);
}
// Draw continues! // Draw continues!
if (!multiplayer /* && (data.spec.continues & 0x80) */) // Always draw outside of netplay if (!multiplayer && safetorender /* && (data.spec.continues & 0x80) */) // Always draw outside of netplay
{ {
UINT8 continues = data.spec.continues & 0x7F; UINT8 continues = data.spec.continues & 0x7F;
@ -368,6 +386,7 @@ void Y_IntermissionDrawer(void)
char strtime[10]; char strtime[10];
// draw the header // draw the header
if (safetorender)
V_DrawScaledPatch(112, 2, 0, data.match.result); V_DrawScaledPatch(112, 2, 0, data.match.result);
// draw the level name // draw the level name
@ -959,6 +978,8 @@ void Y_StartIntermission(void)
I_Error("endtic is dirty"); I_Error("endtic is dirty");
#endif #endif
safetorender = true;
if (!multiplayer) if (!multiplayer)
{ {
timer = 0; timer = 0;
@ -1057,9 +1078,9 @@ void Y_StartIntermission(void)
// get act number // get act number
if (mapheaderinfo[prevmap]->actnum) if (mapheaderinfo[prevmap]->actnum)
data.coop.ttlnum = W_CachePatchName(va("TTL%.2d", mapheaderinfo[prevmap]->actnum), data.coop.ttlnum = W_CachePatchName(va("TTL%.2d", mapheaderinfo[prevmap]->actnum),
PU_STATIC); PU_PATCH);
else else
data.coop.ttlnum = W_CachePatchName("TTL01", PU_STATIC); data.coop.ttlnum = W_CachePatchName("TTL01", PU_PATCH);
// get background patches // get background patches
widebgpatch = W_CachePatchName("INTERSCW", PU_PATCH); widebgpatch = W_CachePatchName("INTERSCW", PU_PATCH);
@ -1178,7 +1199,7 @@ void Y_StartIntermission(void)
data.spec.cemerald = W_CachePatchName("GOTEMALL", PU_PATCH); data.spec.cemerald = W_CachePatchName("GOTEMALL", PU_PATCH);
data.spec.headx = 70; data.spec.headx = 70;
data.spec.nowsuper = players[consoleplayer].skin data.spec.nowsuper = players[consoleplayer].skin
? NULL : W_CachePatchName("NOWSUPER", PU_STATIC); ? NULL : W_CachePatchName("NOWSUPER", PU_PATCH);
} }
else else
{ {
@ -1835,7 +1856,8 @@ static void Y_FollowIntermission(void)
G_AfterIntermission(); G_AfterIntermission();
} }
#define UNLOAD(x) Z_ChangeTag(x, PU_CACHE); x = NULL #define UNLOAD(x) if (x) {Z_ChangeTag(x, PU_CACHE);} x = NULL;
#define CLEANUP(x) x = NULL;
// //
// Y_UnloadData // Y_UnloadData
@ -1886,5 +1908,47 @@ static void Y_UnloadData(void)
//are not handled //are not handled
break; break;
} }
}
static void Y_CleanupData(void)
{
// unload the background patches
CLEANUP(bgpatch);
CLEANUP(widebgpatch);
CLEANUP(bgtile);
CLEANUP(interpic);
switch (intertype)
{
case int_coop:
// unload the coop and single player patches
CLEANUP(data.coop.ttlnum);
CLEANUP(data.coop.bonuspatches[3]);
CLEANUP(data.coop.bonuspatches[2]);
CLEANUP(data.coop.bonuspatches[1]);
CLEANUP(data.coop.bonuspatches[0]);
CLEANUP(data.coop.ptotal);
break;
case int_spec:
// unload the special stage patches
//CLEANUP(data.spec.cemerald);
//CLEANUP(data.spec.nowsuper);
CLEANUP(data.spec.bonuspatch);
CLEANUP(data.spec.pscore);
CLEANUP(data.spec.pcontinues);
break;
case int_match:
case int_race:
CLEANUP(data.match.result);
break;
case int_ctf:
CLEANUP(data.match.blueflag);
CLEANUP(data.match.redflag);
break;
default:
//without this default,
//int_none, int_tag, int_chaos, and int_classicrace
//are not handled
break;
}
} }

View file

@ -411,6 +411,26 @@ void Z_FreeTags(INT32 lowtag, INT32 hightag)
} }
} }
// for renderer switching, free a bunch of stuff
boolean needpatchflush = false;
boolean needpatchrecache = false;
void Z_FlushCachedPatches(void)
{
if (needpatchflush)
{
Z_FreeTag(PU_CACHE);
Z_FreeTag(PU_PATCH);
Z_FreeTag(PU_HUDGFX);
Z_FreeTag(PU_HWRPATCHINFO);
Z_FreeTag(PU_HWRPATCHCOLMIPMAP);
Z_FreeTag(PU_HWRCACHE);
Z_FreeTag(PU_HWRCACHE_UNLOCKED);
Z_FreeTag(PU_HWRPATCHINFO_UNLOCKED);
}
needpatchflush = false;
}
// //
// Z_CheckMemCleanup // Z_CheckMemCleanup
// //

View file

@ -70,6 +70,11 @@ void Z_ChangeTag2(void *ptr, INT32 tag, const char *file, INT32 line);
void Z_ChangeTag2(void *ptr, INT32 tag); void Z_ChangeTag2(void *ptr, INT32 tag);
#endif #endif
// for renderer switching, free a bunch of stuff
extern boolean needpatchflush;
extern boolean needpatchrecache;
void Z_FlushCachedPatches(void);
#ifdef PARANOIA #ifdef PARANOIA
void Z_SetUser2(void *ptr, void **newuser, const char *file, INT32 line); void Z_SetUser2(void *ptr, void **newuser, const char *file, INT32 line);
#else #else