- added runtime checks for the state usage flags.

This commit is contained in:
Christoph Oelckers 2016-11-15 00:18:57 +01:00
commit 647e1399f1
4 changed files with 26 additions and 0 deletions

View file

@ -296,6 +296,16 @@ void DPSprite::SetState(FState *newstate, bool pending)
Destroy();
return;
}
if (!(newstate->UseFlags & (SUF_OVERLAY|SUF_WEAPON))) // Weapon and overlay are mostly the same, the main difference is that weapon states restrict the self pointer to class Actor.
{
auto so = FState::StaticFindStateOwner(newstate);
Printf("State %s.%d not flagged for use in overlays or weapons\n", so->TypeName.GetChars(), int(newstate - so->OwnedStates));
State = nullptr;
Destroy();
return;
}
State = newstate;
if (newstate->sprite != SPR_FIXED)