From 522a940ccf06d99ac8cf22717d4bc6e7ab86cd83 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 7 Feb 2013 20:29:48 +0000 Subject: [PATCH] - In P_SetSafeFlash(), check the requested state against every actor when Dehacked moves the flash to some other class's states instead of just assuming it's good. SVN r4066 (trunk) --- src/g_doom/a_doomweaps.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/g_doom/a_doomweaps.cpp b/src/g_doom/a_doomweaps.cpp index 642c319ec7..0063e72c9c 100644 --- a/src/g_doom/a_doomweaps.cpp +++ b/src/g_doom/a_doomweaps.cpp @@ -308,7 +308,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CloseShotgun2) // //------------------------------------------------------------------------------------ -void P_SetSafeFlash(AWeapon * weapon, player_t * player, FState * flashstate, int index) +void P_SetSafeFlash(AWeapon *weapon, player_t *player, FState *flashstate, int index) { const PClass * cls = weapon->GetClass(); @@ -337,9 +337,13 @@ void P_SetSafeFlash(AWeapon * weapon, player_t * player, FState * flashstate, in } // if we get here the state doesn't seem to belong to any class in the inheritance chain // This can happen with Dehacked if the flash states are remapped. - // The only way to check this would be to go through all Dehacked modifiable actors and - // find the correct one. - // For now let's assume that it will work. + // The only way to check this would be to go through all Dehacked modifiable actors, convert + // their states into a single flat array and find the correct one. + // Rather than that, just check to make sure it belongs to something. + if (FState::StaticFindStateOwner(flashstate + index) == NULL) + { // Invalid state. With no index offset, it should at least be valid. + index = 0; + } P_SetPsprite (player, ps_flash, flashstate + index); }