Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • STJr/SRB2
  • Sryder/SRB2
  • wolfy852/SRB2
  • Alpha2244/SRB2
  • Inuyasha/SRB2
  • yoshibot/SRB2
  • TehRealSalt/SRB2
  • PrisimaTF/SRB2
  • Hatninja/SRB2
  • SteelT/SRB2
  • james/SRB2
  • ShaderWraith/SRB2
  • SinnamonLat/SRB2
  • mazmazz_/SRB2
  • filpAM/SRB2
  • chaoloveicemdboy/SRB2
  • Whooa21/SRB2
  • Machturne/SRB2
  • Golden/SRB2
  • Tatsuru/SRB2
  • Snu/SRB2
  • Zwip-Zwap_Zapony/SRB2
  • fickleheart/SRB2
  • alphaRexJames/SRB2
  • JJK/SRB2
  • diskpoppy/SRB2
  • Hannu_Hanhi/SRB2
  • ZipperQR/SRB2
  • kays/SRB2
  • spherallic/SRB2
  • Zippy_Zolton/SRB2
  • namiishere/SRB2
  • Ors/SRB2
  • SMS_Alfredo/SRB2
  • sonic_edge/SRB2
  • lavla/SRB2
  • ashi/SRB2
  • X.organic/SRB2
  • Fafabis/SRB2
  • Meziu/SRB2
  • v-rob/SRB2
  • tertu/SRB2
  • bitten2up/SRB2
  • flarn2006/SRB2
  • Krabs/SRB2
  • clairebun/SRB2
  • Lactozilla/SRB2
  • thehackstack/SRB2
  • Spice/SRB2
  • win8linux/SRB2
  • JohnFrostFox/SRB2
  • talktoneon726/SRB2
  • Wane/SRB2
  • Lamibe/SRB2
  • spectrumuk2/srb-2
  • nerdyminer18/srb-2
  • 256nil/SRB2
  • ARJr/SRB2
  • Alam/SRB2
  • Zenya/srb-2-marathon-demos
  • Acelite/srb-2-archivedmodifications
  • MIDIMan/SRB2
  • Lach/SRB2
  • Frostiikin/bounce-tweaks
  • Hanicef/SRB2Classic
  • Jaden/SRB2
  • Tyron/SRB2
  • Astronight/SRB2
  • Mari0shi06/SRB2
  • aiire/SRB2
  • Galactice/SRB2
  • srb2-ports/srb2-dreamcast
  • sdasdas/SRB2
  • chreas/srb-2-vr
  • StarManiaKG/the-story-of-sinically-rocketing-and-botching-the-2nd
  • LoganAir/SRB2
  • NepDisk/srb-2
  • alufolie91/SRB2
  • Felicia.iso/SRB2
  • twi/SRB2
  • BarrelsOFun/SRB2
  • Speed2411/SRB2
  • Leather_Realms/SRB2
  • Ayemar/SRB2
  • Acelite/SRB2
  • VladDoc/SRB2
  • kaldrum/model-features
  • strawberryfox417/SRB2
  • Lugent/SRB2
  • Jisk/SRB2
  • Rem/SRB2
  • Refrag/SRB2
  • Henry_3230/srb-3230
  • TehPuertoRicanSpartan2/tprs-srb2
  • Leminn/srb-2-marathon-stuff
  • chromaticpipe2/SRB2
  • MiguelGustavo15/SRB2
  • Maru/srb-2-tests
  • SilicDev/SRB2
  • UnmatchedBracket/SRB2
  • HybridDog/SRB2
  • xordspar0/SRB2
  • jsjhbewfhh/SRB2
  • Fancy2209/SRB2
  • Lorsoen/SRB2
  • shindoukin/SRB2
  • GamerOfDays/SRB2
  • Craftyawesome/SRB2
  • tenshi-tensai-tennoji/SRB2
  • Scarfdudebalder/SRB2
  • luigi-budd/srb-2-fix-interplag-lockon
  • mskluesner/SRB2
  • johnpetersa19/SRB2
  • Pheazant/SRB2
  • chromaticpipe2/srb2classic
  • romoney5/SRB2
  • PAS/SRB2Classic
  • BlueStaggo/SRB2
