mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-02-07 16:31:07 +00:00
The ReadyWeapon is now assumed to not be null
This commit is contained in:
parent
8668719bbc
commit
f14a840777
3 changed files with 39 additions and 38 deletions
|
@ -142,12 +142,8 @@ DPSprite::DPSprite(player_t *owner, AInventory *caller, int id)
|
||||||
if (Next && Next->ID == ID && ID != 0)
|
if (Next && Next->ID == ID && ID != 0)
|
||||||
Next->Destroy(); // Replace it.
|
Next->Destroy(); // Replace it.
|
||||||
|
|
||||||
if (ID == PSP_WEAPON || ID == PSP_FLASH || (ID < PSP_TARGETCENTER && Caller->IsKindOf(RUNTIME_CLASS(AWeapon))))
|
if (Caller->IsKindOf(RUNTIME_CLASS(AWeapon)))
|
||||||
{
|
Flags = (PSPF_ADDWEAPON|PSPF_ADDBOB);
|
||||||
Flags |= PSPF_ADDBOB;
|
|
||||||
if (ID != PSP_WEAPON)
|
|
||||||
Flags |= PSPF_ADDWEAPON;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
|
@ -181,9 +177,36 @@ DPSprite *player_t::FindPSprite(int layer)
|
||||||
|
|
||||||
DPSprite *player_t::GetPSprite(PSPLayers layer)
|
DPSprite *player_t::GetPSprite(PSPLayers layer)
|
||||||
{
|
{
|
||||||
|
assert(ReadyWeapon != nullptr);
|
||||||
|
|
||||||
|
AInventory *oldcaller;
|
||||||
DPSprite *pspr = FindPSprite(layer);
|
DPSprite *pspr = FindPSprite(layer);
|
||||||
if (pspr == nullptr)
|
if (pspr == nullptr)
|
||||||
|
{
|
||||||
pspr = new DPSprite(this, ReadyWeapon, layer);
|
pspr = new DPSprite(this, ReadyWeapon, layer);
|
||||||
|
oldcaller = nullptr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
oldcaller = pspr->Caller;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Always update the caller here in case we switched weapon
|
||||||
|
// or if the layer was being used by an inventory item before.
|
||||||
|
pspr->Caller = ReadyWeapon;
|
||||||
|
|
||||||
|
if (ReadyWeapon != oldcaller)
|
||||||
|
{ // Only change the flags if this layer was created now or if we updated the caller.
|
||||||
|
if (layer != PSP_FLASH)
|
||||||
|
{ // Only the flash layer should follow the weapon.
|
||||||
|
pspr->Flags &= ~PSPF_ADDWEAPON;
|
||||||
|
|
||||||
|
if (layer != PSP_WEAPON)
|
||||||
|
{ // [RH] Don't bob the targeter.
|
||||||
|
pspr->Flags &= ~PSPF_ADDBOB;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return pspr;
|
return pspr;
|
||||||
}
|
}
|
||||||
|
@ -230,10 +253,6 @@ void DPSprite::SetState(FState *newstate, bool pending)
|
||||||
WF_USER1OK | WF_USER2OK | WF_USER3OK | WF_USER4OK);
|
WF_USER1OK | WF_USER2OK | WF_USER3OK | WF_USER4OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special handling for the old hardcoded layers.
|
|
||||||
if (ID == PSP_WEAPON || ID == PSP_FLASH || ID >= PSP_TARGETCENTER)
|
|
||||||
Caller = Owner->ReadyWeapon;
|
|
||||||
|
|
||||||
processPending = pending;
|
processPending = pending;
|
||||||
|
|
||||||
do
|
do
|
||||||
|
@ -259,7 +278,7 @@ void DPSprite::SetState(FState *newstate, bool pending)
|
||||||
|
|
||||||
Tics = newstate->GetTics(); // could be 0
|
Tics = newstate->GetTics(); // could be 0
|
||||||
|
|
||||||
if ((ID == PSP_WEAPON || ID == PSP_FLASH || ID >= PSP_TARGETCENTER) || Caller->IsKindOf(RUNTIME_CLASS(AWeapon)))
|
if (Caller->IsKindOf(RUNTIME_CLASS(AWeapon)))
|
||||||
{ // The targeter layers are affected by this too.
|
{ // The targeter layers are affected by this too.
|
||||||
if (sv_fastweapons == 2 && ID == PSP_WEAPON)
|
if (sv_fastweapons == 2 && ID == PSP_WEAPON)
|
||||||
Tics = newstate->ActionFunc == nullptr ? 0 : 1;
|
Tics = newstate->ActionFunc == nullptr ? 0 : 1;
|
||||||
|
@ -1282,35 +1301,26 @@ void P_SetupPsprites(player_t *player, bool startweaponup)
|
||||||
|
|
||||||
void player_t::TickPSprites()
|
void player_t::TickPSprites()
|
||||||
{
|
{
|
||||||
bool noweapon = (ReadyWeapon == nullptr && (health > 0 || mo->DamageType != NAME_Fire));
|
|
||||||
|
|
||||||
DPSprite *pspr = psprites;
|
DPSprite *pspr = psprites;
|
||||||
while (pspr)
|
while (pspr)
|
||||||
{
|
{
|
||||||
// Destroy the psprite if it's from a weapon that isn't currently selected by the player
|
// Destroy the psprite if it's from a weapon that isn't currently selected by the player
|
||||||
// or if it's from an inventory item that the player no longer owns.
|
// or if it's from an inventory item that the player no longer owns.
|
||||||
// Exclude the old hardcoded layers from this check.
|
if ((pspr->Caller == nullptr ||
|
||||||
if (!(pspr->ID == PSP_WEAPON || pspr->ID == PSP_FLASH || pspr->ID >= PSP_TARGETCENTER) &&
|
(pspr->Caller->Owner != pspr->Owner->mo) ||
|
||||||
(pspr->Caller == nullptr ||
|
(pspr->Caller->IsKindOf(RUNTIME_CLASS(AWeapon)) && pspr->Caller != pspr->Owner->ReadyWeapon)))
|
||||||
(pspr->Caller->IsKindOf(RUNTIME_CLASS(AWeapon)) && pspr->Caller != pspr->Owner->ReadyWeapon) ||
|
|
||||||
(pspr->Caller->Owner != pspr->Owner->mo)))
|
|
||||||
{
|
{
|
||||||
pspr->Destroy();
|
pspr->Destroy();
|
||||||
}
|
}
|
||||||
else if (!((pspr->ID == PSP_WEAPON || pspr->ID == PSP_FLASH || pspr->ID >= PSP_TARGETCENTER) && noweapon))
|
else
|
||||||
{
|
{
|
||||||
pspr->Tick();
|
pspr->Tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (noweapon && (pspr->ID == PSP_WEAPON || pspr->ID == PSP_FLASH))
|
|
||||||
{ // Special treatment to destroy both the flash and weapon layers.
|
|
||||||
pspr->Destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
pspr = pspr->Next;
|
pspr = pspr->Next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (noweapon)
|
if (ReadyWeapon == nullptr && (health > 0 || mo->DamageType != NAME_Fire))
|
||||||
{
|
{
|
||||||
if (PendingWeapon != WP_NOCHANGE)
|
if (PendingWeapon != WP_NOCHANGE)
|
||||||
P_BringUpWeapon(this);
|
P_BringUpWeapon(this);
|
||||||
|
@ -1344,8 +1354,7 @@ void DPSprite::Tick()
|
||||||
|
|
||||||
// [BC] Apply double firing speed.
|
// [BC] Apply double firing speed.
|
||||||
// This is applied to the targeter layers too.
|
// This is applied to the targeter layers too.
|
||||||
if (((ID == PSP_WEAPON || ID == PSP_FLASH || ID >= PSP_TARGETCENTER) || Caller->IsKindOf(RUNTIME_CLASS(AWeapon))) &&
|
if (Caller->IsKindOf(RUNTIME_CLASS(AWeapon)) && Tics && Owner->cheats & CF_DOUBLEFIRINGSPEED)
|
||||||
(Tics && Owner->cheats & CF_DOUBLEFIRINGSPEED))
|
|
||||||
Tics--;
|
Tics--;
|
||||||
|
|
||||||
if (!Tics)
|
if (!Tics)
|
||||||
|
|
|
@ -3088,7 +3088,7 @@ void player_t::Serialize (FArchive &arc)
|
||||||
<< sx << sy
|
<< sx << sy
|
||||||
<< sprite << frame;
|
<< sprite << frame;
|
||||||
|
|
||||||
if (state != nullptr)
|
if (state != nullptr && ReadyWeapon != nullptr)
|
||||||
{
|
{
|
||||||
DPSprite *pspr;
|
DPSprite *pspr;
|
||||||
pspr = GetPSprite(PSPLayers(layer));
|
pspr = GetPSprite(PSPLayers(layer));
|
||||||
|
@ -3108,14 +3108,6 @@ void player_t::Serialize (FArchive &arc)
|
||||||
pspr->x = sx;
|
pspr->x = sx;
|
||||||
pspr->y = sy;
|
pspr->y = sy;
|
||||||
}
|
}
|
||||||
|
|
||||||
pspr->Flags = 0;
|
|
||||||
if (layer < PSP_TARGETCENTER)
|
|
||||||
{
|
|
||||||
pspr->Flags |= PSPF_ADDBOB;
|
|
||||||
if (layer == PSP_FLASH)
|
|
||||||
pspr->Flags |= PSPF_ADDWEAPON;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (layer == PSP_WEAPON)
|
if (layer == PSP_WEAPON)
|
||||||
|
|
|
@ -1319,8 +1319,8 @@ void R_DrawPSprite(DPSprite *pspr, AActor *owner, float bobx, float boby, double
|
||||||
if (tex->UseType == FTexture::TEX_Null)
|
if (tex->UseType == FTexture::TEX_Null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
isweapon = ((pspr->GetID() == PSP_WEAPON || pspr->GetID() == PSP_FLASH) ||
|
// The targeters aren't weapons.
|
||||||
(pspr->GetID() < PSP_TARGETCENTER && pspr->GetCaller()->IsKindOf(RUNTIME_CLASS(AWeapon))));
|
isweapon = (pspr->GetID() < PSP_TARGETCENTER && pspr->GetCaller()->IsKindOf(RUNTIME_CLASS(AWeapon)));
|
||||||
|
|
||||||
if (pspr->firstTic)
|
if (pspr->firstTic)
|
||||||
{ // Can't interpolate the first tic.
|
{ // Can't interpolate the first tic.
|
||||||
|
|
Loading…
Reference in a new issue