Merge branch 'fix-1183' into 'next'

Fix #1183

Closes #1183

See merge request STJr/SRB2!2282
This commit is contained in:
Lactozilla 2024-02-06 21:54:27 +00:00
commit 7724fafa0b
5 changed files with 31 additions and 23 deletions

View file

@ -5514,7 +5514,10 @@ static void HWR_ProjectSprite(mobj_t *thing)
translation = thing->translation;
//Hurdler: 25/04/2000: now support colormap in hardware mode
vis->colormap = R_GetTranslationForThing(vis->mobj, color, translation);
if ((thing->flags2 & MF2_LINKDRAW) && thing->tracer)
vis->colormap = R_GetTranslationForThing(thing->tracer, color, translation);
else
vis->colormap = R_GetTranslationForThing(thing, color, translation);
// set top/bottom coords
vis->gzt = gzt;

View file

@ -130,7 +130,7 @@ static colorcache_t **translationtablecache[TT_CACHE_SIZE] = {NULL};
boolean skincolor_modified[MAXSKINCOLORS];
static INT32 SkinToCacheIndex(INT32 translation)
INT32 R_SkinTranslationToCacheIndex(INT32 translation)
{
switch (translation)
{
@ -557,7 +557,7 @@ UINT8* R_GetTranslationColormap(INT32 skinnum, skincolornum_t color, UINT8 flags
else if (skinnum <= TC_DEFAULT)
{
// Do default translation
index = SkinToCacheIndex(skinnum);
index = R_SkinTranslationToCacheIndex(skinnum);
}
else
I_Error("Invalid translation %d", skinnum);

View file

@ -114,6 +114,8 @@ enum
TC_DEFAULT
};
INT32 R_SkinTranslationToCacheIndex(INT32 translation);
// Amount of colors in the palette
#define NUM_PALETTE_ENTRIES 256

View file

@ -770,6 +770,22 @@ UINT8 *R_GetTranslationForThing(mobj_t *mobj, skincolornum_t color, UINT16 trans
if (is_player) // This thing is a player!
skinnum = ((skin_t*)mobj->skin)->skinnum;
if (color != SKINCOLOR_NONE)
{
// New colormap stuff for skins Tails 06-07-2002
if (mobj->colorized)
skinnum = TC_RAINBOW;
else if (mobj->player && mobj->player->dashmode >= DASHMODE_THRESHOLD
&& (mobj->player->charflags & SF_DASHMODE)
&& ((leveltime/2) & 1))
{
if (mobj->player->charflags & SF_MACHINE)
skinnum = TC_DASHMODE;
else
skinnum = TC_RAINBOW;
}
}
if (R_ThingIsFlashing(mobj)) // Bosses "flash"
{
if (mobj->type == MT_CYBRAKDEMON || mobj->colorized)
@ -786,22 +802,7 @@ UINT8 *R_GetTranslationForThing(mobj_t *mobj, skincolornum_t color, UINT16 trans
return tr;
}
else if (color != SKINCOLOR_NONE)
{
// New colormap stuff for skins Tails 06-07-2002
if (mobj->colorized)
return R_GetTranslationColormap(TC_RAINBOW, color, GTC_CACHE);
else if (mobj->player && mobj->player->dashmode >= DASHMODE_THRESHOLD
&& (mobj->player->charflags & SF_DASHMODE)
&& ((leveltime/2) & 1))
{
if (mobj->player->charflags & SF_MACHINE)
return R_GetTranslationColormap(TC_DASHMODE, 0, GTC_CACHE);
else
return R_GetTranslationColormap(TC_RAINBOW, color, GTC_CACHE);
}
else
return R_GetTranslationColormap(skinnum, color, GTC_CACHE);
}
return R_GetTranslationColormap(skinnum, color, GTC_CACHE);
else if (mobj->sprite == SPR_PLAY) // Looks like a player, but doesn't have a color? Get rid of green sonic syndrome.
return R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_BLUE, GTC_CACHE);

View file

@ -1126,17 +1126,19 @@ UINT8 *R_GetTranslationRemap(int id, skincolornum_t skincolor, INT32 skinnum)
if (!tr->skincolor_remaps)
Z_Calloc(sizeof(*tr->skincolor_remaps) * TT_CACHE_SIZE, PU_LEVEL, &tr->skincolor_remaps);
if (!tr->skincolor_remaps[skinnum])
tr->skincolor_remaps[skinnum] = Z_Calloc(NUM_PALETTE_ENTRIES * MAXSKINCOLORS, PU_LEVEL, NULL);
INT32 index = R_SkinTranslationToCacheIndex(skinnum);
colorcache_t *cache = tr->skincolor_remaps[skinnum][skincolor];
if (!tr->skincolor_remaps[index])
tr->skincolor_remaps[index] = Z_Calloc(NUM_PALETTE_ENTRIES * (MAXSKINCOLORS - 1), PU_LEVEL, NULL);
colorcache_t *cache = tr->skincolor_remaps[index][skincolor - 1];
if (!cache)
{
cache = Z_Calloc(sizeof(colorcache_t), PU_LEVEL, NULL);
R_ApplyTranslationRemap(tr, cache->colors, skincolor, skinnum);
tr->skincolor_remaps[skinnum][skincolor] = cache;
tr->skincolor_remaps[index][skincolor - 1] = cache;
}
return cache->colors;