- implement limits for state loops to prevent infinite state freezes

This commit is contained in:
Rachael Alexanderson 2025-06-06 08:49:08 -04:00 committed by Rachael Alexanderson
commit 6b2b8a198f
2 changed files with 18 additions and 0 deletions

View file

@ -874,9 +874,17 @@ bool AActor::SetState (FState *newstate, bool nofunction)
if (debugfile && player && (player->cheats & CF_PREDICTING))
fprintf (debugfile, "for pl %d: SetState while predicting!\n", Level->PlayerNum(player));
int statelooplimit = 300000;
auto oldstate = state;
do
{
if (!(--statelooplimit))
{
Printf(TEXTCOLOR_RED "Infinite state loop in Actor '%s' state '%s'\n", GetClass()->TypeName.GetChars(), FState::StaticGetStateName(state).GetChars());
state = nullptr;
Destroy();
return false;
}
if (newstate == NULL)
{
state = NULL;