From 3db712cd730fe0e0f23aa56eec44cd79cb2605e7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 21 Nov 2016 22:20:25 +0100 Subject: [PATCH] - fixed: Switch statement without a default jumped to the first first case label instead. - removed placeholder code from scripted Marine. --- src/scripting/codegeneration/codegen.cpp | 3 +++ wadsrc/static/zscript/doom/scriptedmarine.txt | 13 ++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/scripting/codegeneration/codegen.cpp b/src/scripting/codegeneration/codegen.cpp index 75d49801f..701b998ca 100644 --- a/src/scripting/codegeneration/codegen.cpp +++ b/src/scripting/codegeneration/codegen.cpp @@ -8250,6 +8250,7 @@ ExpEmit FxSwitchStatement::Emit(VMFunctionBuilder *build) } size_t DefaultAddress = build->Emit(OP_JMP, 0); TArray BreakAddresses; + bool defaultset = false; for (auto line : Content) { @@ -8270,6 +8271,7 @@ ExpEmit FxSwitchStatement::Emit(VMFunctionBuilder *build) else { build->BackpatchToHere(DefaultAddress); + defaultset = true; } break; @@ -8290,6 +8292,7 @@ ExpEmit FxSwitchStatement::Emit(VMFunctionBuilder *build) { build->BackpatchToHere(addr); } + if (!defaultset) build->BackpatchToHere(DefaultAddress); Content.Clear(); Content.ShrinkToFit(); return ExpEmit(); diff --git a/wadsrc/static/zscript/doom/scriptedmarine.txt b/wadsrc/static/zscript/doom/scriptedmarine.txt index 1096f24b5..3987bc795 100644 --- a/wadsrc/static/zscript/doom/scriptedmarine.txt +++ b/wadsrc/static/zscript/doom/scriptedmarine.txt @@ -96,6 +96,7 @@ class ScriptedMarine : Actor PLAY F 6 BRIGHT A_M_FirePistol(1); PLAY A 4 A_FaceTarget; PLAY A 0 A_M_Refire(0, "ShootEnd"); + Goto Fireloop.Pistol; ShootEnd: PLAY A 5; Goto See; @@ -226,18 +227,12 @@ class ScriptedMarine : Actor // //============================================================================ - // placeholder to make it compile for the time being. - SpriteID GetSprite(State st) - { - return SpriteID(0); - } - override void Tick () { Super.Tick (); // Override the standard sprite, if desired - if (SpriteOverride != 0 && sprite == GetSprite(SpawnState)) + if (SpriteOverride != 0 && sprite == SpawnState.sprite) { sprite = SpriteOverride; } @@ -632,14 +627,14 @@ class ScriptedMarine : Actor { if (source == null) { // A valid actor class wasn't passed, so use the standard sprite - SpriteOverride = sprite = GetSprite(SpawnState); + SpriteOverride = sprite = SpawnState.sprite; // Copy the standard scaling Scale = Default.Scale; } else { // Use the same sprite and scaling the passed class spawns with readonly def = GetDefaultByType (source); - SpriteOverride = sprite = GetSprite(def.SpawnState); + SpriteOverride = sprite = def.SpawnState.sprite; Scale = def.Scale; } }