mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-11-10 07:12:03 +00:00
Cache colormaps everywhere to avoid memory leaks
This commit is contained in:
parent
abc479980c
commit
cd4fc40b9e
4 changed files with 29 additions and 23 deletions
|
@ -611,7 +611,7 @@ void F_CreditDrawer(void)
|
|||
|
||||
if (credits_pics[i].colorize != SKINCOLOR_NONE)
|
||||
{
|
||||
colormap = R_GetTranslationColormap(TC_RAINBOW, credits_pics[i].colorize, 0);
|
||||
colormap = R_GetTranslationColormap(TC_RAINBOW, credits_pics[i].colorize, GTC_MENUCACHE);
|
||||
sc = FRACUNIT; // quick hack so I don't have to add another field to credits_pics
|
||||
}
|
||||
|
||||
|
@ -1103,6 +1103,10 @@ void F_StartWaitingPlayers(void)
|
|||
finalecount = 0;
|
||||
|
||||
randskin = M_RandomKey(numskins);
|
||||
|
||||
if (waitcolormap)
|
||||
Z_Free(waitcolormap);
|
||||
|
||||
waitcolormap = R_GetTranslationColormap(randskin, skins[randskin].prefcolor, 0);
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
|
|
20
src/k_kart.c
20
src/k_kart.c
|
@ -6989,7 +6989,7 @@ static void K_drawKartItem(void)
|
|||
}
|
||||
|
||||
if (localcolor != SKINCOLOR_NONE)
|
||||
colmap = R_GetTranslationColormap(colormode, localcolor, 0);
|
||||
colmap = R_GetTranslationColormap(colormode, localcolor, GTC_CACHE);
|
||||
|
||||
V_DrawScaledPatch(fx, fy, V_HUDTRANS|fflags, localbg);
|
||||
|
||||
|
@ -7651,7 +7651,7 @@ static void K_drawKartSpeedometer(void)
|
|||
|
||||
static void K_drawKartBumpersOrKarma(void)
|
||||
{
|
||||
UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, stplyr->skincolor, 0);
|
||||
UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, stplyr->skincolor, GTC_CACHE);
|
||||
INT32 splitflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTOLEFT);
|
||||
INT32 fx = 0, fy = 0, fflags = 0;
|
||||
boolean flipstring = false; // same as laps, used for splitscreen
|
||||
|
@ -7859,7 +7859,7 @@ static void K_drawKartPlayerCheck(void)
|
|||
else if (x > 306)
|
||||
x = 306;
|
||||
|
||||
colormap = R_GetTranslationColormap(TC_DEFAULT, players[i].mo->color, 0);
|
||||
colormap = R_GetTranslationColormap(TC_DEFAULT, players[i].mo->color, GTC_CACHE);
|
||||
V_DrawMappedPatch(x, CHEK_Y, V_HUDTRANS|splitflags, kp_check[pnum], colormap);
|
||||
}
|
||||
}
|
||||
|
@ -8388,16 +8388,16 @@ static void K_drawKartFirstPerson(void)
|
|||
|
||||
// drift sparks!
|
||||
if ((leveltime & 1) && (stplyr->kartstuff[k_driftcharge] >= dsthree))
|
||||
colmap = R_GetTranslationColormap(TC_RAINBOW, (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))), 0);
|
||||
colmap = R_GetTranslationColormap(TC_RAINBOW, (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))), GTC_CACHE);
|
||||
else if ((leveltime & 1) && (stplyr->kartstuff[k_driftcharge] >= dstwo))
|
||||
colmap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_KETCHUP, 0);
|
||||
colmap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_KETCHUP, GTC_CACHE);
|
||||
else if ((leveltime & 1) && (stplyr->kartstuff[k_driftcharge] >= dsone))
|
||||
colmap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_SAPPHIRE, 0);
|
||||
colmap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_SAPPHIRE, GTC_CACHE);
|
||||
else
|
||||
#endif
|
||||
// invincibility/grow/shrink!
|
||||
if (stplyr->mo->colorized && stplyr->mo->color)
|
||||
colmap = R_GetTranslationColormap(TC_RAINBOW, stplyr->mo->color, 0);
|
||||
colmap = R_GetTranslationColormap(TC_RAINBOW, stplyr->mo->color, GTC_CACHE);
|
||||
}
|
||||
|
||||
V_DrawFixedPatch(x, y, scale, splitflags, kp_fpview[target], colmap);
|
||||
|
@ -8507,7 +8507,7 @@ static void K_drawInput(void)
|
|||
else
|
||||
{
|
||||
UINT8 *colormap;
|
||||
colormap = R_GetTranslationColormap(0, stplyr->skincolor, 0);
|
||||
colormap = R_GetTranslationColormap(0, stplyr->skincolor, GTC_CACHE);
|
||||
V_DrawFixedPatch(x<<FRACBITS, y<<FRACBITS, FRACUNIT, splitflags, kp_inputwheel[target], colormap);
|
||||
}
|
||||
}
|
||||
|
@ -8532,7 +8532,7 @@ static void K_drawLapStartAnim(void)
|
|||
{
|
||||
// This is an EVEN MORE insanely complicated animation.
|
||||
const UINT8 progress = 80-stplyr->kartstuff[k_lapanimation];
|
||||
UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, stplyr->skincolor, 0);
|
||||
UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, stplyr->skincolor, GTC_CACHE);
|
||||
|
||||
V_DrawFixedPatch((BASEVIDWIDTH/2 + (32*max(0, stplyr->kartstuff[k_lapanimation]-76)))*FRACUNIT,
|
||||
(48 - (32*max(0, progress-76)))*FRACUNIT,
|
||||
|
@ -8906,7 +8906,7 @@ void K_drawKartHUD(void)
|
|||
|
||||
for (c = 1; c < MAXSKINCOLORS; c++)
|
||||
{
|
||||
UINT8 *cm = R_GetTranslationColormap(TC_RAINBOW, c, 0);
|
||||
UINT8 *cm = R_GetTranslationColormap(TC_RAINBOW, c, GTC_CACHE);
|
||||
V_DrawFixedPatch(x<<FRACBITS, y<<FRACBITS, FRACUNIT>>1, 0, facewantprefix[stplyr->skin], cm);
|
||||
|
||||
x += 16;
|
||||
|
|
24
src/m_menu.c
24
src/m_menu.c
|
@ -3474,7 +3474,7 @@ static void M_DrawMapEmblems(INT32 mapnum, INT32 x, INT32 y)
|
|||
|
||||
if (emblem->collected)
|
||||
V_DrawSmallMappedPatch(x, y, 0, W_CachePatchName(M_GetEmblemPatch(emblem), PU_CACHE),
|
||||
R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_CACHE));
|
||||
R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_MENUCACHE));
|
||||
else
|
||||
V_DrawSmallScaledPatch(x, y, 0, W_CachePatchName("NEEDIT", PU_CACHE));
|
||||
|
||||
|
@ -3811,7 +3811,7 @@ static void M_DrawPauseMenu(void)
|
|||
|
||||
if (emblem->collected)
|
||||
V_DrawSmallMappedPatch(40, 44 + (i*8), 0, W_CachePatchName(M_GetEmblemPatch(emblem), PU_CACHE),
|
||||
R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_CACHE));
|
||||
R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_MENUCACHE));
|
||||
else
|
||||
V_DrawSmallScaledPatch(40, 44 + (i*8), 0, W_CachePatchName("NEEDIT", PU_CACHE));
|
||||
|
||||
|
@ -5359,7 +5359,7 @@ static void M_DrawEmblemHints(void)
|
|||
{
|
||||
collected = recommendedflags;
|
||||
V_DrawMappedPatch(12, 12+(28*j), 0, W_CachePatchName(M_GetEmblemPatch(emblem), PU_CACHE),
|
||||
R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_CACHE));
|
||||
R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_MENUCACHE));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -5702,7 +5702,7 @@ static void M_DrawLoadGameData(void)
|
|||
V_DrawScaledPatch(SP_LoadDef.x,144+8,0,W_CachePatchName(skins[savegameinfo[saveSlotSelected].skinnum].face, PU_CACHE));
|
||||
else
|
||||
{
|
||||
UINT8 *colormap = R_GetTranslationColormap(savegameinfo[saveSlotSelected].skinnum, savegameinfo[saveSlotSelected].skincolor, 0);
|
||||
UINT8 *colormap = R_GetTranslationColormap(savegameinfo[saveSlotSelected].skinnum, savegameinfo[saveSlotSelected].skincolor, GTC_MENUCACHE);
|
||||
V_DrawMappedPatch(SP_LoadDef.x,144+8,0,W_CachePatchName(skins[savegameinfo[saveSlotSelected].skinnum].face, PU_CACHE), colormap);
|
||||
}
|
||||
|
||||
|
@ -6392,7 +6392,7 @@ static void M_DrawStatsMaps(int location)
|
|||
|
||||
if (exemblem->collected)
|
||||
V_DrawSmallMappedPatch(295, y, 0, W_CachePatchName(M_GetExtraEmblemPatch(exemblem), PU_CACHE),
|
||||
R_GetTranslationColormap(TC_DEFAULT, M_GetExtraEmblemColor(exemblem), GTC_CACHE));
|
||||
R_GetTranslationColormap(TC_DEFAULT, M_GetExtraEmblemColor(exemblem), GTC_MENUCACHE));
|
||||
else
|
||||
V_DrawSmallScaledPatch(295, y, 0, W_CachePatchName("NEEDIT", PU_CACHE));
|
||||
|
||||
|
@ -6527,7 +6527,7 @@ void M_DrawTimeAttackMenu(void)
|
|||
// Character face!
|
||||
if (W_CheckNumForName(skins[cv_chooseskin.value-1].facewant) != LUMPERROR)
|
||||
{
|
||||
UINT8 *colormap = R_GetTranslationColormap(cv_chooseskin.value-1, cv_playercolor.value, 0);
|
||||
UINT8 *colormap = R_GetTranslationColormap(cv_chooseskin.value-1, cv_playercolor.value, GTC_MENUCACHE);
|
||||
V_DrawMappedPatch(BASEVIDWIDTH-x - SHORT(facewantprefix[cv_chooseskin.value-1]->width), y, 0, facewantprefix[cv_chooseskin.value-1], colormap);
|
||||
}
|
||||
|
||||
|
@ -6652,7 +6652,7 @@ void M_DrawTimeAttackMenu(void)
|
|||
|
||||
if (em->collected)
|
||||
V_DrawMappedPatch(BASEVIDWIDTH - 64 - 24, y+48, 0, W_CachePatchName(M_GetEmblemPatch(em), PU_CACHE),
|
||||
R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(em), GTC_CACHE));
|
||||
R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(em), GTC_MENUCACHE));
|
||||
else
|
||||
V_DrawScaledPatch(BASEVIDWIDTH - 64 - 24, y+48, 0, W_CachePatchName("NEEDIT", PU_CACHE));
|
||||
|
||||
|
@ -6812,7 +6812,7 @@ static boolean M_QuitTimeAttackMenu(void)
|
|||
|
||||
if (em->collected)
|
||||
V_DrawSmallMappedPatch(160+88, yHeight, 0, W_CachePatchName(M_GetEmblemPatch(em), PU_CACHE),
|
||||
R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(em), GTC_CACHE));
|
||||
R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(em), GTC_MENUCACHE));
|
||||
else
|
||||
V_DrawSmallScaledPatch(160+88, yHeight, 0, W_CachePatchName("NEEDIT", PU_CACHE));
|
||||
|
||||
|
@ -7886,7 +7886,7 @@ Update the maxplayers label...
|
|||
if (!trans && i > cv_splitplayers.value)
|
||||
trans = V_TRANSLUCENT;
|
||||
|
||||
colmap = R_GetTranslationColormap(pskin, pcol, 0);
|
||||
colmap = R_GetTranslationColormap(pskin, pcol, GTC_MENUCACHE);
|
||||
|
||||
V_DrawFixedPatch(x<<FRACBITS, y<<FRACBITS, FRACUNIT, trans, facewantprefix[pskin], colmap);
|
||||
|
||||
|
@ -8197,7 +8197,7 @@ static void M_DrawSetupMultiPlayerMenu(void)
|
|||
|
||||
statdot = W_CachePatchName("K_SDOT2", PU_CACHE); // coloured center
|
||||
if (setupm_fakecolor)
|
||||
V_DrawFixedPatch(((BASEVIDWIDTH - mx - 80) + ((speed-1)*8))<<FRACBITS, ((my+76) + ((weight-1)*8))<<FRACBITS, FRACUNIT, 0, statdot, R_GetTranslationColormap(0, setupm_fakecolor, 0));
|
||||
V_DrawFixedPatch(((BASEVIDWIDTH - mx - 80) + ((speed-1)*8))<<FRACBITS, ((my+76) + ((weight-1)*8))<<FRACBITS, FRACUNIT, 0, statdot, R_GetTranslationColormap(0, setupm_fakecolor, GTC_MENUCACHE));
|
||||
|
||||
// 2.2 color bar backported with permission
|
||||
#define charw 72
|
||||
|
@ -8267,7 +8267,7 @@ static void M_DrawSetupMultiPlayerMenu(void)
|
|||
offx = 8;
|
||||
offy = 8;
|
||||
}
|
||||
colmap = R_GetTranslationColormap(col, setupm_fakecolor, 0);
|
||||
colmap = R_GetTranslationColormap(col, setupm_fakecolor, GTC_MENUCACHE);
|
||||
V_DrawFixedPatch((x+offx)<<FRACBITS, (my+28+offy)<<FRACBITS, FRACUNIT, 0, face, colmap);
|
||||
if (scale == FRACUNIT) // bit of a hack
|
||||
V_DrawFixedPatch((x+offx)<<FRACBITS, (my+28+offy)<<FRACBITS, FRACUNIT, 0, cursor, colmap);
|
||||
|
@ -8313,7 +8313,7 @@ static void M_DrawSetupMultiPlayerMenu(void)
|
|||
// draw player sprite
|
||||
if (setupm_fakecolor) // inverse should never happen
|
||||
{
|
||||
UINT8 *colormap = R_GetTranslationColormap(setupm_fakeskin, setupm_fakecolor, 0);
|
||||
UINT8 *colormap = R_GetTranslationColormap(setupm_fakeskin, setupm_fakecolor, GTC_MENUCACHE);
|
||||
|
||||
if (skins[setupm_fakeskin].flags & SF_HIRES)
|
||||
{
|
||||
|
|
|
@ -102,6 +102,8 @@ extern lumpnum_t viewborderlump[8];
|
|||
// ------------------------------------------------
|
||||
|
||||
#define GTC_CACHE 1
|
||||
#define GTC_MENUCACHE GTC_CACHE
|
||||
//@TODO Add a separate caching mechanism for menu colormaps distinct from in-level GTC_CACHE. For now this is still preferable to memory leaks...
|
||||
|
||||
#define TC_DEFAULT -1
|
||||
#define TC_BOSS -2
|
||||
|
|
Loading…
Reference in a new issue