2016-01-12 03:41:44 +00:00
|
|
|
//
|
|
|
|
// Created by koncord on 04.01.16.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef OPENMW_NETWORKING_HPP
|
|
|
|
#define OPENMW_NETWORKING_HPP
|
|
|
|
|
|
|
|
#include <RakPeerInterface.h>
|
|
|
|
#include <BitStream.h>
|
|
|
|
#include <string>
|
|
|
|
|
2017-04-09 13:32:44 +00:00
|
|
|
#include "ActorList.hpp"
|
2017-02-06 15:40:32 +00:00
|
|
|
#include "WorldEvent.hpp"
|
2016-01-12 03:41:44 +00:00
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
2017-04-09 05:51:28 +00:00
|
|
|
|
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 19:49:35 +00:00
|
|
|
#include <components/openmw-mp/Controllers/WorldPacketController.hpp>
|
2017-04-09 05:51:28 +00:00
|
|
|
|
2017-03-04 05:23:26 +00:00
|
|
|
#include <components/files/collections.hpp>
|
2016-01-04 12:17:30 +00:00
|
|
|
|
|
|
|
namespace mwmp
|
|
|
|
{
|
2016-01-12 03:41:44 +00:00
|
|
|
class LocalPlayer;
|
|
|
|
|
|
|
|
class Networking
|
2016-01-04 12:17:30 +00:00
|
|
|
{
|
|
|
|
public:
|
2016-01-12 03:41:44 +00:00
|
|
|
Networking();
|
|
|
|
~Networking();
|
2017-03-04 05:23:26 +00:00
|
|
|
void connect(const std::string& ip, unsigned short port, std::vector<std::string> &content, Files::Collections &collections);
|
2016-11-15 19:54:06 +00:00
|
|
|
void update();
|
2016-10-19 19:49:35 +00:00
|
|
|
|
2016-11-15 19:54:06 +00:00
|
|
|
PlayerPacket *getPlayerPacket(RakNet::MessageID id);
|
2017-04-09 05:51:28 +00:00
|
|
|
ActorPacket *getActorPacket(RakNet::MessageID id);
|
2016-11-15 19:54:06 +00:00
|
|
|
WorldPacket *getWorldPacket(RakNet::MessageID id);
|
2016-01-12 03:41:44 +00:00
|
|
|
|
|
|
|
bool isDedicatedPlayer(const MWWorld::Ptr &ptr);
|
2016-11-15 19:54:06 +00:00
|
|
|
bool attack(const MWWorld::Ptr &ptr);
|
2016-01-12 03:41:44 +00:00
|
|
|
|
|
|
|
RakNet::SystemAddress serverAddress()
|
|
|
|
{
|
|
|
|
return serverAddr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isConnected();
|
2016-01-04 12:17:30 +00:00
|
|
|
|
2017-04-05 06:04:41 +00:00
|
|
|
LocalPlayer *getLocalPlayer();
|
2017-04-09 13:32:44 +00:00
|
|
|
ActorList *getActorList();
|
|
|
|
WorldEvent *getWorldEvent();
|
2016-10-20 11:28:19 +00:00
|
|
|
|
2016-01-04 12:17:30 +00:00
|
|
|
private:
|
2016-01-12 03:41:44 +00:00
|
|
|
bool connected;
|
|
|
|
RakNet::RakPeerInterface *peer;
|
|
|
|
RakNet::SystemAddress serverAddr;
|
|
|
|
RakNet::BitStream bsOut;
|
|
|
|
|
2017-04-09 05:51:28 +00:00
|
|
|
PlayerPacketController playerPacketController;
|
|
|
|
ActorPacketController actorPacketController;
|
|
|
|
WorldPacketController worldPacketController;
|
|
|
|
|
2017-04-09 13:32:44 +00:00
|
|
|
ActorList actorList;
|
2017-02-23 07:18:48 +00:00
|
|
|
WorldEvent worldEvent;
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2016-11-15 19:54:06 +00:00
|
|
|
void processPlayerPacket(RakNet::Packet *packet);
|
2017-04-09 05:51:28 +00:00
|
|
|
void processActorPacket(RakNet::Packet *packet);
|
2016-11-15 19:54:06 +00:00
|
|
|
void processWorldPacket(RakNet::Packet *packet);
|
2017-04-09 05:51:28 +00:00
|
|
|
|
2016-11-15 19:54:06 +00:00
|
|
|
void receiveMessage(RakNet::Packet *packet);
|
2017-03-05 08:55:05 +00:00
|
|
|
|
|
|
|
void preInit(std::vector<std::string> &content, Files::Collections &collections);
|
2016-01-04 12:17:30 +00:00
|
|
|
};
|
|
|
|
}
|
2016-01-12 03:41:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif //OPENMW_NETWORKING_HPP
|