2016-01-12 03:41:44 +00:00
|
|
|
#ifndef OPENMW_NETWORKING_HPP
|
|
|
|
#define OPENMW_NETWORKING_HPP
|
|
|
|
|
2019-11-09 03:12:00 +00:00
|
|
|
#include <components/openmw-mp/Controllers/SystemPacketController.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>
|
2018-05-12 16:40:00 +00:00
|
|
|
#include <components/openmw-mp/Controllers/ObjectPacketController.hpp>
|
2018-05-18 03:40:28 +00:00
|
|
|
#include <components/openmw-mp/Controllers/WorldstatePacketController.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);
|
2018-04-17 13:36:48 +00:00
|
|
|
void kickPlayer(RakNet::RakNetGUID guid, bool sendNotification = true);
|
2017-07-27 16:29:17 +00:00
|
|
|
|
|
|
|
void banAddress(const char *ipAddress);
|
|
|
|
void unbanAddress(const char *ipAddress);
|
2017-07-04 07:57:16 +00:00
|
|
|
RakNet::SystemAddress getSystemAddress(RakNet::RakNetGUID guid);
|
2016-10-19 18:26:42 +00:00
|
|
|
|
2019-11-09 03:12:00 +00:00
|
|
|
void processSystemPacket(RakNet::Packet *packet);
|
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);
|
2018-05-12 16:40:00 +00:00
|
|
|
void processObjectPacket(RakNet::Packet *packet);
|
2018-05-18 03:40:28 +00:00
|
|
|
void processWorldstatePacket(RakNet::Packet *packet);
|
2018-07-16 16:58:37 +00:00
|
|
|
void update(RakNet::Packet *packet, RakNet::BitStream &bsIn);
|
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;
|
2018-09-05 10:19:34 +00:00
|
|
|
unsigned short getPort() 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
|
|
|
|
2019-11-09 03:12:00 +00:00
|
|
|
SystemPacketController *getSystemPacketController() const;
|
2017-04-09 05:51:28 +00:00
|
|
|
PlayerPacketController *getPlayerPacketController() const;
|
|
|
|
ActorPacketController *getActorPacketController() const;
|
2018-05-12 16:40:00 +00:00
|
|
|
ObjectPacketController *getObjectPacketController() const;
|
2018-05-18 03:40:28 +00:00
|
|
|
WorldstatePacketController *getWorldstatePacketController() const;
|
2017-04-09 05:51:28 +00:00
|
|
|
|
2018-07-12 23:40:24 +00:00
|
|
|
BaseActorList *getReceivedActorList();
|
|
|
|
BaseObjectList *getReceivedObjectList();
|
|
|
|
BaseWorldstate *getReceivedWorldstate();
|
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
|
|
|
|
2019-04-23 19:45:25 +00:00
|
|
|
bool getDataFileEnforcementState();
|
|
|
|
void setDataFileEnforcementState(bool state);
|
2018-01-02 14:32:38 +00:00
|
|
|
|
2018-12-01 01:03:39 +00:00
|
|
|
bool getScriptErrorIgnoringState();
|
|
|
|
void setScriptErrorIgnoringState(bool state);
|
|
|
|
|
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
|
|
|
|
2017-05-06 18:49:58 +00:00
|
|
|
void postInit();
|
2018-10-30 06:02:27 +00:00
|
|
|
|
|
|
|
PacketPreInit::PluginContainer &getSamples();
|
2016-01-12 03:41:44 +00:00
|
|
|
private:
|
2018-07-16 16:58:37 +00:00
|
|
|
bool preInit(RakNet::Packet *packet, RakNet::BitStream &bsIn);
|
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
|
|
|
|
2019-11-09 03:12:00 +00:00
|
|
|
BaseSystem baseSystem;
|
2017-04-09 13:32:44 +00:00
|
|
|
BaseActorList baseActorList;
|
2018-05-12 21:42:24 +00:00
|
|
|
BaseObjectList baseObjectList;
|
2018-05-18 03:40:28 +00:00
|
|
|
BaseWorldstate baseWorldstate;
|
2017-04-09 13:32:44 +00:00
|
|
|
|
2019-11-09 03:12:00 +00:00
|
|
|
SystemPacketController *systemPacketController;
|
2017-04-09 05:51:28 +00:00
|
|
|
PlayerPacketController *playerPacketController;
|
|
|
|
ActorPacketController *actorPacketController;
|
2018-05-12 16:40:00 +00:00
|
|
|
ObjectPacketController *objectPacketController;
|
2018-05-18 03:40:28 +00:00
|
|
|
WorldstatePacketController *worldstatePacketController;
|
2016-01-12 03:41:44 +00:00
|
|
|
|
|
|
|
bool running;
|
|
|
|
int exitCode;
|
2017-05-06 18:49:58 +00:00
|
|
|
PacketPreInit::PluginContainer samples;
|
2016-01-12 03:41:44 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif //OPENMW_NETWORKING_HPP
|