Handle player state is P_SetMobjState
ran into another case where P_SetMobjState
was called on a player, seemingly caused by an addon, but i haven't been bothering to dig into this. that said, i've started to question why we even split these functions into two in the first place, despite the fact that we know at the calling point which function we should use.
for context, bugs regarding calling the wrong state functions is something i've seen and fixed in the past. they're most easily discovered with a debug build, since they have a sanity check that verifies that the callee is calling the right function, and triggers an error if it's not. while they have gotten increasingly more rare over time, they still happen since the design itself forces the callee to keep in mind if the mobj corresponds to a player or not, which is just an unnecessary bug vector.
so, to fix this entire bug vector and prevent it from ever happening again, this patch merges these two functions so P_SetMobjState
can be called on any mobj, regardless if it's a player mobj or not. we do this by just replacing the sanity check with a actual check that calls P_SetPlayerMobjState
if it's a player mobj, making it impossible to get it wrong on the callee side.