mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 01:01:33 +00:00
Merge branch 'blendmode-rangecheck' into 'next'
Handle invalid blend modes See merge request STJr/SRB2!1486
This commit is contained in:
commit
090e5384d5
4 changed files with 16 additions and 13 deletions
|
@ -703,13 +703,12 @@ static void HWR_RenderSkyPlane(extrasubsector_t *xsub, fixed_t fixedheight)
|
|||
|
||||
#endif //doplanes
|
||||
|
||||
FBITFIELD HWR_GetBlendModeFlag(INT32 ast)
|
||||
FBITFIELD HWR_GetBlendModeFlag(INT32 style)
|
||||
{
|
||||
switch (ast)
|
||||
switch (style)
|
||||
{
|
||||
case AST_COPY:
|
||||
case AST_OVERLAY:
|
||||
return PF_Masked;
|
||||
case AST_TRANSLUCENT:
|
||||
return PF_Translucent;
|
||||
case AST_ADD:
|
||||
return PF_Additive;
|
||||
case AST_SUBTRACT:
|
||||
|
@ -719,10 +718,8 @@ FBITFIELD HWR_GetBlendModeFlag(INT32 ast)
|
|||
case AST_MODULATE:
|
||||
return PF_Multiplicative;
|
||||
default:
|
||||
return PF_Translucent;
|
||||
return PF_Masked;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT8 HWR_GetTranstableAlpha(INT32 transtablenum)
|
||||
|
@ -748,7 +745,7 @@ UINT8 HWR_GetTranstableAlpha(INT32 transtablenum)
|
|||
|
||||
FBITFIELD HWR_SurfaceBlend(INT32 style, INT32 transtablenum, FSurfaceInfo *pSurf)
|
||||
{
|
||||
if (!transtablenum || style == AST_COPY || style == AST_OVERLAY)
|
||||
if (!transtablenum || style <= AST_COPY || style >= AST_OVERLAY)
|
||||
{
|
||||
pSurf->PolyColor.s.alpha = 0xff;
|
||||
return PF_Masked;
|
||||
|
|
|
@ -69,7 +69,7 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col
|
|||
UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap); // Let's see if this can work
|
||||
|
||||
UINT8 HWR_GetTranstableAlpha(INT32 transtablenum);
|
||||
FBITFIELD HWR_GetBlendModeFlag(INT32 ast);
|
||||
FBITFIELD HWR_GetBlendModeFlag(INT32 style);
|
||||
FBITFIELD HWR_SurfaceBlend(INT32 style, INT32 transtablenum, FSurfaceInfo *pSurf);
|
||||
FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf);
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include "doomdef.h"
|
||||
#include "fastcmp.h"
|
||||
#include "r_data.h"
|
||||
#include "r_skins.h"
|
||||
#include "p_local.h"
|
||||
#include "g_game.h"
|
||||
|
@ -654,8 +655,13 @@ static int mobj_set(lua_State *L)
|
|||
break;
|
||||
}
|
||||
case mobj_blendmode:
|
||||
mo->blendmode = (INT32)luaL_checkinteger(L, 3);
|
||||
{
|
||||
INT32 blendmode = (INT32)luaL_checkinteger(L, 3);
|
||||
if (blendmode < 0 || blendmode > AST_OVERLAY)
|
||||
return luaL_error(L, "mobj.blendmode %d out of range (0 - %d).", blendmode, AST_OVERLAY);
|
||||
mo->blendmode = blendmode;
|
||||
break;
|
||||
}
|
||||
case mobj_bnext:
|
||||
return NOSETPOS;
|
||||
case mobj_bprev:
|
||||
|
|
|
@ -342,7 +342,7 @@ UINT8 *R_GetBlendTable(int style, INT32 alphalevel)
|
|||
{
|
||||
size_t offs;
|
||||
|
||||
if (style == AST_COPY || style == AST_OVERLAY)
|
||||
if (style <= AST_COPY || style >= AST_OVERLAY)
|
||||
return NULL;
|
||||
|
||||
offs = (ClipBlendLevel(style, alphalevel) << FF_TRANSSHIFT);
|
||||
|
@ -372,7 +372,7 @@ UINT8 *R_GetBlendTable(int style, INT32 alphalevel)
|
|||
|
||||
boolean R_BlendLevelVisible(INT32 blendmode, INT32 alphalevel)
|
||||
{
|
||||
if (blendmode == AST_COPY || blendmode == AST_SUBTRACT || blendmode == AST_MODULATE || blendmode == AST_OVERLAY)
|
||||
if (blendmode <= AST_COPY || blendmode == AST_SUBTRACT || blendmode == AST_MODULATE || blendmode >= AST_OVERLAY)
|
||||
return true;
|
||||
|
||||
return (alphalevel < BlendTab_Count[BlendTab_FromStyle[blendmode]]);
|
||||
|
|
Loading…
Reference in a new issue