- fixed: Switch statement without a default jumped to the first first case label instead.

- removed placeholder code from scripted Marine.
This commit is contained in:
Christoph Oelckers 2016-11-21 22:20:25 +01:00
parent 135cfcf016
commit 3db712cd73
2 changed files with 7 additions and 9 deletions

View file

@ -8250,6 +8250,7 @@ ExpEmit FxSwitchStatement::Emit(VMFunctionBuilder *build)
} }
size_t DefaultAddress = build->Emit(OP_JMP, 0); size_t DefaultAddress = build->Emit(OP_JMP, 0);
TArray<size_t> BreakAddresses; TArray<size_t> BreakAddresses;
bool defaultset = false;
for (auto line : Content) for (auto line : Content)
{ {
@ -8270,6 +8271,7 @@ ExpEmit FxSwitchStatement::Emit(VMFunctionBuilder *build)
else else
{ {
build->BackpatchToHere(DefaultAddress); build->BackpatchToHere(DefaultAddress);
defaultset = true;
} }
break; break;
@ -8290,6 +8292,7 @@ ExpEmit FxSwitchStatement::Emit(VMFunctionBuilder *build)
{ {
build->BackpatchToHere(addr); build->BackpatchToHere(addr);
} }
if (!defaultset) build->BackpatchToHere(DefaultAddress);
Content.Clear(); Content.Clear();
Content.ShrinkToFit(); Content.ShrinkToFit();
return ExpEmit(); return ExpEmit();

View file

@ -96,6 +96,7 @@ class ScriptedMarine : Actor
PLAY F 6 BRIGHT A_M_FirePistol(1); PLAY F 6 BRIGHT A_M_FirePistol(1);
PLAY A 4 A_FaceTarget; PLAY A 4 A_FaceTarget;
PLAY A 0 A_M_Refire(0, "ShootEnd"); PLAY A 0 A_M_Refire(0, "ShootEnd");
Goto Fireloop.Pistol;
ShootEnd: ShootEnd:
PLAY A 5; PLAY A 5;
Goto See; 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 () override void Tick ()
{ {
Super.Tick (); Super.Tick ();
// Override the standard sprite, if desired // Override the standard sprite, if desired
if (SpriteOverride != 0 && sprite == GetSprite(SpawnState)) if (SpriteOverride != 0 && sprite == SpawnState.sprite)
{ {
sprite = SpriteOverride; sprite = SpriteOverride;
} }
@ -632,14 +627,14 @@ class ScriptedMarine : Actor
{ {
if (source == null) if (source == null)
{ // A valid actor class wasn't passed, so use the standard sprite { // A valid actor class wasn't passed, so use the standard sprite
SpriteOverride = sprite = GetSprite(SpawnState); SpriteOverride = sprite = SpawnState.sprite;
// Copy the standard scaling // Copy the standard scaling
Scale = Default.Scale; Scale = Default.Scale;
} }
else else
{ // Use the same sprite and scaling the passed class spawns with { // Use the same sprite and scaling the passed class spawns with
readonly<Actor> def = GetDefaultByType (source); readonly<Actor> def = GetDefaultByType (source);
SpriteOverride = sprite = GetSprite(def.SpawnState); SpriteOverride = sprite = def.SpawnState.sprite;
Scale = def.Scale; Scale = def.Scale;
} }
} }