Fixed A_Changemodel crash from invalid modeldef names

- Invalid modeldef names no longer result in a crash

https://forum.zdoom.org/viewtopic.php?t=76810
This commit is contained in:
Shiny Metagross 2022-11-30 09:31:09 -07:00 committed by Christoph Oelckers
parent 6cf3dc045f
commit 169139c22c

View file

@ -5123,6 +5123,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_ChangeModel)
if (self == nullptr)
ACTION_RETURN_BOOL(false);
else if (modeldef != NAME_None && PClass::FindClass(modeldef.GetChars()) == nullptr)
{
Printf("Attempt to pass invalid modeldef name %s in %s.", modeldef.GetChars(), self->GetCharacterName());
ACTION_RETURN_BOOL(false);
}
else if (modelindex < 0)
{
Printf("Attempt to pass invalid model index %d in %s, index must be non-negative.", modelindex, self->GetCharacterName());