118 results
Show changes
Commits on Source (16)
......@@ -98,5 +98,6 @@ lua_taglib.c
lua_polyobjlib.c
lua_blockmaplib.c
lua_hudlib.c
lua_colorlib.c
lua_hudlib_drawlist.c
lua_inputlib.c
......@@ -1079,7 +1079,7 @@ static inline void AM_drawPlayers(void)
p = &players[i];
if (p->skincolor > 0)
color = R_GetTranslationColormap(TC_DEFAULT, p->skincolor, GTC_CACHE)[GREENS + 8];
color = R_GetCachedTranslation(TC_DEFAULT, p->skincolor)[GREENS + 8];
AM_drawLineCharacter(player_arrow, NUMPLYRLINES, 16<<FRACBITS, p->mo->angle, color, p->mo->x, p->mo->y);
}
......
......@@ -5012,6 +5012,9 @@ struct int_const_s const INT_CONST[] = {
{"AST_OVERLAY",AST_OVERLAY},
{"AST_FOG",AST_FOG},
// Default color translation range
{"DEFAULT_STARTTRANSCOLOR", DEFAULT_STARTTRANSCOLOR},
// Render flags
{"RF_HORIZONTALFLIP",RF_HORIZONTALFLIP},
{"RF_VERTICALFLIP",RF_VERTICALFLIP},
......
......@@ -828,10 +828,10 @@ void F_IntroDrawer(void)
trans = -trans;
if (finalecount < 15)
colormap = R_GetTranslationColormap(TC_ALLWHITE, 0, GTC_CACHE);
colormap = R_GetCachedTranslation(TC_ALLWHITE, 0);
V_DrawFixedPatch(x, y, scale, 0, rockpat, colormap);
if (trans < 10)
V_DrawFixedPatch(x, y, scale, trans<<V_ALPHASHIFT, rockpat, R_GetTranslationColormap(TC_BLINK, SKINCOLOR_AQUA, GTC_CACHE));
V_DrawFixedPatch(x, y, scale, trans<<V_ALPHASHIFT, rockpat, R_GetCachedTranslation(TC_BLINK, SKINCOLOR_AQUA));
}
}
else if (intro_scenenum == 1 && intro_curtime < 5*TICRATE)
......@@ -1517,11 +1517,11 @@ void F_GameEvaluationDrawer(void)
trans = -trans;
if (finalecount < 15)
colormap[0] = R_GetTranslationColormap(TC_ALLWHITE, 0, GTC_CACHE);
colormap[0] = R_GetCachedTranslation(TC_ALLWHITE, 0);
V_DrawFixedPatch(x, y, scale, 0, rockpat, colormap[0]);
if (trans < 10)
{
colormap[1] = R_GetTranslationColormap(TC_BLINK, SKINCOLOR_AQUA, GTC_CACHE);
colormap[1] = R_GetCachedTranslation(TC_BLINK, SKINCOLOR_AQUA);
V_DrawFixedPatch(x, y, scale, trans<<V_ALPHASHIFT, rockpat, colormap[1]);
}
if (goodending)
......@@ -1536,7 +1536,7 @@ void F_GameEvaluationDrawer(void)
// if j == 0 - alternate between 0 and 1
// 1 - 1 and 2
// 2 - 2 and not rendered
V_DrawFixedPatch(x+sparkloffs[j-1][0], y+sparkloffs[j-1][1], FRACUNIT, 0, W_CachePatchName(va("ENDSPKL%.1d", (j - ((sparklloop & 1) ? 0 : 1))), PU_PATCH_LOWPRIORITY), R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_AQUA, GTC_CACHE));
V_DrawFixedPatch(x+sparkloffs[j-1][0], y+sparkloffs[j-1][1], FRACUNIT, 0, W_CachePatchName(va("ENDSPKL%.1d", (j - ((sparklloop & 1) ? 0 : 1))), PU_PATCH_LOWPRIORITY), R_GetCachedTranslation(TC_DEFAULT, SKINCOLOR_AQUA));
}
j--;
}
......@@ -1859,13 +1859,13 @@ void F_EndingDrawer(void)
{
V_DrawFill(24, 24, BASEVIDWIDTH-48, BASEVIDHEIGHT-48, 0);
V_DrawFixedPatch(x+i, y+j, FRACUNIT, 0, endegrk[0],
R_GetTranslationColormap(TC_BLINK, SKINCOLOR_BLACK, GTC_CACHE));
R_GetCachedTranslation(TC_BLINK, SKINCOLOR_BLACK));
//V_DrawScaledPatch(BASEVIDWIDTH/2, BASEVIDHEIGHT/2, 0, endbrdr[1]);
}
else if (goodending && parallaxticker == -1)
{
V_DrawFixedPatch(x+i, y+j, FRACUNIT, 0, rockpat,
R_GetTranslationColormap(TC_ALLWHITE, 0, GTC_CACHE));
R_GetCachedTranslation(TC_ALLWHITE, 0));
V_DrawScaledPatch(BASEVIDWIDTH/2, BASEVIDHEIGHT/2, 0, endbrdr[1]);
}
else
......@@ -1898,7 +1898,7 @@ void F_EndingDrawer(void)
{
INT32 scale = FRACUNIT + ((parallaxticker-10)<<7);
INT32 trans = parallaxticker>>2;
UINT8 *colormap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_JET, GTC_CACHE);
UINT8 *colormap = R_GetCachedTranslation(TC_RAINBOW, SKINCOLOR_JET);
if (parallaxticker < 10)
{
......@@ -1996,7 +1996,7 @@ void F_EndingDrawer(void)
}
if ((parallaxticker/2) > -15)
colormap[0] = R_GetTranslationColormap(TC_ALLWHITE, 0, GTC_CACHE);
colormap[0] = R_GetCachedTranslation(TC_ALLWHITE, 0);
V_DrawFixedPatch(x, y, scale, 0, rockpat, colormap[0]);
if ((parallaxticker/2) > -25)
{
......@@ -2005,19 +2005,19 @@ void F_EndingDrawer(void)
trans = -trans;
if (trans < 10)
V_DrawFixedPatch(x, y, scale, trans<<V_ALPHASHIFT, rockpat,
R_GetTranslationColormap(TC_BLINK, SKINCOLOR_AQUA, GTC_CACHE));
R_GetCachedTranslation(TC_BLINK, SKINCOLOR_AQUA));
}
if (goodending && finalecount > INFLECTIONPOINT)
{
if (finalecount < INFLECTIONPOINT+10)
V_DrawFixedPatch(x, y, scale, (finalecount-INFLECTIONPOINT)<<V_ALPHASHIFT, rockpat,
R_GetTranslationColormap(TC_BLINK, SKINCOLOR_BLACK, GTC_CACHE));
R_GetCachedTranslation(TC_BLINK, SKINCOLOR_BLACK));
}
else
{
if ((-parallaxticker/2) < -5)
colormap[1] = R_GetTranslationColormap(TC_ALLWHITE, 0, GTC_CACHE);
colormap[1] = R_GetCachedTranslation(TC_ALLWHITE, 0);
V_DrawFixedPatch(x, y, scale, 0, endegrk[0], colormap[1]);
......@@ -2050,7 +2050,7 @@ void F_EndingDrawer(void)
scale += (parallaxticker-4)<<5;
if (goodending)
colormap = R_GetTranslationColormap(players[consoleplayer].skin, players[consoleplayer].skincolor, GTC_CACHE);
colormap = R_GetCachedTranslation(players[consoleplayer].skin, players[consoleplayer].skincolor);
if ((frame = ((parallaxticker & 1) ? 1 : 0) + (parallaxticker/TICRATE)) < 3)
V_DrawFixedPatch(x, y, scale, 0, endfwrk[frame], colormap);
......@@ -2134,7 +2134,7 @@ void F_EndingDrawer(void)
break;
}
colormap = R_GetTranslationColormap(TC_DEFAULT, col, GTC_CACHE);
colormap = R_GetCachedTranslation(TC_DEFAULT, col);
j = (sparklloop & 1) ? 2 : 3;
while (j)
......@@ -2755,8 +2755,8 @@ void F_TitleScreenDrawer(void)
if (39-finalecount > 0)
{
whitefade = (9 - (39-finalecount))<<V_ALPHASHIFT;
whitecol[0] = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_SUPERGOLD3, GTC_CACHE);
whitecol[1] = R_GetTranslationColormap(TC_ALLWHITE, 0, GTC_CACHE);
whitecol[0] = R_GetCachedTranslation(TC_RAINBOW, SKINCOLOR_SUPERGOLD3);
whitecol[1] = R_GetCachedTranslation(TC_ALLWHITE, 0);
}
}
......@@ -3578,7 +3578,7 @@ void F_StartContinue(void)
contskins[0] = &skins[players[consoleplayer].skin];
cont_spr2[0][0] = P_GetSkinSprite2(contskins[0], SPR2_CNT1, NULL);
cont_spr2[0][2] = contskins[0]->contangle & 7;
contcolormaps[0] = R_GetTranslationColormap(players[consoleplayer].skin, players[consoleplayer].skincolor, GTC_CACHE);
contcolormaps[0] = R_GetCachedTranslation(players[consoleplayer].skin, players[consoleplayer].skincolor);
cont_spr2[0][4] = contskins[0]->sprites[cont_spr2[0][0]].numframes;
cont_spr2[0][5] = max(1, contskins[0]->contspeed);
......@@ -3594,7 +3594,7 @@ void F_StartContinue(void)
contskins[1] = &skins[players[secondplaya].skin];
cont_spr2[1][0] = P_GetSkinSprite2(contskins[1], SPR2_CNT4, NULL);
cont_spr2[1][2] = (contskins[1]->contangle >> 3) & 7;
contcolormaps[1] = R_GetTranslationColormap(players[secondplaya].skin, players[secondplaya].skincolor, GTC_CACHE);
contcolormaps[1] = R_GetCachedTranslation(players[secondplaya].skin, players[secondplaya].skincolor);
cont_spr2[1][4] = contskins[1]->sprites[cont_spr2[1][0]].numframes;
if (cont_spr2[1][0] == SPR2_CNT4)
cont_spr2[1][5] = 4; // sorry, this one is hardcoded
......
......@@ -585,126 +585,217 @@ static GLMapTexture_t *gl_textures; // For all textures
static GLMapTexture_t *gl_flats; // For all (texture) flats, as normal flats don't need to be cached
boolean gl_maptexturesloaded = false;
void HWR_FreeTextureData(patch_t *patch)
static GLColormap_t **texColormapList;
static UINT32 numTexColormaps;
static void InsertColormapIntoList(GLColormap_t *colormap)
{
GLPatch_t *grPatch;
UINT32 index = 0;
if (!patch || !patch->hardware)
return;
if (numTexColormaps)
{
// Find spot to insert this colormap
for (; index < numTexColormaps; index++)
{
if (texColormapList[index] == NULL)
break;
}
grPatch = patch->hardware;
// None found, so extend the list
if (index == numTexColormaps)
numTexColormaps += 16;
if (vid.glstate == VID_GL_LIBRARY_LOADED)
HWD.pfnDeleteTexture(grPatch->mipmap);
if (grPatch->mipmap->data)
Z_Free(grPatch->mipmap->data);
texColormapList = realloc(texColormapList, sizeof(*texColormapList) * numTexColormaps);
for (UINT32 i = index + 1; i < numTexColormaps; i++)
texColormapList[i] = NULL;
}
else
{
numTexColormaps = 16;
texColormapList = calloc(numTexColormaps, sizeof(*texColormapList));
}
texColormapList[index] = colormap;
colormap->index = index;
}
void HWR_FreeTexture(patch_t *patch)
GLColormap_t *HWR_NewColormap(const UINT8 *source)
{
if (!patch)
return;
for (UINT32 index = 0; index < numTexColormaps; index++)
{
GLColormap_t *colormap = texColormapList[index];
if (colormap && colormap->source == source)
return colormap;
}
if (patch->hardware)
GLColormap_t *colormap = Z_Malloc(sizeof(GLColormap_t), PU_HWRPATCHCOLMIPMAP, NULL);
colormap->source = source;
M_Memcpy(colormap->data, source, 256 * sizeof(UINT8));
InsertColormapIntoList(colormap);
return colormap;
}
static void MarkColormap(GLColormap_t *colormap)
{
colormap->index = UINT32_MAX;
}
static void FreeMarkedColormaps(void)
{
for (UINT32 index = 0; index < numTexColormaps; index++)
{
GLPatch_t *grPatch = patch->hardware;
GLColormap_t *colormap = texColormapList[index];
HWR_FreeTextureColormaps(patch);
if (colormap && colormap->index == UINT32_MAX)
{
texColormapList[index] = NULL;
Z_Free(colormap);
}
}
}
if (grPatch->mipmap)
static void FreeByColormap(GLMipmap_t *mipmap, const UINT8 *colormap)
{
GLMipmap_t *cur = mipmap->nextcolormap;
while (cur)
{
if (!cur->colormap || cur->colormap->source != colormap)
{
HWR_FreeTextureData(patch);
Z_Free(grPatch->mipmap);
cur = cur->nextcolormap;
continue;
}
Z_Free(patch->hardware);
MarkColormap(cur->colormap);
// Set the first colormap to the one that comes after it.
mipmap->nextcolormap = cur->nextcolormap;
// Free image data from memory.
if (cur->data)
Z_Free(cur->data);
if (vid.glstate == VID_GL_LIBRARY_LOADED)
HWD.pfnDeleteTexture(cur);
// Free the old colormap mipmap from memory.
free(cur);
cur = mipmap->nextcolormap;
}
patch->hardware = NULL;
FreeMarkedColormaps();
}
// Called by HWR_FreePatchCache.
void HWR_FreeTextureColormaps(patch_t *patch)
static boolean FreeColormapsCallback(void *mem, const void *data)
{
GLPatch_t *pat;
// The patch must be valid, obviously
if (!patch)
return;
pat = patch->hardware;
if (!pat)
return;
patch_t *patch = (patch_t *)mem;
GLPatch_t *grPatch = (GLPatch_t *)(patch->hardware);
if (grPatch && grPatch->mipmap)
FreeByColormap(grPatch->mipmap, (const UINT8 *)data);
return false;
}
// The mipmap must be valid, obviously
while (pat->mipmap)
void HWR_FreeTexturesByColormap(const UINT8 *source)
{
for (UINT32 index = 0; index < numTexColormaps; index++)
{
// Confusing at first, but pat->mipmap->nextcolormap
// at the beginning of the loop is the first colormap
// from the linked list of colormaps.
GLMipmap_t *next = NULL;
GLColormap_t *colormap = texColormapList[index];
// No mipmap in this patch, break out of the loop.
if (!pat->mipmap)
if (colormap && colormap->source == source)
{
Z_IterateTags(PU_PATCH, PU_PATCH_ROTATED, FreeColormapsCallback, colormap->source);
Z_IterateTags(PU_SPRITE, PU_HUDGFX, FreeColormapsCallback, colormap->source);
MarkColormap(colormap);
break;
}
}
FreeMarkedColormaps();
}
static void FreeTextureData(GLMipmap_t *mipmap)
{
if (vid.glstate == VID_GL_LIBRARY_LOADED)
HWD.pfnDeleteTexture(mipmap);
if (mipmap->data)
Z_Free(mipmap->data);
Z_Free(mipmap);
}
// No colormap mipmaps either.
if (!pat->mipmap->nextcolormap)
static void FreeColormapMipmaps(GLMipmap_t *mipmap)
{
while (true)
{
if (!mipmap->nextcolormap)
break;
GLMipmap_t *cur = mipmap->nextcolormap;
// Set the first colormap to the one that comes after it.
next = pat->mipmap->nextcolormap;
pat->mipmap->nextcolormap = next->nextcolormap;
mipmap->nextcolormap = cur->nextcolormap;
// Free image data from memory.
if (next->data)
Z_Free(next->data);
if (next->colormap)
Z_Free(next->colormap);
next->data = NULL;
next->colormap = NULL;
HWD.pfnDeleteTexture(next);
if (cur->data)
Z_Free(cur->data);
if (cur->colormap)
MarkColormap(cur->colormap);
if (vid.glstate == VID_GL_LIBRARY_LOADED)
HWD.pfnDeleteTexture(cur);
// Free the old colormap mipmap from memory.
free(next);
free(cur);
}
}
static boolean FreeTextureCallback(void *mem)
void HWR_FreeTextureFromPatch(patch_t *patch)
{
patch_t *patch = (patch_t *)mem;
HWR_FreeTexture(patch);
return false;
if (!patch)
return;
if (patch->hardware)
{
GLPatch_t *grPatch = patch->hardware;
if (grPatch->mipmap)
{
FreeColormapMipmaps(grPatch->mipmap);
FreeTextureData(grPatch->mipmap);
}
Z_Free(patch->hardware);
}
patch->hardware = NULL;
FreeMarkedColormaps();
}
static boolean FreeColormapsCallback(void *mem)
static boolean FreeTextureCallback(void *mem, const void *data)
{
(void)data;
patch_t *patch = (patch_t *)mem;
HWR_FreeTextureColormaps(patch);
HWR_FreeTextureFromPatch(patch);
return false;
}
static void HWR_FreePatchCache(boolean freeall)
static void HWR_FreePatchCache(void)
{
boolean (*callback)(void *mem) = FreeTextureCallback;
if (!freeall)
callback = FreeColormapsCallback;
Z_IterateTags(PU_PATCH, PU_PATCH_ROTATED, FreeTextureCallback, NULL);
Z_IterateTags(PU_SPRITE, PU_HUDGFX, FreeTextureCallback, NULL);
Z_IterateTags(PU_PATCH, PU_PATCH_ROTATED, callback);
Z_IterateTags(PU_SPRITE, PU_HUDGFX, callback);
free(texColormapList);
texColormapList = NULL;
numTexColormaps = 0;
}
// free all textures after each level
void HWR_ClearAllTextures(void)
{
HWD.pfnClearMipMapCache(); // free references to the textures
HWR_FreePatchCache(true);
}
void HWR_FreeColormapCache(void)
{
HWR_FreePatchCache(false);
HWR_FreePatchCache();
}
void HWR_InitMapTextures(void)
......@@ -753,7 +844,7 @@ void HWR_LoadMapTextures(size_t pnumtextures)
gl_textures = calloc(gl_numtextures, sizeof(*gl_textures));
gl_flats = calloc(gl_numtextures, sizeof(*gl_flats));
if ((gl_textures == NULL) || (gl_flats == NULL))
if (gl_textures == NULL || gl_flats == NULL)
I_Error("HWR_LoadMapTextures: ran out of memory for OpenGL textures");
gl_maptexturesloaded = true;
......@@ -1002,7 +1093,6 @@ void HWR_GetPatch(patch_t *patch)
Patch_CreateGL(patch);
HWR_LoadPatchMipmap(patch, ((GLPatch_t *)patch->hardware)->mipmap);
}
// -------------------+
// HWR_GetMappedPatch : Same as HWR_GetPatch for sprite color
// -------------------+
......@@ -1040,20 +1130,14 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap)
}
}
// not found, create it!
// If we are here, the sprite with the current colormap is not already in hardware memory
//BP: WARNING: don't free it manually without clearing the cache of harware renderer
// (it have a liste of mipmap)
// this malloc is cleared in HWR_FreeColormapCache
// (...) unfortunately z_malloc fragment alot the memory :(so malloc is better
// If we are here, the sprite with the current colormap is not already in hardware memory
newMipmap = calloc(1, sizeof (*newMipmap));
if (newMipmap == NULL)
I_Error("%s: Out of memory", "HWR_GetMappedPatch");
grMipmap->nextcolormap = newMipmap;
newMipmap->colormap = Z_Calloc(sizeof(*newMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL);
newMipmap->colormap->source = colormap;
M_Memcpy(newMipmap->colormap->data, colormap, 256 * sizeof(UINT8));
newMipmap->colormap = HWR_NewColormap(colormap);
HWR_LoadPatchMipmap(patch, newMipmap);
}
......
......@@ -44,6 +44,7 @@ struct GLColormap_s
{
const UINT8 *source;
UINT8 data[256];
UINT32 index;
};
typedef struct GLColormap_s GLColormap_t;
......
......@@ -120,15 +120,15 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap);
void HWR_GetFadeMask(lumpnum_t fademasklumpnum);
patch_t *HWR_GetPic(lumpnum_t lumpnum);
GLColormap_t *HWR_NewColormap(const UINT8 *source);
void HWR_FreeTexturesByColormap(const UINT8 *source);
GLMapTexture_t *HWR_GetTexture(INT32 tex);
void HWR_GetLevelFlat(levelflat_t *levelflat);
void HWR_GetRawFlat(lumpnum_t flatlumpnum);
void HWR_FreeTexture(patch_t *patch);
void HWR_FreeTextureData(patch_t *patch);
void HWR_FreeTextureColormaps(patch_t *patch);
void HWR_FreeTextureFromPatch(patch_t *patch);
void HWR_ClearAllTextures(void);
void HWR_FreeColormapCache(void);
void HWR_UnlockCachedPatch(GLPatch_t *gpatch);
void HWR_SetPalette(RGBA_t *palette);
......
......@@ -5421,33 +5421,33 @@ static void HWR_ProjectSprite(mobj_t *thing)
if ((vis->mobj->flags & (MF_ENEMY|MF_BOSS)) && (vis->mobj->flags2 & MF2_FRET) && !(vis->mobj->flags & MF_GRENADEBOUNCE) && (leveltime & 1)) // Bosses "flash"
{
if (vis->mobj->type == MT_CYBRAKDEMON || vis->mobj->colorized)
vis->colormap = R_GetTranslationColormap(TC_ALLWHITE, 0, GTC_CACHE);
vis->colormap = R_GetCachedTranslation(TC_ALLWHITE, 0);
else if (vis->mobj->type == MT_METALSONIC_BATTLE)
vis->colormap = R_GetTranslationColormap(TC_METALSONIC, 0, GTC_CACHE);
vis->colormap = R_GetCachedTranslation(TC_METALSONIC, 0);
else
vis->colormap = R_GetTranslationColormap(TC_BOSS, vis->color, GTC_CACHE);
vis->colormap = R_GetCachedTranslation(TC_BOSS, vis->color);
}
else if (vis->color)
{
// New colormap stuff for skins Tails 06-07-2002
if (thing->colorized)
vis->colormap = R_GetTranslationColormap(TC_RAINBOW, vis->color, GTC_CACHE);
vis->colormap = R_GetCachedTranslation(TC_RAINBOW, vis->color);
else if (thing->player && thing->player->dashmode >= DASHMODE_THRESHOLD
&& (thing->player->charflags & SF_DASHMODE)
&& ((leveltime/2) & 1))
{
if (thing->player->charflags & SF_MACHINE)
vis->colormap = R_GetTranslationColormap(TC_DASHMODE, 0, GTC_CACHE);
vis->colormap = R_GetCachedTranslation(TC_DASHMODE, 0);
else
vis->colormap = R_GetTranslationColormap(TC_RAINBOW, vis->color, GTC_CACHE);
vis->colormap = R_GetCachedTranslation(TC_RAINBOW, vis->color);
}
else if (thing->skin && thing->sprite == SPR_PLAY) // This thing is a player!
{
size_t skinnum = (skin_t*)thing->skin-skins;
vis->colormap = R_GetTranslationColormap((INT32)skinnum, vis->color, GTC_CACHE);
vis->colormap = R_GetCachedTranslation((INT32)skinnum, vis->color);
}
else
vis->colormap = R_GetTranslationColormap(TC_DEFAULT, vis->color ? vis->color : SKINCOLOR_CYAN, GTC_CACHE);
vis->colormap = R_GetCachedTranslation(TC_DEFAULT, vis->color ? vis->color : SKINCOLOR_CYAN);
}
else
vis->colormap = NULL;
......
......@@ -1120,19 +1120,12 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendpatch, INT32 ski
// If here, the blended texture has not been created
// So we create it
//BP: WARNING: don't free it manually without clearing the cache of harware renderer
// (it have a liste of mipmap)
// this malloc is cleared in HWR_FreeColormapCache
// (...) unfortunately z_malloc fragment alot the memory :(so malloc is better
newMipmap = calloc(1, sizeof (*newMipmap));
if (newMipmap == NULL)
I_Error("%s: Out of memory", "HWR_GetBlendedTexture");
grMipmap->nextcolormap = newMipmap;
newMipmap->colormap = Z_Calloc(sizeof(*newMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL);
newMipmap->colormap->source = colormap;
M_Memcpy(newMipmap->colormap->data, colormap, 256 * sizeof(UINT8));
newMipmap->colormap = HWR_NewColormap(colormap);
HWR_CreateBlendedTexture(patch, blendpatch, newMipmap, skinnum, color);
......@@ -1140,9 +1133,6 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendpatch, INT32 ski
Z_ChangeTag(newMipmap->data, PU_HWRMODELTEXTURE_UNLOCKED);
}
#define NORMALFOG 0x00000000
#define FADEFOG 0x19000000
static boolean HWR_AllowModel(mobj_t *mobj)
{
// Signpost overlay. Not needed.
......
......@@ -2219,12 +2219,12 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I
{
if (supercheck)
{
colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo->color, GTC_CACHE);
colormap = R_GetCachedTranslation(players[tab[i].num].skin, players[tab[i].num].mo->color);
V_DrawSmallMappedPatch (x, y-4, 0, superprefix[players[tab[i].num].skin], colormap);
}
else
{
colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo ? players[tab[i].num].mo->color : tab[i].color, GTC_CACHE);
colormap = R_GetCachedTranslation(players[tab[i].num].skin, players[tab[i].num].mo ? players[tab[i].num].mo->color : tab[i].color);
if (greycheck)
V_DrawSmallTranslucentMappedPatch (x, y-4, V_80TRANS, faceprefix[players[tab[i].num].skin], colormap);
else
......@@ -2363,12 +2363,12 @@ static void HU_Draw32TeamTabRankings(playersort_t *tab, INT32 whiteplayer)
if (supercheck)
{
colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo ? players[tab[i].num].mo->color : tab[i].color, GTC_CACHE);
colormap = R_GetCachedTranslation(players[tab[i].num].skin, players[tab[i].num].mo ? players[tab[i].num].mo->color : tab[i].color);
V_DrawFixedPatch(x*FRACUNIT, y*FRACUNIT, FRACUNIT/4, 0, superprefix[players[tab[i].num].skin], colormap);
}
else
{
colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo ? players[tab[i].num].mo->color : tab[i].color, GTC_CACHE);
colormap = R_GetCachedTranslation(players[tab[i].num].skin, players[tab[i].num].mo ? players[tab[i].num].mo->color : tab[i].color);
if (players[tab[i].num].spectator || players[tab[i].num].playerstate == PST_DEAD)
V_DrawFixedPatch(x*FRACUNIT, y*FRACUNIT, FRACUNIT/4, V_HUDTRANSHALF, faceprefix[players[tab[i].num].skin], colormap);
else
......@@ -2488,12 +2488,12 @@ void HU_DrawTeamTabRankings(playersort_t *tab, INT32 whiteplayer)
if (supercheck)
{
colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo ? players[tab[i].num].mo->color : tab[i].color, GTC_CACHE);
colormap = R_GetCachedTranslation(players[tab[i].num].skin, players[tab[i].num].mo ? players[tab[i].num].mo->color : tab[i].color);
V_DrawSmallMappedPatch (x, y-4, 0, superprefix[players[tab[i].num].skin], colormap);
}
else
{
colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo ? players[tab[i].num].mo->color : tab[i].color, GTC_CACHE);
colormap = R_GetCachedTranslation(players[tab[i].num].skin, players[tab[i].num].mo ? players[tab[i].num].mo->color : tab[i].color);
if (greycheck)
V_DrawSmallTranslucentMappedPatch (x, y-4, V_80TRANS, faceprefix[players[tab[i].num].skin], colormap);
else
......@@ -2579,12 +2579,12 @@ void HU_DrawDualTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scoreline
{
if (supercheck)
{
colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo ? players[tab[i].num].mo->color : tab[i].color, GTC_CACHE);
colormap = R_GetCachedTranslation(players[tab[i].num].skin, players[tab[i].num].mo ? players[tab[i].num].mo->color : tab[i].color);
V_DrawSmallMappedPatch (x, y-4, 0, superprefix[players[tab[i].num].skin], colormap);
}
else
{
colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo ? players[tab[i].num].mo->color : tab[i].color, GTC_CACHE);
colormap = R_GetCachedTranslation(players[tab[i].num].skin, players[tab[i].num].mo ? players[tab[i].num].mo->color : tab[i].color);
if (greycheck)
V_DrawSmallTranslucentMappedPatch (x, y-4, V_80TRANS, faceprefix[players[tab[i].num].skin], colormap);
else
......@@ -2690,12 +2690,12 @@ static void HU_Draw32TabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scor
{
if (supercheck)
{
colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo ? players[tab[i].num].mo->color : tab[i].color, GTC_CACHE);
colormap = R_GetCachedTranslation(players[tab[i].num].skin, players[tab[i].num].mo ? players[tab[i].num].mo->color : tab[i].color);
V_DrawFixedPatch(x*FRACUNIT, y*FRACUNIT, FRACUNIT/4, 0, superprefix[players[tab[i].num].skin], colormap);
}
else
{
colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo ? players[tab[i].num].mo->color : tab[i].color, GTC_CACHE);
colormap = R_GetCachedTranslation(players[tab[i].num].skin, players[tab[i].num].mo ? players[tab[i].num].mo->color : tab[i].color);
if (greycheck)
V_DrawFixedPatch(x*FRACUNIT, (y)*FRACUNIT, FRACUNIT/4, V_HUDTRANSHALF, faceprefix[players[tab[i].num].skin], colormap);
else
......
......@@ -214,6 +214,9 @@ static const struct {
{META_HUDINFO, "hudinfo_t"},
{META_PATCH, "patch_t"},
{META_COLORMAP, "colormap"},
{META_TRANSLATION, "translation"},
{META_EXTRACOLORMAP,"extracolormap_t"},
{META_LIGHTTABLE, "lighttable_t"},
{META_CAMERA, "camera_t"},
{META_ACTION, "action"},
......@@ -1997,6 +2000,26 @@ static int lib_pCeilingzAtPos(lua_State *L)
return 1;
}
static int lib_pGetSectorColormapAt(lua_State *L)
{
sector_t *sector = NULL;
if (!lua_isnone(L, 1) && lua_isuserdata(L, 1))
sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR));
fixed_t x = luaL_checkfixed(L, 2);
fixed_t y = luaL_checkfixed(L, 3);
fixed_t z = luaL_checkfixed(L, 4);
INLEVEL
if (!sector)
return LUA_ErrInvalid(L, "sector_t");
extracolormap_t *exc;
if (sector)
exc = P_GetColormapFromSectorAt(sector, x, y, z);
else
exc = P_GetSectorColormapAt(x, y, z);
LUA_PushUserdata(L, exc, META_EXTRACOLORMAP);
return 1;
}
static int lib_pDoSpring(lua_State *L)
{
mobj_t *spring = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
......@@ -4185,6 +4208,7 @@ static luaL_Reg lib[] = {
{"P_RadiusAttack",lib_pRadiusAttack},
{"P_FloorzAtPos",lib_pFloorzAtPos},
{"P_CeilingzAtPos",lib_pCeilingzAtPos},
{"P_GetSectorColormapAt",lib_pGetSectorColormapAt},
{"P_DoSpring",lib_pDoSpring},
{"P_TryCameraMove", lib_pTryCameraMove},
{"P_TeleportCameraMove", lib_pTeleportCameraMove},
......
This diff is collapsed.
......@@ -263,22 +263,11 @@ static int hudinfo_num(lua_State *L)
return 1;
}
static int colormap_get(lua_State *L)
{
const UINT8 *colormap = *((UINT8 **)luaL_checkudata(L, 1, META_COLORMAP));
UINT32 i = luaL_checkinteger(L, 2);
if (i >= 256)
return luaL_error(L, "colormap index %d out of range (0 - %d)", i, 255);
lua_pushinteger(L, colormap[i]);
return 1;
}
static int patch_get(lua_State *L)
{
patch_t *patch = *((patch_t **)luaL_checkudata(L, 1, META_PATCH));
enum patch field = luaL_checkoption(L, 2, NULL, patch_opt);
// patches are invalidated when switching renderers
if (!patch) {
if (field == patch_valid) {
lua_pushboolean(L, 0);
......@@ -656,7 +645,7 @@ static int libd_draw(lua_State *L)
return LUA_ErrInvalid(L, "patch_t");
flags = luaL_optinteger(L, 4, 0);
if (!lua_isnoneornil(L, 5))
colormap = *((UINT8 **)luaL_checkudata(L, 5, META_COLORMAP));
colormap = LUA_CheckColormap(L, 5);
flags &= ~V_PARAMMASK; // Don't let crashes happen.
......@@ -690,7 +679,7 @@ static int libd_drawScaled(lua_State *L)
return LUA_ErrInvalid(L, "patch_t");
flags = luaL_optinteger(L, 5, 0);
if (!lua_isnoneornil(L, 6))
colormap = *((UINT8 **)luaL_checkudata(L, 6, META_COLORMAP));
colormap = LUA_CheckColormap(L, 6);
flags &= ~V_PARAMMASK; // Don't let crashes happen.
......@@ -725,7 +714,7 @@ static int libd_drawStretched(lua_State *L)
patch = *((patch_t **)luaL_checkudata(L, 5, META_PATCH));
flags = luaL_optinteger(L, 6, 0);
if (!lua_isnoneornil(L, 7))
colormap = *((UINT8 **)luaL_checkudata(L, 7, META_COLORMAP));
colormap = LUA_CheckColormap(L, 7);
flags &= ~V_PARAMMASK; // Don't let crashes happen.
......@@ -760,7 +749,7 @@ static int libd_drawCropped(lua_State *L)
patch = *((patch_t **)luaL_checkudata(L, 5, META_PATCH));
flags = luaL_checkinteger(L, 6);
if (!lua_isnoneornil(L, 7))
colormap = *((UINT8 **)luaL_checkudata(L, 7, META_COLORMAP));
colormap = LUA_CheckColormap(L, 7);
sx = luaL_checkinteger(L, 8);
if (sx < 0) // Don't crash. Now, we could do "x-=sx*FRACUNIT; sx=0;" here...
return luaL_error(L, "negative crop sx");
......@@ -979,9 +968,9 @@ static int libd_drawNameTag(lua_State *L)
basecolor = luaL_optinteger(L, 5, SKINCOLOR_BLUE);
outlinecolor = luaL_optinteger(L, 6, SKINCOLOR_ORANGE);
if (basecolor != SKINCOLOR_NONE)
basecolormap = R_GetTranslationColormap(TC_DEFAULT, basecolor, GTC_CACHE);
basecolormap = R_GetCachedTranslation(TC_DEFAULT, basecolor);
if (outlinecolor != SKINCOLOR_NONE)
outlinecolormap = R_GetTranslationColormap(TC_DEFAULT, outlinecolor, GTC_CACHE);
outlinecolormap = R_GetCachedTranslation(TC_DEFAULT, outlinecolor);
flags &= ~V_PARAMMASK; // Don't let crashes happen.
......@@ -1021,9 +1010,9 @@ static int libd_drawScaledNameTag(lua_State *L)
basecolor = luaL_optinteger(L, 6, SKINCOLOR_BLUE);
outlinecolor = luaL_optinteger(L, 7, SKINCOLOR_ORANGE);
if (basecolor != SKINCOLOR_NONE)
basecolormap = R_GetTranslationColormap(TC_DEFAULT, basecolor, GTC_CACHE);
basecolormap = R_GetCachedTranslation(TC_DEFAULT, basecolor);
if (outlinecolor != SKINCOLOR_NONE)
outlinecolormap = R_GetTranslationColormap(TC_DEFAULT, outlinecolor, GTC_CACHE);
outlinecolormap = R_GetCachedTranslation(TC_DEFAULT, outlinecolor);
flags &= ~V_PARAMMASK; // Don't let crashes happen.
......@@ -1134,9 +1123,8 @@ static int libd_getColormap(lua_State *L)
}
// all was successful above, now we generate the colormap at last!
colormap = R_GetTranslationColormap(skinnum, color, GTC_CACHE);
LUA_PushUserdata(L, colormap, META_COLORMAP); // push as META_COLORMAP userdata, specifically for patches to use!
colormap = R_GetCachedTranslation(skinnum, color);
LUA_PushUserdata(L, colormap, META_TRANSLATION); // push as META_TRANSLATION userdata, specifically for patches to use!
return 1;
}
......@@ -1147,7 +1135,7 @@ static int libd_getStringColormap(lua_State *L)
HUDONLY
colormap = V_GetStringColormap(flags & V_CHARCOLORMASK);
if (colormap) {
LUA_PushUserdata(L, colormap, META_COLORMAP); // push as META_COLORMAP userdata, specifically for patches to use!
LUA_PushUserdata(L, colormap, META_TRANSLATION); // push as META_TRANSLATION userdata, specifically for patches to use!
return 1;
}
return 0;
......@@ -1431,11 +1419,6 @@ int LUA_HudLib(lua_State *L)
lua_setmetatable(L, -2);
lua_setglobal(L, "hudinfo");
luaL_newmetatable(L, META_COLORMAP);
lua_pushcfunction(L, colormap_get);
lua_setfield(L, -2, "__index");
lua_pop(L,1);
luaL_newmetatable(L, META_PATCH);
lua_pushcfunction(L, patch_get);
lua_setfield(L, -2, "__index");
......
......@@ -81,9 +81,13 @@ extern boolean mousegrabbedbylua;
#define META_BBOX "BOUNDING_BOX"
#define META_COLORMAP "COLORMAP"
#define META_TRANSLATION "TRANSLATION"
#define META_EXTRACOLORMAP "EXTRACOLORMAP_T"
#define META_LIGHTTABLE "LIGHTTABLE_T"
#define META_HUDINFO "HUDINFO_T*"
#define META_PATCH "PATCH_T*"
#define META_COLORMAP "COLORMAP"
#define META_CAMERA "CAMERA_T*"
#define META_ACTION "ACTIONF_T*"
......@@ -112,4 +116,5 @@ int LUA_TagLib(lua_State *L);
int LUA_PolyObjLib(lua_State *L);
int LUA_BlockmapLib(lua_State *L);
int LUA_HudLib(lua_State *L);
int LUA_ColorLib(lua_State *L);
int LUA_InputLib(lua_State *L);
......@@ -49,13 +49,14 @@ enum sector_e {
sector_ffloors,
sector_fslope,
sector_cslope,
sector_extracolormap,
sector_flags,
sector_specialflags,
sector_damagetype,
sector_triggertag,
sector_triggerer,
sector_friction,
sector_gravity,
sector_gravity
};
static const char *const sector_opt[] = {
......@@ -79,6 +80,7 @@ static const char *const sector_opt[] = {
"ffloors",
"f_slope",
"c_slope",
"extra_colormap",
"flags",
"specialflags",
"damagetype",
......@@ -669,6 +671,9 @@ static int sector_get(lua_State *L)
case sector_cslope: // c_slope
LUA_PushUserdata(L, sector->c_slope, META_SLOPE);
return 1;
case sector_extracolormap: // extra_colormap
LUA_PushUserdata(L, sector->extra_colormap, META_EXTRACOLORMAP);
return 1;
case sector_flags: // flags
lua_pushinteger(L, sector->flags);
return 1;
......@@ -717,6 +722,7 @@ static int sector_set(lua_State *L)
case sector_ffloors: // ffloors
case sector_fslope: // f_slope
case sector_cslope: // c_slope
case sector_extracolormap: // extra_colormap
case sector_friction: // friction
default:
return luaL_error(L, "sector_t field " LUA_QS " cannot be set.", sector_opt[field]);
......
......@@ -58,6 +58,7 @@ static lua_CFunction liblist[] = {
LUA_PolyObjLib, // polyobj_t
LUA_BlockmapLib, // blockmap stuff
LUA_HudLib, // HUD stuff
LUA_ColorLib, // general color functions and colormaps
LUA_InputLib, // inputs
NULL
};
......
......@@ -98,6 +98,8 @@ void LUA_InvalidateLevel(void);
void LUA_InvalidateMapthings(void);
void LUA_InvalidatePlayer(player_t *player);
UINT8* LUA_CheckColormap(lua_State *L, int ud);
// Console wrapper
void COM_Lua_f(void);
......
......@@ -4281,7 +4281,7 @@ static void M_DrawMapEmblems(INT32 mapnum, INT32 x, INT32 y, boolean norecordatt
if (emblem->collected)
V_DrawSmallMappedPatch(x, y, 0, W_CachePatchName(M_GetEmblemPatch(emblem, false), PU_PATCH),
R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_CACHE));
R_GetCachedTranslation(TC_DEFAULT, M_GetEmblemColor(emblem)));
else
V_DrawSmallScaledPatch(x, y, 0, W_CachePatchName("NEEDIT", PU_PATCH));
......@@ -4829,7 +4829,7 @@ static void M_DrawPauseMenu(void)
if (emblem->collected)
V_DrawSmallMappedPatch(40, 44 + (i*8), 0, W_CachePatchName(M_GetEmblemPatch(emblem, false), PU_PATCH),
R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_CACHE));
R_GetCachedTranslation(TC_DEFAULT, M_GetEmblemColor(emblem)));
else
V_DrawSmallScaledPatch(40, 44 + (i*8), 0, W_CachePatchName("NEEDIT", PU_PATCH));
......@@ -5963,7 +5963,7 @@ static void M_DrawNightsAttackBackground(void)
static patch_t *ntssupersonic[2];
static void M_DrawNightsAttackSuperSonic(void)
{
const UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_YELLOW, GTC_CACHE);
const UINT8 *colormap = R_GetCachedTranslation(TC_DEFAULT, SKINCOLOR_YELLOW);
INT32 timer = FixedInt(ntsatkdrawtimer/4) % 2;
angle_t fa = (FixedAngle((FixedInt(ntsatkdrawtimer * 4) % 360)<<FRACBITS)>>ANGLETOFINESHIFT) & FINEMASK;
V_DrawFixedPatch(235<<FRACBITS, (120<<FRACBITS) - (8*FINESINE(fa)), FRACUNIT, 0, ntssupersonic[timer], colormap);
......@@ -7601,7 +7601,7 @@ static void M_DrawEmblemHints(void)
{
collected = V_GREENMAP;
V_DrawMappedPatch(x, y+4, 0, W_CachePatchName(M_GetEmblemPatch(emblem, false), PU_PATCH),
R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_CACHE));
R_GetCachedTranslation(TC_DEFAULT, M_GetEmblemColor(emblem)));
}
else
{
......@@ -7818,7 +7818,7 @@ static void M_DrawSoundTest(void)
{
if (i == frame[2])
{
UINT8 *colmap = R_GetTranslationColormap(TC_RAINBOW, frame[3], GTC_CACHE);
UINT8 *colmap = R_GetCachedTranslation(TC_RAINBOW, frame[3]);
V_DrawFixedPatch(x, y + (frame[1]<<FRACBITS), FRACUNIT/2, 0, st_launchpad[frame[1]+1], colmap);
}
else
......@@ -8588,7 +8588,7 @@ static void M_DrawLoadGameData(void)
sprdef = &charbotskin->sprites[SPR2_SIGN];
if (!sprdef->numframes)
goto skipbot;
colormap = R_GetTranslationColormap(savegameinfo[savetodraw].botskin-1, charbotskin->prefcolor, GTC_CACHE);
colormap = R_GetCachedTranslation(savegameinfo[savetodraw].botskin-1, charbotskin->prefcolor);
sprframe = &sprdef->spriteframes[0];
patch = W_CachePatchNum(sprframe->lumppat[0], PU_PATCH);
......@@ -8606,7 +8606,7 @@ skipbot:
if (!charskin) // shut up compiler
goto skipsign;
sprdef = &charskin->sprites[SPR2_SIGN];
colormap = R_GetTranslationColormap(savegameinfo[savetodraw].skinnum, charskin->prefcolor, GTC_CACHE);
colormap = R_GetCachedTranslation(savegameinfo[savetodraw].skinnum, charskin->prefcolor);
if (!sprdef->numframes)
goto skipsign;
sprframe = &sprdef->spriteframes[0];
......@@ -9413,7 +9413,7 @@ static void M_DrawSetupChoosePlayerMenu(void)
col = skincolors[charskin->prefcolor].invcolor;
// Make the translation colormap
colormap = R_GetTranslationColormap(TC_DEFAULT, col, GTC_CACHE);
colormap = R_GetCachedTranslation(TC_DEFAULT, col);
// Don't render the title map
hidetitlemap = true;
......@@ -9489,8 +9489,8 @@ static void M_DrawSetupChoosePlayerMenu(void)
{
V_DrawNameTag(
x, y, V_CENTERNAMETAG, FRACUNIT,
R_GetTranslationColormap(TC_DEFAULT, curtextcolor, GTC_CACHE),
R_GetTranslationColormap(TC_DEFAULT, curoutlinecolor, GTC_CACHE),
R_GetCachedTranslation(TC_DEFAULT, curtextcolor),
R_GetCachedTranslation(TC_DEFAULT, curoutlinecolor),
curtext
);
}
......@@ -9522,8 +9522,8 @@ static void M_DrawSetupChoosePlayerMenu(void)
{
V_DrawNameTag(
x, y, V_CENTERNAMETAG, FRACUNIT,
R_GetTranslationColormap(TC_DEFAULT, prevtextcolor, GTC_CACHE),
R_GetTranslationColormap(TC_DEFAULT, prevoutlinecolor, GTC_CACHE),
R_GetCachedTranslation(TC_DEFAULT, prevtextcolor),
R_GetCachedTranslation(TC_DEFAULT, prevoutlinecolor),
prevtext
);
}
......@@ -9552,8 +9552,8 @@ static void M_DrawSetupChoosePlayerMenu(void)
{
V_DrawNameTag(
x, y, V_CENTERNAMETAG, FRACUNIT,
R_GetTranslationColormap(TC_DEFAULT, nexttextcolor, GTC_CACHE),
R_GetTranslationColormap(TC_DEFAULT, nextoutlinecolor, GTC_CACHE),
R_GetCachedTranslation(TC_DEFAULT, nexttextcolor),
R_GetCachedTranslation(TC_DEFAULT, nextoutlinecolor),
nexttext
);
}
......@@ -9732,7 +9732,7 @@ static void M_DrawStatsMaps(int location)
if (exemblem->collected)
V_DrawSmallMappedPatch(292, y, 0, W_CachePatchName(M_GetExtraEmblemPatch(exemblem, false), PU_PATCH),
R_GetTranslationColormap(TC_DEFAULT, M_GetExtraEmblemColor(exemblem), GTC_CACHE));
R_GetCachedTranslation(TC_DEFAULT, M_GetExtraEmblemColor(exemblem)));
else
V_DrawSmallScaledPatch(292, y, 0, W_CachePatchName("NEEDIT", PU_PATCH));
......@@ -10039,7 +10039,7 @@ void M_DrawTimeAttackMenu(void)
if (em->collected)
V_DrawSmallMappedPatch(104+76+empatx, yHeight+lsheadingheight/2+empaty, 0, empatch,
R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(em), GTC_CACHE));
R_GetCachedTranslation(TC_DEFAULT, M_GetEmblemColor(em)));
else
V_DrawSmallScaledPatch(104+76, yHeight+lsheadingheight/2, 0, W_CachePatchName("NEEDITL", PU_PATCH));
......@@ -10323,7 +10323,7 @@ void M_DrawNightsAttackMenu(void)
if (em->collected)
V_DrawSmallMappedPatch(xpos, yHeight+lsheadingheight/2, 0, W_CachePatchName(M_GetEmblemPatch(em, false), PU_PATCH),
R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(em), GTC_CACHE));
R_GetCachedTranslation(TC_DEFAULT, M_GetEmblemColor(em)));
else
V_DrawSmallScaledPatch(xpos, yHeight+lsheadingheight/2, 0, W_CachePatchName("NEEDIT", PU_PATCH));
......@@ -12026,7 +12026,7 @@ static void M_DrawSetupMultiPlayerMenu(void)
goto faildraw;
// ok, draw player sprite for sure now
colormap = R_GetTranslationColormap(setupm_fakeskin, setupm_fakecolor->color, GTC_CACHE);
colormap = R_GetCachedTranslation(setupm_fakeskin, setupm_fakecolor->color);
if (multi_frame >= sprdef->numframes)
multi_frame = 0;
......
......@@ -2804,3 +2804,17 @@ boolean M_IsStringEmpty(const char *s)
return true;
}
// Rounds off floating numbers and checks for 0 - 255 bounds
int M_RoundUp(double number)
{
if (number > 255.0l)
return 255;
if (number < 0.0l)
return 0;
if ((int)number <= (int)(number - 0.5f))
return (int)number + 1;
return (int)number;
}
......@@ -112,6 +112,9 @@ boolean M_IsStringEmpty(const char *s);
// counting bits, for weapon ammo code, usually
FUNCMATH UINT8 M_CountBits(UINT32 num, UINT8 size);
// Rounds off floating numbers and checks for 0 - 255 bounds
int M_RoundUp(double number);
#include "w_wad.h"
extern char configfile[MAX_WADPATH];
......