mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-01-18 07:02:03 +00:00
Changed the default layer indices and renamed them
Note that this doesn't compile yet
This commit is contained in:
parent
c82620129c
commit
2f5ae3b51e
7 changed files with 52 additions and 44 deletions
|
@ -532,7 +532,7 @@ public:
|
|||
void TickPSprites();
|
||||
void DestroyPSprites();
|
||||
DPSprite *FindPSprite(int layer);
|
||||
DPSprite *GetPSprite(psprnum_t layer); // Used ONLY for compatibility with the old hardcoded layers.
|
||||
DPSprite *GetPSprite(PSPLayers layer); // Used ONLY for compatibility with the old hardcoded layers.
|
||||
};
|
||||
|
||||
// Bookkeeping on players - state.
|
||||
|
|
|
@ -142,10 +142,10 @@ DPSprite::DPSprite(player_t *owner, AInventory *caller, int id)
|
|||
if (Next && Next->ID == ID && ID != 0)
|
||||
Next->Destroy(); // Replace it.
|
||||
|
||||
if (ID == ps_weapon || ID == ps_flash || (ID >= NUMPSPRITES && Caller->IsKindOf(RUNTIME_CLASS(AWeapon))))
|
||||
if (ID == PSP_WEAPON || ID == PSP_FLASH || (ID < PSP_TARGETCENTER && Caller->IsKindOf(RUNTIME_CLASS(AWeapon))))
|
||||
{
|
||||
Flags |= PSPF_ADDBOB;
|
||||
if (ID != ps_weapon)
|
||||
if (ID != PSP_WEAPON)
|
||||
Flags |= PSPF_ADDWEAPON;
|
||||
}
|
||||
}
|
||||
|
@ -179,10 +179,8 @@ DPSprite *player_t::FindPSprite(int layer)
|
|||
//
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
DPSprite *player_t::GetPSprite(psprnum_t layer)
|
||||
DPSprite *player_t::GetPSprite(PSPLayers layer)
|
||||
{
|
||||
assert(layer > 0 && layer < NUMPSPRITES);
|
||||
|
||||
DPSprite *pspr = FindPSprite(layer);
|
||||
if (pspr == nullptr)
|
||||
pspr = new DPSprite(this, ReadyWeapon, layer);
|
||||
|
@ -226,14 +224,14 @@ void DPSprite::NewTick()
|
|||
|
||||
void DPSprite::SetState(FState *newstate, bool pending)
|
||||
{
|
||||
if (ID == ps_weapon)
|
||||
if (ID == PSP_WEAPON)
|
||||
{ // A_WeaponReady will re-set these as needed
|
||||
Owner->WeaponState &= ~(WF_WEAPONREADY | WF_WEAPONREADYALT | WF_WEAPONBOBBING | WF_WEAPONSWITCHOK | WF_WEAPONRELOADOK | WF_WEAPONZOOMOK |
|
||||
WF_USER1OK | WF_USER2OK | WF_USER3OK | WF_USER4OK);
|
||||
}
|
||||
|
||||
// Special handling for the old hardcoded layers.
|
||||
if (ID > 0 && ID < NUMPSPRITES)
|
||||
if (ID == PSP_WEAPON || ID == PSP_FLASH || ID >= PSP_TARGETCENTER)
|
||||
Caller = Owner->ReadyWeapon;
|
||||
|
||||
processPending = pending;
|
||||
|
@ -261,9 +259,9 @@ void DPSprite::SetState(FState *newstate, bool pending)
|
|||
|
||||
Tics = newstate->GetTics(); // could be 0
|
||||
|
||||
if ((ID > 0 && ID < NUMPSPRITES) || Caller->IsKindOf(RUNTIME_CLASS(AWeapon)))
|
||||
if ((ID == PSP_WEAPON || ID == PSP_FLASH || ID >= PSP_TARGETCENTER) || Caller->IsKindOf(RUNTIME_CLASS(AWeapon)))
|
||||
{ // The targeter layers are affected by this too.
|
||||
if (sv_fastweapons == 2 && ID == ps_weapon)
|
||||
if (sv_fastweapons == 2 && ID == PSP_WEAPON)
|
||||
Tics = newstate->ActionFunc == nullptr ? 0 : 1;
|
||||
else if (sv_fastweapons == 3)
|
||||
Tics = (newstate->GetTics() != 0);
|
||||
|
@ -271,7 +269,7 @@ void DPSprite::SetState(FState *newstate, bool pending)
|
|||
Tics = 1; // great for producing decals :)
|
||||
}
|
||||
|
||||
if (ID != ps_flash)
|
||||
if (ID != PSP_FLASH)
|
||||
{ // It's still possible to set the flash layer's offsets with the action function.
|
||||
if (newstate->GetMisc1())
|
||||
{ // Set coordinates.
|
||||
|
@ -313,7 +311,7 @@ void DPSprite::SetState(FState *newstate, bool pending)
|
|||
return;
|
||||
}
|
||||
|
||||
void P_SetPsprite(player_t *player, psprnum_t id, FState *state, bool pending)
|
||||
void P_SetPsprite(player_t *player, PSPLayers id, FState *state, bool pending)
|
||||
{
|
||||
if (player == nullptr) return;
|
||||
player->GetPSprite(id)->SetState(state, pending);
|
||||
|
@ -961,7 +959,7 @@ void A_OverlayOffset(AActor *self, int layer, double wx, double wy, int flags)
|
|||
DEFINE_ACTION_FUNCTION(AInventory, A_OverlayOffset)
|
||||
{
|
||||
PARAM_ACTION_PROLOGUE;
|
||||
PARAM_INT_OPT(layer) { layer = ps_weapon; }
|
||||
PARAM_INT_OPT(layer) { layer = PSP_WEAPON; }
|
||||
PARAM_FLOAT_OPT(wx) { wx = 0.; }
|
||||
PARAM_FLOAT_OPT(wy) { wy = 32.; }
|
||||
PARAM_INT_OPT(flags) { flags = 0; }
|
||||
|
@ -975,7 +973,7 @@ DEFINE_ACTION_FUNCTION(AInventory, A_WeaponOffset)
|
|||
PARAM_FLOAT_OPT(wx) { wx = 0.; }
|
||||
PARAM_FLOAT_OPT(wy) { wy = 32.; }
|
||||
PARAM_INT_OPT(flags) { flags = 0; }
|
||||
A_OverlayOffset(self, ps_weapon, wx, wy, flags);
|
||||
A_OverlayOffset(self, PSP_WEAPON, wx, wy, flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1290,8 +1288,6 @@ void P_SetupPsprites(player_t *player, bool startweaponup)
|
|||
|
||||
void player_t::TickPSprites()
|
||||
{
|
||||
DPSprite *weapon = nullptr;
|
||||
DPSprite *flash = nullptr;
|
||||
bool noweapon = (ReadyWeapon == nullptr && (health > 0 || mo->DamageType != NAME_Fire));
|
||||
|
||||
DPSprite *pspr = psprites;
|
||||
|
@ -1299,31 +1295,29 @@ void player_t::TickPSprites()
|
|||
{
|
||||
// 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.
|
||||
// (except for the old hardcoded layers)
|
||||
if (!(pspr->ID > 0 && pspr->ID < NUMPSPRITES) &&
|
||||
// Exclude the old hardcoded layers from this check.
|
||||
if (!(pspr->ID == PSP_WEAPON || pspr->ID == PSP_FLASH || pspr->ID >= PSP_TARGETCENTER) &&
|
||||
(pspr->Caller == nullptr ||
|
||||
(pspr->Caller->IsKindOf(RUNTIME_CLASS(AWeapon)) && pspr->Caller != pspr->Owner->ReadyWeapon) ||
|
||||
(pspr->Caller->Owner != pspr->Owner->mo)))
|
||||
{
|
||||
pspr->Destroy();
|
||||
}
|
||||
else if (!(pspr->ID > 0 && pspr->ID < NUMPSPRITES && noweapon))
|
||||
else if (!((pspr->ID == PSP_WEAPON || pspr->ID == PSP_FLASH || pspr->ID >= PSP_TARGETCENTER) && noweapon))
|
||||
{
|
||||
pspr->Tick();
|
||||
}
|
||||
|
||||
if (pspr->ID == ps_weapon)
|
||||
weapon = pspr;
|
||||
else if (pspr->ID == ps_flash)
|
||||
flash = pspr;
|
||||
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;
|
||||
}
|
||||
|
||||
if (noweapon)
|
||||
{
|
||||
if (weapon) weapon->SetState(nullptr);
|
||||
if (flash) flash->SetState(nullptr);
|
||||
if (PendingWeapon != WP_NOCHANGE)
|
||||
P_BringUpWeapon(this);
|
||||
}
|
||||
|
@ -1356,7 +1350,7 @@ void DPSprite::Tick()
|
|||
|
||||
// [BC] Apply double firing speed.
|
||||
// This is applied to the targeter layers too.
|
||||
if (((ID > 0 && ID < NUMPSPRITES) || (Caller->IsKindOf(RUNTIME_CLASS(AWeapon)))) &&
|
||||
if (((ID == PSP_WEAPON || ID == PSP_FLASH || ID >= PSP_TARGETCENTER) || Caller->IsKindOf(RUNTIME_CLASS(AWeapon))) &&
|
||||
(Tics && Owner->cheats & CF_DOUBLEFIRINGSPEED))
|
||||
Tics--;
|
||||
|
||||
|
|
15
src/p_pspr.h
15
src/p_pspr.h
|
@ -42,14 +42,13 @@ class FArchive;
|
|||
// drawn directly on the view screen,
|
||||
// coordinates are given for a 320*200 view screen.
|
||||
//
|
||||
enum psprnum_t // These are all called by the owner's ReadyWeapon.
|
||||
enum PSPLayers // These are all called by the owner's ReadyWeapon.
|
||||
{
|
||||
ps_weapon = 1,
|
||||
ps_flash,
|
||||
ps_targetcenter,
|
||||
ps_targetleft,
|
||||
ps_targetright,
|
||||
NUMPSPRITES
|
||||
PSP_WEAPON = 1,
|
||||
PSP_FLASH = 1000,
|
||||
PSP_TARGETCENTER = INT_MAX - 2,
|
||||
PSP_TARGETLEFT,
|
||||
PSP_TARGETRIGHT,
|
||||
};
|
||||
|
||||
enum PSPFlags
|
||||
|
@ -103,7 +102,7 @@ private:
|
|||
|
||||
void P_NewPspriteTick();
|
||||
void P_CalcSwing (player_t *player);
|
||||
void P_SetPsprite(player_t *player, psprnum_t id, FState *state, bool pending = false);
|
||||
void P_SetPsprite(player_t *player, PSPLayers id, FState *state, bool pending = false);
|
||||
void P_BringUpWeapon (player_t *player);
|
||||
void P_FireWeapon (player_t *player);
|
||||
void P_DropWeapon (player_t *player);
|
||||
|
|
|
@ -3075,7 +3075,8 @@ void player_t::Serialize (FArchive &arc)
|
|||
|
||||
if (SaveVersion < 4547)
|
||||
{
|
||||
for (i = ps_weapon; i < NUMPSPRITES; i++)
|
||||
int layer = PSP_WEAPON;
|
||||
for (i = 0; i < 5; i++)
|
||||
{
|
||||
FState *state;
|
||||
int tics;
|
||||
|
@ -3090,14 +3091,14 @@ void player_t::Serialize (FArchive &arc)
|
|||
if (state != nullptr)
|
||||
{
|
||||
DPSprite *pspr;
|
||||
pspr = GetPSprite(psprnum_t(i));
|
||||
pspr = GetPSprite(PSPLayers(layer));
|
||||
pspr->State = state;
|
||||
pspr->Tics = tics;
|
||||
pspr->Sprite = sprite;
|
||||
pspr->Frame = frame;
|
||||
pspr->Owner = this;
|
||||
|
||||
if (i == ps_flash)
|
||||
if (layer == PSP_FLASH)
|
||||
{
|
||||
pspr->x = 0;
|
||||
pspr->y = 0;
|
||||
|
@ -3109,13 +3110,20 @@ void player_t::Serialize (FArchive &arc)
|
|||
}
|
||||
|
||||
pspr->Flags = 0;
|
||||
if (i < ps_targetcenter)
|
||||
if (layer < PSP_TARGETCENTER)
|
||||
{
|
||||
pspr->Flags |= PSPF_ADDBOB;
|
||||
if (i == ps_flash)
|
||||
if (layer == PSP_FLASH)
|
||||
pspr->Flags |= PSPF_ADDWEAPON;
|
||||
}
|
||||
}
|
||||
|
||||
if (layer == PSP_WEAPON)
|
||||
layer = PSP_FLASH;
|
||||
else if (layer == PSP_FLASH)
|
||||
layer = PSP_TARGETCENTER;
|
||||
else
|
||||
layer++;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1319,8 +1319,8 @@ void R_DrawPSprite(DPSprite *pspr, AActor *owner, float bobx, float boby, double
|
|||
if (tex->UseType == FTexture::TEX_Null)
|
||||
return;
|
||||
|
||||
isweapon = ((pspr->GetID() > 0 && pspr->GetID() < ps_targetcenter) ||
|
||||
(pspr->GetID() >= NUMPSPRITES && pspr->GetCaller() && pspr->GetCaller()->IsKindOf(RUNTIME_CLASS(AWeapon))));
|
||||
isweapon = ((pspr->GetID() == PSP_WEAPON || pspr->GetID() == PSP_FLASH) ||
|
||||
(pspr->GetID() < PSP_TARGETCENTER && pspr->GetCaller()->IsKindOf(RUNTIME_CLASS(AWeapon))));
|
||||
|
||||
if (pspr->firstTic)
|
||||
{ // Can't interpolate the first tic.
|
||||
|
@ -1627,7 +1627,7 @@ void R_DrawPlayerSprites ()
|
|||
P_BobWeapon (camera->player, &bobx, &boby, r_TicFracF);
|
||||
|
||||
// Interpolate the main weapon layer once so as to be able to add it to other layers.
|
||||
if ((weapon = camera->player->FindPSprite(ps_weapon)) != nullptr)
|
||||
if ((weapon = camera->player->FindPSprite(PSP_WEAPON)) != nullptr)
|
||||
{
|
||||
if (weapon->firstTic)
|
||||
{
|
||||
|
@ -1651,7 +1651,7 @@ void R_DrawPlayerSprites ()
|
|||
while (psp)
|
||||
{
|
||||
// [RH] Don't draw the targeter's crosshair if the player already has a crosshair set.
|
||||
if (psp->GetID() != ps_targetcenter || CrosshairImage == nullptr)
|
||||
if (psp->GetID() != PSP_TARGETCENTER || CrosshairImage == nullptr)
|
||||
{
|
||||
R_DrawPSprite(psp, camera, bobx, boby, wx, wy, r_TicFracF);
|
||||
}
|
||||
|
|
|
@ -576,3 +576,10 @@ enum
|
|||
PSPF_ADDWEAPON = 1 << 0,
|
||||
PSPF_ADDBOB = 1 << 1,
|
||||
};
|
||||
|
||||
// Default psprite layers
|
||||
enum
|
||||
{
|
||||
PSP_WEAPON = 1,
|
||||
PSP_FLASH = 1000,
|
||||
};
|
||||
|
|
|
@ -50,7 +50,7 @@ ACTOR Inventory native
|
|||
action native A_RestoreSpecialThing1();
|
||||
action native A_RestoreSpecialThing2();
|
||||
action native A_WeaponOffset(float wx = 0, float wy = 32, int flags = 0);
|
||||
action native A_OverlayOffset(int layer = 1, float wx = 0, float wy = 32, int flags = 0);
|
||||
action native A_OverlayOffset(int layer = PSP_WEAPON, float wx = 0, float wy = 32, int flags = 0);
|
||||
action native A_OverlayFlags(int layer, int flags, bool set);
|
||||
|
||||
States
|
||||
|
|
Loading…
Reference in a new issue