mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-30 16:00:55 +00:00
- moved the handling of ending PowerWeaponLevel2 into PlayerPawn.Tick and restored the immediate weapon switch.
This got changed because switching weapons in EndPowerup is not safe - this can be called from weapon states where the player can end up with a different weapon being active than the one running the state. The actual weapon switch has to be delayed until the state processing has ended.
This commit is contained in:
parent
af137dbb35
commit
28dab3889b
3 changed files with 24 additions and 16 deletions
|
@ -1133,22 +1133,12 @@ class PowerWeaponLevel2 : Powerup
|
||||||
Super.EndEffect();
|
Super.EndEffect();
|
||||||
if (Owner == null) return;
|
if (Owner == null) return;
|
||||||
let player = Owner.player;
|
let player = Owner.player;
|
||||||
if (player != NULL)
|
if (player != NULL && player.mo != null)
|
||||||
{
|
{
|
||||||
if (player.ReadyWeapon != NULL && player.ReadyWeapon.bPowered_Up)
|
player.mo.bWeaponLevel2Ended = true;
|
||||||
{
|
|
||||||
player.ReadyWeapon.EndPowerup ();
|
|
||||||
}
|
|
||||||
if (player.PendingWeapon != NULL && player.PendingWeapon != WP_NOCHANGE &&
|
|
||||||
player.PendingWeapon.bPowered_Up &&
|
|
||||||
player.PendingWeapon.SisterWeapon != NULL)
|
|
||||||
{
|
|
||||||
player.PendingWeapon = player.PendingWeapon.SisterWeapon;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
|
@ -848,9 +848,10 @@ class Weapon : StateProvider
|
||||||
{
|
{
|
||||||
if (player.PendingWeapon == NULL || player.PendingWeapon == WP_NOCHANGE)
|
if (player.PendingWeapon == NULL || player.PendingWeapon == WP_NOCHANGE)
|
||||||
{
|
{
|
||||||
player.PendingWeapon = SisterWeapon;
|
player.refire = 0;
|
||||||
|
player.ReadyWeapon = SisterWeapon;
|
||||||
|
player.SetPsprite(PSP_WEAPON, SisterWeapon.GetReadyState());
|
||||||
}
|
}
|
||||||
player.WeaponState |= WF_REFIRESWITCHOK;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -866,9 +867,10 @@ class Weapon : StateProvider
|
||||||
if (player.PendingWeapon == NULL || player.PendingWeapon == WP_NOCHANGE)
|
if (player.PendingWeapon == NULL || player.PendingWeapon == WP_NOCHANGE)
|
||||||
{
|
{
|
||||||
// Something went wrong. Initiate a regular weapon change.
|
// Something went wrong. Initiate a regular weapon change.
|
||||||
player.PendingWeapon = SisterWeapon;
|
player.refire = 0;
|
||||||
|
player.ReadyWeapon = SisterWeapon;
|
||||||
|
player.SetPsprite(PSP_WEAPON, SisterWeapon.GetReadyState());
|
||||||
}
|
}
|
||||||
player.WeaponState |= WF_REFIRESWITCHOK;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,7 @@ class PlayerPawn : Actor
|
||||||
flagdef NoThrustWhenInvul: PlayerFlags, 0;
|
flagdef NoThrustWhenInvul: PlayerFlags, 0;
|
||||||
flagdef CanSuperMorph: PlayerFlags, 1;
|
flagdef CanSuperMorph: PlayerFlags, 1;
|
||||||
flagdef CrouchableMorph: PlayerFlags, 2;
|
flagdef CrouchableMorph: PlayerFlags, 2;
|
||||||
|
flagdef WeaponLevel2Ended: PlayerFlags, 3;
|
||||||
|
|
||||||
Default
|
Default
|
||||||
{
|
{
|
||||||
|
@ -138,6 +139,21 @@ class PlayerPawn : Actor
|
||||||
{
|
{
|
||||||
if (health > 0) Height = FullHeight;
|
if (health > 0) Height = FullHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bWeaponLevel2Ended)
|
||||||
|
{
|
||||||
|
bWeaponLevel2Ended = false;
|
||||||
|
if (player.ReadyWeapon != NULL && player.ReadyWeapon.bPowered_Up)
|
||||||
|
{
|
||||||
|
player.ReadyWeapon.EndPowerup ();
|
||||||
|
}
|
||||||
|
if (player.PendingWeapon != NULL && player.PendingWeapon != WP_NOCHANGE &&
|
||||||
|
player.PendingWeapon.bPowered_Up &&
|
||||||
|
player.PendingWeapon.SisterWeapon != NULL)
|
||||||
|
{
|
||||||
|
player.PendingWeapon = player.PendingWeapon.SisterWeapon;
|
||||||
|
}
|
||||||
|
}
|
||||||
Super.Tick();
|
Super.Tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue