qzdoom/src/playsim/p_pspr.h

140 lines
3.9 KiB
C
Raw Normal View History

2016-03-01 15:47:10 +00:00
//-----------------------------------------------------------------------------
//
// Copyright 1993-1996 id Software
// Copyright 1994-1996 Raven Software
// Copyright 1999-2016 Randy Heit
// Copyright 2002-2016 Christoph Oelckers
2016-03-01 15:47:10 +00:00
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
2016-03-01 15:47:10 +00:00
//
// This program is distributed in the hope that it will be useful,
2016-03-01 15:47:10 +00:00
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/
2016-03-01 15:47:10 +00:00
//
//-----------------------------------------------------------------------------
//
2016-03-01 15:47:10 +00:00
// DESCRIPTION:
// Sprite animation.
//
//-----------------------------------------------------------------------------
#ifndef __P_PSPR_H__
#define __P_PSPR_H__
#include "renderstyle.h"
2016-03-01 15:47:10 +00:00
// Basic data types.
// Needs fixed point, and BAM angles.
2016-03-21 00:16:34 +00:00
#define WEAPONBOTTOM 128.
2016-03-01 15:47:10 +00:00
#define WEAPONTOP 32.
#define WEAPON_FUDGE_Y 0.375
struct FTranslatedLineTarget;
struct FState;
2016-03-01 15:47:10 +00:00
//
// Overlay psprites are scaled shapes
// drawn directly on the view screen,
// coordinates are given for a 320*200 view screen.
//
enum PSPLayers
2016-03-01 15:47:10 +00:00
{
PSP_STRIFEHANDS = -1,
PSP_WEAPON = 1,
PSP_FLASH = 1000,
PSP_TARGETCENTER = INT_MAX - 2,
PSP_TARGETLEFT,
PSP_TARGETRIGHT,
};
2016-03-01 15:47:10 +00:00
enum PSPFlags
{
2016-09-29 02:20:15 +00:00
PSPF_ADDWEAPON = 1 << 0,
PSPF_ADDBOB = 1 << 1,
PSPF_POWDOUBLE = 1 << 2,
PSPF_CVARFAST = 1 << 3,
PSPF_ALPHA = 1 << 4,
PSPF_RENDERSTYLE = 1 << 5,
PSPF_FLIP = 1 << 6,
PSPF_FORCEALPHA = 1 << 7,
PSPF_FORCESTYLE = 1 << 8,
PSPF_MIRROR = 1 << 9,
PSPF_PLAYERTRANSLATED = 1 << 10
};
class DPSprite : public DObject
2016-03-01 15:47:10 +00:00
{
DECLARE_CLASS (DPSprite, DObject)
HAS_OBJECT_POINTERS
public:
DPSprite(player_t *owner, AActor *caller, int id);
static void NewTick();
void SetState(FState *newstate, bool pending = false);
2016-05-26 19:58:46 +00:00
int GetID() const { return ID; }
int GetSprite() const { return Sprite; }
int GetFrame() const { return Frame; }
int GetTics() const { return Tics; }
2016-05-26 19:58:46 +00:00
FState* GetState() const { return State; }
DPSprite* GetNext() { return Next; }
AActor* GetCaller() { return Caller; }
void SetCaller(AActor *newcaller) { Caller = newcaller; }
void ResetInterpolation() { oldx = x; oldy = y; }
void OnDestroy() override;
std::pair<FRenderStyle, float> GetRenderStyle(FRenderStyle ownerstyle, double owneralpha);
float GetYAdjust(bool fullscreen);
2016-09-29 02:20:15 +00:00
double x, y, alpha;
double oldx, oldy;
bool firstTic;
int Tics;
int Flags;
FRenderStyle Renderstyle;
private:
DPSprite () {}
void Serialize(FSerializer &arc);
public: // must be public to be able to generate the field export tables. Grrr...
TObjPtr<AActor*> Caller;
TObjPtr<DPSprite*> Next;
player_t *Owner;
FState *State;
int Sprite;
int Frame;
int ID;
bool processPending; // true: waiting for periodic processing on this tick
friend class player_t;
friend void CopyPlayer(player_t *dst, player_t *src, const char *name);
2016-03-01 15:47:10 +00:00
};
void P_NewPspriteTick();
void P_CalcSwing (player_t *player);
2016-06-16 12:24:00 +00:00
void P_SetPsprite(player_t *player, PSPLayers id, FState *state, bool pending = false);
2016-03-01 15:47:10 +00:00
void P_BringUpWeapon (player_t *player);
void P_FireWeapon (player_t *player);
void P_BobWeapon (player_t *player, float *x, float *y, double ticfrac);
DAngle P_BulletSlope (AActor *mo, FTranslatedLineTarget *pLineTarget = NULL, int aimflags = 0);
- fixed: State labels were resolved in the calling function's context instead of the called function one's. This could cause problems with functions that take states as parameters but use them to set them internally instead of passing them through the A_Jump interface back to the caller, like A_Chase or A_LookEx. This required some quite significant refactoring because the entire state resolution logic had been baked into the compiler which turned out to be a major maintenance problem. Fixed this by adding a new builtin type 'statelabel'. This is an opaque identifier representing a state, with the actual data either directly encoded into the number for single label state or an index into a state information table. The state resolution is now the task of the called function as it should always have remained. Note, that this required giving back the 'action' qualifier to most state jumping functions. - refactored most A_Jump checkers to a two stage setup with a pure checker that returns a boolean and a scripted A_Jump wrapper, for some simpler checks the checker function was entirely omitted and calculated inline in the A_Jump function. It is strongly recommended to use the boolean checkers unless using an inline function invocation in a state as they lead to vastly clearer code and offer more flexibility. - let Min() and Max() use the OP_MIN and OP_MAX opcodes. Although these were present, these function were implemented using some grossly inefficient branching tests. - the DECORATE 'state' cast kludge will now actually call ResolveState because a state label is not a state and needs conversion.
2016-11-14 13:12:27 +00:00
AActor *P_AimTarget(AActor *mo);
2016-03-01 15:47:10 +00:00
void DoReadyWeaponToBob(AActor *self);
void DoReadyWeaponToFire(AActor *self, bool primary = true, bool secondary = true);
void DoReadyWeaponToSwitch(AActor *self, bool switchable = true);
void A_ReFire(AActor *self, FState *state = NULL);
#endif // __P_PSPR_H__