diff --git a/Doom/p_mobj.pas b/Doom/p_mobj.pas index 3422d5f2..430b03a5 100644 --- a/Doom/p_mobj.pas +++ b/Doom/p_mobj.pas @@ -287,6 +287,10 @@ implementation const MOBJ_CYCLE_LIMIT = 1000000; +var + prev_states: TDNumberList; + recursion_level: integer = 0; + //============================================================================== // P_DoSetMobjState // @@ -300,7 +304,15 @@ function P_DoSetMobjState(mobj: Pmobj_t; state: statenum_t; const runthinker: bo cycle_counter: integer; begin cycle_counter := 0; + result := true; + if recursion_level = 0 then + prev_states := TDNumberList.Create; + Inc(recursion_level); repeat + if prev_states.IndexOf(Ord(state)) > 0 then + Break; + prev_states.Add(Ord(state)); + if state = S_NULL then begin if mobj.flags_ex and MF_EX_DONOTREMOVE = 0 then // JVAL Do not remove missile @@ -309,7 +321,7 @@ function P_DoSetMobjState(mobj: Pmobj_t; state: statenum_t; const runthinker: bo P_RemoveMobj(mobj); end; result := false; - exit; + break; end; if mobj.validcount <> validcount then @@ -329,6 +341,7 @@ function P_DoSetMobjState(mobj: Pmobj_t; state: statenum_t; const runthinker: bo // Call action functions when the state is set if Assigned(st.action.acp1) and runthinker then begin + if st.params <> nil then st.params.Actor := mobj; st.action.acp2(mobj, nil); @@ -340,8 +353,9 @@ function P_DoSetMobjState(mobj: Pmobj_t; state: statenum_t; const runthinker: bo if cycle_counter > MOBJ_CYCLE_LIMIT then I_Error('P_SetMobjState(): Infinite state cycle detected in object "%s"!', [Info_GetMobjName(mobj.info)]); until mobj.tics <> 0; - - result := true; + Dec(recursion_level); + if recursion_level = 0 then + prev_states.Free; end; //============================================================================== diff --git a/Doom32.dof b/Doom32.dof index 1e2fcf84..2c638b5a 100644 --- a/Doom32.dof +++ b/Doom32.dof @@ -100,7 +100,7 @@ Conditionals=DOOM;OPTIMIZE_FOR_SPEED; DebugSourceDirs=.\Base\;F:\DelphiDoom_Release\DelphiDoom_Src\Src\Doom\ UsePackages=0 [Parameters] -RunParams=-iwad doomu.wad +RunParams=-iwad doom2.wad NineCircles_1.0.wad HostApplication= Launcher= UseLauncher=0