diff --git a/docs/rh-log.txt b/docs/rh-log.txt index fe580d7aac..f0ae4de10e 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,8 @@ +May 26, 2006 (Changes by Graf Zahl) +- Fixed: CallStateChain relied on CallingState being preserved across the + call of the state's action function. This is not the case when a missile + is being spawned and exploded right away. + May 25, 2006 - Fixed: The C code in AltSoundRenderer::CopyAndClip() did not shift the sample data enough (2 bits instead of 8), so it was super loud and aliased. diff --git a/src/thingdef_codeptr.cpp b/src/thingdef_codeptr.cpp index 4b5ed642b2..2a578ba0f3 100644 --- a/src/thingdef_codeptr.cpp +++ b/src/thingdef_codeptr.cpp @@ -107,13 +107,12 @@ bool ACustomInventory::CallStateChain (AActor *actor, FState * State) bool result = false; int counter = 0; - StateCall.State = State; - while (StateCall.State != NULL) + while (State != NULL) { // Assume success. The code pointer will set this to false if necessary StateCall.Result = true; - CallingState = StateCall.State; - StateCall.State->GetAction() (actor); + CallingState = StateCall.State = State; + State->GetAction() (actor); // collect all the results. Even one successful call signifies overall success. result |= StateCall.Result; @@ -122,16 +121,25 @@ bool ACustomInventory::CallStateChain (AActor *actor, FState * State) counter++; if (counter >= 10000) break; - if (StateCall.State == CallingState) + if (StateCall.State == State) { // Abort immediately if the state jumps to itself! - if (StateCall.State == StateCall.State->GetNextState()) return false; + if (State == State->GetNextState()) + { + StateCall.State = NULL; + return false; + } // If both variables are still the same there was no jump // so we must advance to the next state. - StateCall.State = StateCall.State->GetNextState(); + State = State->GetNextState(); + } + else + { + State = StateCall.State; } } + StateCall.State = NULL; return result; }