From 40355f6298761e82d924e9b7df0e518981bac3d7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 11 Dec 2016 13:07:25 +0100 Subject: [PATCH] - allow A_M_Refire to be called without state label because this seems to have been used in existing DECORATE mods. This way of calling it will revert to the old behavior of jumping one state forward instead of to a state label. --- src/scripting/codegeneration/codegen.cpp | 11 +++++++++++ wadsrc/static/zscript/doom/scriptedmarine.txt | 8 +++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/scripting/codegeneration/codegen.cpp b/src/scripting/codegeneration/codegen.cpp index 16025c0d0f..06cdfbd06a 100644 --- a/src/scripting/codegeneration/codegen.cpp +++ b/src/scripting/codegeneration/codegen.cpp @@ -3371,6 +3371,17 @@ FxExpression *FxCompareEq::Resolve(FCompileContext& ctx) { Promote(ctx); } + // allows comparing state labels with null pointers. + else if (left->ValueType == TypeStateLabel && right->ValueType == TypeNullPtr) + { + right = new FxTypeCast(right, TypeStateLabel, false); + SAFE_RESOLVE(right, ctx); + } + else if (right->ValueType == TypeStateLabel && left->ValueType == TypeNullPtr) + { + left = new FxTypeCast(left, TypeStateLabel, false); + SAFE_RESOLVE(left, ctx); + } else if (left->ValueType->GetRegType() == REGT_POINTER && right->ValueType->GetRegType() == REGT_POINTER) { if (left->ValueType != right->ValueType && right->ValueType != TypeNullPtr && left->ValueType != TypeNullPtr && diff --git a/wadsrc/static/zscript/doom/scriptedmarine.txt b/wadsrc/static/zscript/doom/scriptedmarine.txt index 9ecfbc4605..7428b7be35 100644 --- a/wadsrc/static/zscript/doom/scriptedmarine.txt +++ b/wadsrc/static/zscript/doom/scriptedmarine.txt @@ -282,7 +282,7 @@ class ScriptedMarine : Actor // //============================================================================ - void A_M_Refire (bool ignoremissile, statelabel jumpto) + void A_M_Refire (bool ignoremissile, statelabel jumpto = null) { if (target == null || target.health <= 0) { @@ -293,13 +293,15 @@ class ScriptedMarine : Actor return; } } - SetStateLabel (jumpto); + if (jumpto != null) SetStateLabel (jumpto); + else SetState(CurState + 1); return; } if (((ignoremissile || MissileState == null) && !CheckMeleeRange ()) || !CheckSight (target) || random[SMarineRefire]() < 4) // Small chance of stopping even when target not dead { - SetStateLabel (jumpto); + if (jumpto != null) SetStateLabel (jumpto); + else SetState(CurState + 1); } }