raze/source/core/coreplayer.h
Christoph Oelckers dd2ea96d6c turn players into DObjects and fix several bugs with bad memory access.
* DObjects may not be memset to 0.
* There was still code trying to retrieve the player index with pointer artithmetic. With an array of pointers this does not work.
2023-10-02 21:03:59 +02:00

33 lines
661 B
C++

#pragma once
#include "d_net.h"
#include "packet.h"
#include "gameinput.h"
class DCorePlayer : public DObject
{
DECLARE_CLASS(DCorePlayer, DObject)
HAS_OBJECT_POINTERS
protected:
DCorePlayer() = default;
void Clear()
{
memset(&lastcmd, 0, sizeof(lastcmd));
memset(&cmd, 0, sizeof(cmd));
memset(&Angles, 0, sizeof(Angles));
actor = nullptr;
pnum = 0;
}
public:
ticcmd_t lastcmd, cmd;
PlayerAngles Angles;
DCoreActor* actor;
uint8_t pnum;
DCorePlayer(uint8_t p) : pnum(p) {}
void OnDestroy() override { if (actor) actor->Destroy(); actor = nullptr; }
virtual DCoreActor* GetActor() = 0;
};
extern DCorePlayer* PlayerArray[MAXPLAYERS];