mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 04:19:55 +00:00
70 lines
2.1 KiB
C++
70 lines
2.1 KiB
C++
//
|
|
// Created by koncord on 04.01.16.
|
|
//
|
|
|
|
#ifndef OPENMW_NETWORKING_HPP
|
|
#define OPENMW_NETWORKING_HPP
|
|
|
|
#include <RakPeerInterface.h>
|
|
#include <BitStream.h>
|
|
#include <string>
|
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
#include <components/openmw-mp/Packets/Player/PacketPosition.hpp>
|
|
#include <components/openmw-mp/Packets/Player/PacketBaseInfo.hpp>
|
|
#include <components/openmw-mp/Packets/Player/PacketEquipment.hpp>
|
|
#include <components/openmw-mp/Packets/Player/PacketAttack.hpp>
|
|
#include <components/openmw-mp/Packets/Player/PacketDynamicStats.hpp>
|
|
#include <components/openmw-mp/Packets/Player/PacketResurrect.hpp>
|
|
#include <components/openmw-mp/Packets/Player/PacketDie.hpp>
|
|
#include <components/openmw-mp/Packets/Player/PacketCell.hpp>
|
|
#include <components/openmw-mp/Packets/Player/PacketDrawState.hpp>
|
|
#include <components/openmw-mp/Controllers/PlayerPacketController.hpp>
|
|
#include <components/openmw-mp/Controllers/WorldPacketController.hpp>
|
|
|
|
namespace mwmp
|
|
{
|
|
class LocalPlayer;
|
|
|
|
class Networking
|
|
{
|
|
public:
|
|
Networking();
|
|
~Networking();
|
|
void Connect(const std::string& ip, unsigned short port);
|
|
void Update();
|
|
void SendData(RakNet::BitStream *bitStream);
|
|
|
|
PlayerPacket *GetPlayerPacket(RakNet::MessageID id);
|
|
WorldPacket *GetWorldPacket(RakNet::MessageID id);
|
|
|
|
bool isDedicatedPlayer(const MWWorld::Ptr &ptr);
|
|
bool Attack(const MWWorld::Ptr &ptr);
|
|
|
|
RakNet::SystemAddress serverAddress()
|
|
{
|
|
return serverAddr;
|
|
}
|
|
|
|
bool isConnected();
|
|
|
|
WorldEvent *createWorldEvent();
|
|
|
|
private:
|
|
bool connected;
|
|
RakNet::RakPeerInterface *peer;
|
|
RakNet::SystemAddress serverAddr;
|
|
RakNet::BitStream bsOut;
|
|
|
|
PlayerPacketController playerController;
|
|
WorldPacketController worldController;
|
|
|
|
void ProcessPlayerPacket(RakNet::Packet *packet);
|
|
void ProcessWorldPacket(RakNet::Packet *packet);
|
|
void ReceiveMessage(RakNet::Packet *packet);
|
|
LocalPlayer *getLocalPlayer();
|
|
};
|
|
}
|
|
|
|
|
|
#endif //OPENMW_NETWORKING_HPP
|