This commit is contained in:
Christoph Oelckers 2016-10-04 18:17:32 +02:00
commit 64863d30f3
2 changed files with 24 additions and 5 deletions

View file

@ -2097,7 +2097,7 @@ void R_DrawSprite (vissprite_t *spr)
{ // seen below floor: clip top { // seen below floor: clip top
if (!spr->bIsVoxel && h > topclip) if (!spr->bIsVoxel && h > topclip)
{ {
topclip = MIN<short> (h, viewheight); topclip = short(MIN(h, viewheight));
} }
hzt = MIN(hzt, hz); hzt = MIN(hzt, hz);
} }
@ -2127,7 +2127,7 @@ void R_DrawSprite (vissprite_t *spr)
{ // seen in the middle: clip top { // seen in the middle: clip top
if (!spr->bIsVoxel && h > topclip) if (!spr->bIsVoxel && h > topclip)
{ {
topclip = MIN<short> (h, viewheight); topclip = MIN(h, viewheight);
} }
hzt = MIN(hzt, hz); hzt = MIN(hzt, hz);
} }
@ -2181,7 +2181,7 @@ void R_DrawSprite (vissprite_t *spr)
int h = xs_RoundToInt(CenterY - (hz - ViewPos.Z) * scale); int h = xs_RoundToInt(CenterY - (hz - ViewPos.Z) * scale);
if (h > topclip) if (h > topclip)
{ {
topclip = MIN<short>(h, viewheight); topclip = short(MIN(h, viewheight));
} }
} }
hzt = MIN(hzt, sclipTop); hzt = MIN(hzt, sclipTop);
@ -2204,7 +2204,7 @@ void R_DrawSprite (vissprite_t *spr)
h = (centeryfrac - FixedMul (h-viewz, scale)) >> FRACBITS; h = (centeryfrac - FixedMul (h-viewz, scale)) >> FRACBITS;
if (h > topclip) if (h > topclip)
{ {
topclip = MIN<short> (h, viewheight); topclip = short(MIN(h, viewheight));
} }
} }
#endif #endif

View file

@ -4956,6 +4956,25 @@ FxExpression *FxRuntimeStateIndex::Resolve(FCompileContext &ctx)
return this; return this;
} }
static bool VerifyJumpTarget(AActor *stateowner, FStateParamInfo *stateinfo, int index)
{
PClassActor *cls = stateowner->GetClass();
while (cls != RUNTIME_CLASS(AActor))
{
// both calling and target state need to belong to the same class.
if (cls->OwnsState(stateinfo->mCallingState))
{
return cls->OwnsState(stateinfo->mCallingState + index);
}
// We can safely assume the ParentClass is of type PClassActor
// since we stop when we see the Actor base class.
cls = static_cast<PClassActor *>(cls->ParentClass);
}
return false;
}
static int DecoHandleRuntimeState(VMFrameStack *stack, VMValue *param, int numparam, VMReturn *ret, int numret) static int DecoHandleRuntimeState(VMFrameStack *stack, VMValue *param, int numparam, VMReturn *ret, int numret)
{ {
PARAM_PROLOGUE; PARAM_PROLOGUE;
@ -4963,7 +4982,7 @@ static int DecoHandleRuntimeState(VMFrameStack *stack, VMValue *param, int numpa
PARAM_POINTER(stateinfo, FStateParamInfo); PARAM_POINTER(stateinfo, FStateParamInfo);
PARAM_INT(index); PARAM_INT(index);
if (index == 0 || !stateowner->GetClass()->OwnsState(stateinfo->mCallingState + index)) if (index == 0 || !VerifyJumpTarget(stateowner, stateinfo, index))
{ {
// Null is returned if the location was invalid which means that no jump will be performed // Null is returned if the location was invalid which means that no jump will be performed
// if used as return value // if used as return value