2016-01-12 03:41:44 +00:00
|
|
|
#ifndef OPENMW_PLAYER_HPP
|
|
|
|
#define OPENMW_PLAYER_HPP
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
2016-10-30 11:19:48 +00:00
|
|
|
#include <chrono>
|
2016-01-12 03:41:44 +00:00
|
|
|
#include <RakNetTypes.h>
|
|
|
|
|
|
|
|
#include <components/esm/npcstats.hpp>
|
|
|
|
#include <components/esm/cellid.hpp>
|
|
|
|
#include <components/esm/loadnpc.hpp>
|
|
|
|
#include <components/esm/loadcell.hpp>
|
|
|
|
|
2019-08-19 18:39:33 +00:00
|
|
|
#include <components/openmw-mp/TimedLog.hpp>
|
2016-01-12 03:41:44 +00:00
|
|
|
#include <components/openmw-mp/Base/BasePlayer.hpp>
|
2017-02-19 08:38:47 +00:00
|
|
|
#include <components/openmw-mp/Packets/Player/PlayerPacket.hpp>
|
2017-02-19 05:26:42 +00:00
|
|
|
#include "Cell.hpp"
|
2017-04-29 20:05:12 +00:00
|
|
|
#include "CellController.hpp"
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2016-11-17 05:11:42 +00:00
|
|
|
typedef std::map<RakNet::RakNetGUID, Player*> TPlayers;
|
2016-01-12 03:41:44 +00:00
|
|
|
typedef std::map<unsigned short, Player*> TSlots;
|
|
|
|
|
|
|
|
class Players
|
|
|
|
{
|
|
|
|
public:
|
2016-11-16 00:05:14 +00:00
|
|
|
static void newPlayer(RakNet::RakNetGUID guid);
|
|
|
|
static void deletePlayer(RakNet::RakNetGUID guid);
|
|
|
|
static Player *getPlayer(RakNet::RakNetGUID guid);
|
|
|
|
static Player *getPlayer(unsigned short id);
|
|
|
|
static TPlayers *getPlayers();
|
2017-02-26 21:00:51 +00:00
|
|
|
static unsigned short getLastPlayerId();
|
2018-07-21 04:34:45 +00:00
|
|
|
static bool doesPlayerExist(RakNet::RakNetGUID guid);
|
2016-01-12 03:41:44 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
static TPlayers players;
|
|
|
|
static TSlots slots;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Player : public mwmp::BasePlayer
|
|
|
|
{
|
2017-02-19 05:26:42 +00:00
|
|
|
friend class Cell;
|
2016-01-12 03:41:44 +00:00
|
|
|
unsigned short id;
|
|
|
|
public:
|
|
|
|
|
2016-09-18 07:52:13 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
NOTLOADED=0,
|
|
|
|
LOADED,
|
2018-10-30 04:56:50 +00:00
|
|
|
POSTLOADED,
|
|
|
|
KICKED
|
2016-09-18 07:52:13 +00:00
|
|
|
};
|
2016-10-26 12:55:34 +00:00
|
|
|
Player(RakNet::RakNetGUID guid);
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2016-11-16 00:05:14 +00:00
|
|
|
unsigned short getId();
|
|
|
|
void setId(unsigned short id);
|
2016-01-12 03:41:44 +00:00
|
|
|
|
|
|
|
bool isHandshaked();
|
2018-04-09 12:25:50 +00:00
|
|
|
int getHandshakeAttempts();
|
|
|
|
void incrementHandshakeAttempts();
|
2016-11-16 00:05:14 +00:00
|
|
|
void setHandshake();
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2016-11-16 00:05:14 +00:00
|
|
|
void setLoadState(int state);
|
|
|
|
int getLoadState();
|
2016-09-18 03:48:08 +00:00
|
|
|
|
2016-01-12 03:41:44 +00:00
|
|
|
virtual ~Player();
|
2016-11-21 18:37:04 +00:00
|
|
|
|
2017-02-20 12:43:51 +00:00
|
|
|
CellController::TContainer *getCells();
|
2017-02-19 12:37:26 +00:00
|
|
|
void sendToLoaded(mwmp::PlayerPacket *myPacket);
|
2017-02-19 05:26:42 +00:00
|
|
|
|
2017-02-19 13:32:25 +00:00
|
|
|
void forEachLoaded(std::function<void(Player *pl, Player *other)> func);
|
2017-02-19 09:42:39 +00:00
|
|
|
|
2016-01-12 03:41:44 +00:00
|
|
|
private:
|
2017-02-19 05:26:42 +00:00
|
|
|
CellController::TContainer cells;
|
2016-11-16 00:05:14 +00:00
|
|
|
int loadState;
|
2018-04-09 12:25:50 +00:00
|
|
|
int handshakeCounter;
|
2016-10-30 11:19:48 +00:00
|
|
|
|
2016-01-12 03:41:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //OPENMW_PLAYER_HPP
|