2016-01-12 03:41:44 +00:00
|
|
|
//
|
|
|
|
// Created by koncord on 12.01.16.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef OPENMW_NETWORKING_HPP
|
|
|
|
#define OPENMW_NETWORKING_HPP
|
|
|
|
|
2016-10-19 13:31:07 +00:00
|
|
|
#include <components/openmw-mp/Controllers/PlayerPacketController.hpp>
|
2017-04-09 05:51:28 +00:00
|
|
|
#include <components/openmw-mp/Controllers/ActorPacketController.hpp>
|
2016-10-19 17:51:51 +00:00
|
|
|
#include <components/openmw-mp/Controllers/WorldPacketController.hpp>
|
2017-05-02 15:33:50 +00:00
|
|
|
#include <components/openmw-mp/Packets/PacketPreInit.hpp>
|
2016-08-14 23:48:25 +00:00
|
|
|
#include "Player.hpp"
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2017-01-10 11:21:31 +00:00
|
|
|
class MasterClient;
|
2016-01-12 03:41:44 +00:00
|
|
|
namespace mwmp
|
|
|
|
{
|
|
|
|
class Networking
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Networking(RakNet::RakPeerInterface *peer);
|
|
|
|
~Networking();
|
|
|
|
|
2016-11-16 00:05:14 +00:00
|
|
|
void newPlayer(RakNet::RakNetGUID guid);
|
|
|
|
void disconnectPlayer(RakNet::RakNetGUID guid);
|
|
|
|
void kickPlayer(RakNet::RakNetGUID guid);
|
2016-10-19 18:26:42 +00:00
|
|
|
|
2016-11-16 00:05:14 +00:00
|
|
|
void processPlayerPacket(RakNet::Packet *packet);
|
2017-04-09 05:51:28 +00:00
|
|
|
void processActorPacket(RakNet::Packet *packet);
|
2016-11-16 00:05:14 +00:00
|
|
|
void processWorldPacket(RakNet::Packet *packet);
|
|
|
|
void update(RakNet::Packet *packet);
|
2016-10-19 18:26:42 +00:00
|
|
|
|
2016-11-16 00:05:14 +00:00
|
|
|
unsigned short numberOfConnections() const;
|
|
|
|
unsigned int maxConnections() const;
|
|
|
|
int getAvgPing(RakNet::AddressOrGUID) const;
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2016-11-16 00:05:14 +00:00
|
|
|
int mainLoop();
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2016-11-16 00:05:14 +00:00
|
|
|
void stopServer(int code);
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2017-04-09 05:51:28 +00:00
|
|
|
PlayerPacketController *getPlayerPacketController() const;
|
|
|
|
ActorPacketController *getActorPacketController() const;
|
|
|
|
WorldPacketController *getWorldPacketController() const;
|
|
|
|
|
2017-04-09 13:32:44 +00:00
|
|
|
BaseActorList *getLastActorList();
|
2017-02-06 10:53:41 +00:00
|
|
|
BaseEvent *getLastEvent();
|
2016-10-19 17:51:51 +00:00
|
|
|
|
2017-04-04 06:23:34 +00:00
|
|
|
int getCurrentMpNum();
|
|
|
|
void setCurrentMpNum(int value);
|
2017-04-04 22:30:15 +00:00
|
|
|
int incrementMpNum();
|
2017-04-04 06:23:34 +00:00
|
|
|
|
2017-01-10 11:21:31 +00:00
|
|
|
MasterClient *getMasterClient();
|
2017-04-24 12:01:05 +00:00
|
|
|
void InitQuery(std::string queryAddr, unsigned short queryPort);
|
2017-02-20 13:15:04 +00:00
|
|
|
void setServerPassword(std::string passw) noexcept;
|
2017-02-20 15:14:59 +00:00
|
|
|
bool isPassworded() const;
|
2017-01-10 11:21:31 +00:00
|
|
|
|
2016-11-16 00:05:14 +00:00
|
|
|
static const Networking &get();
|
|
|
|
static Networking *getPtr();
|
2016-01-12 03:41:44 +00:00
|
|
|
|
|
|
|
private:
|
2017-05-02 15:33:50 +00:00
|
|
|
PacketPreInit::PluginContainer getPluginListSample();
|
2017-02-20 13:15:04 +00:00
|
|
|
std::string serverPassword;
|
2016-01-12 03:41:44 +00:00
|
|
|
static Networking *sThis;
|
2017-04-09 13:32:44 +00:00
|
|
|
|
2016-01-12 03:41:44 +00:00
|
|
|
RakNet::RakPeerInterface *peer;
|
|
|
|
RakNet::BitStream bsOut;
|
|
|
|
TPlayers *players;
|
2017-01-10 11:21:31 +00:00
|
|
|
MasterClient *mclient;
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2017-04-09 13:32:44 +00:00
|
|
|
BaseActorList baseActorList;
|
|
|
|
BaseEvent baseEvent;
|
|
|
|
|
2017-04-09 05:51:28 +00:00
|
|
|
PlayerPacketController *playerPacketController;
|
|
|
|
ActorPacketController *actorPacketController;
|
|
|
|
WorldPacketController *worldPacketController;
|
2016-01-12 03:41:44 +00:00
|
|
|
|
|
|
|
bool running;
|
|
|
|
int exitCode;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif //OPENMW_NETWORKING_HPP
|