1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-20 11:23:50 +00:00
openmw-tes3mp/apps/openmw-mp/Networking.hpp
David Cernat d4dbfdfdb6 Merge pull request #423 from TES3MP/0.6.3 while resolving conflicts
Conflicts:
	apps/openmw-mp/Networking.cpp
	apps/openmw-mp/Script/Functions/World.cpp
	apps/openmw-mp/Script/Functions/World.hpp
	apps/openmw-mp/processors/WorldProcessor.cpp
	apps/openmw-mp/processors/WorldProcessor.hpp
	apps/openmw-mp/processors/world/ProcessorContainer.hpp
	apps/openmw-mp/processors/world/ProcessorDoorState.hpp
	apps/openmw-mp/processors/world/ProcessorObjectDelete.hpp
	apps/openmw-mp/processors/world/ProcessorObjectLock.hpp
	apps/openmw-mp/processors/world/ProcessorObjectPlace.hpp
	apps/openmw-mp/processors/world/ProcessorObjectScale.hpp
	apps/openmw-mp/processors/world/ProcessorObjectSpawn.hpp
	apps/openmw-mp/processors/world/ProcessorObjectState.hpp
	apps/openmw-mp/processors/world/ProcessorObjectTrap.hpp
	apps/openmw/mwgui/container.cpp
	apps/openmw/mwmp/Networking.cpp
	apps/openmw/mwmp/ObjectList.cpp
	apps/openmw/mwmp/ObjectList.hpp
	apps/openmw/mwmp/processors/world/ProcessorContainer.hpp
	components/CMakeLists.txt
	components/openmw-mp/Base/BaseObject.hpp
	components/openmw-mp/Packets/Object/ObjectPacket.cpp
	components/openmw-mp/Packets/Object/PacketConsoleCommand.cpp
	components/openmw-mp/Packets/Object/PacketContainer.cpp
	components/openmw-mp/Packets/Object/PacketDoorState.hpp
	components/openmw-mp/Packets/Object/PacketMusicPlay.hpp
	components/openmw-mp/Packets/Object/PacketObjectAnimPlay.hpp
	components/openmw-mp/Packets/Object/PacketObjectLock.hpp
	components/openmw-mp/Packets/Object/PacketObjectMove.hpp
	components/openmw-mp/Packets/Object/PacketObjectPlace.hpp
	components/openmw-mp/Packets/Object/PacketObjectRotate.hpp
	components/openmw-mp/Packets/Object/PacketObjectScale.hpp
	components/openmw-mp/Packets/Object/PacketObjectSpawn.hpp
	components/openmw-mp/Packets/Object/PacketObjectState.hpp
	components/openmw-mp/Packets/Object/PacketObjectTrap.hpp
	components/openmw-mp/Packets/Object/PacketScriptGlobalShort.hpp
	components/openmw-mp/Packets/Object/PacketScriptLocalFloat.hpp
	components/openmw-mp/Packets/Object/PacketScriptLocalShort.hpp
	components/openmw-mp/Packets/Object/PacketScriptMemberShort.hpp
	components/openmw-mp/Packets/Object/PacketVideoPlay.hpp
2018-05-13 03:20:01 +03:00

108 lines
3.2 KiB
C++

//
// Created by koncord on 12.01.16.
//
#ifndef OPENMW_NETWORKING_HPP
#define OPENMW_NETWORKING_HPP
#include <components/openmw-mp/Controllers/PlayerPacketController.hpp>
#include <components/openmw-mp/Controllers/ActorPacketController.hpp>
#include <components/openmw-mp/Controllers/ObjectPacketController.hpp>
#include <components/openmw-mp/Packets/PacketPreInit.hpp>
#include <apps/openmw-mp/Script/LuaState.hpp>
class MasterClient;
namespace mwmp
{
struct ChatChannel
{
ChatChannel()
{
}
std::vector<std::weak_ptr<Player>> members;
};
class Networking
{
public:
Networking(RakNet::RakPeerInterface *peer);
~Networking();
void newPlayer(RakNet::RakNetGUID guid);
void disconnectPlayer(RakNet::RakNetGUID guid);
void kickPlayer(RakNet::RakNetGUID guid, bool sendNotification = true);
void banAddress(const char *ipAddress);
void unbanAddress(const char *ipAddress);
RakNet::SystemAddress getSystemAddress(RakNet::RakNetGUID guid);
void processPlayerPacket(RakNet::Packet *packet);
void processActorPacket(RakNet::Packet *packet);
void processObjectPacket(RakNet::Packet *packet);
bool update(RakNet::Packet *packet);
unsigned short numberOfConnections() const;
unsigned int maxConnections() const;
int getAvgPing(RakNet::AddressOrGUID) const;
int mainLoop();
void stopServer(int code);
PlayerPacketController *getPlayerPacketController() const;
ActorPacketController *getActorPacketController() const;
ObjectPacketController *getObjectPacketController() const;
LuaState &getState() {return luaState;}
BaseActorList *getLastActorList();
BaseObjectList *getLastObjectList();
int getCurrentMpNum();
void setCurrentMpNum(int value);
int incrementMpNum();
bool getPluginEnforcementState();
void setPluginEnforcementState(bool state);
MasterClient *getMasterClient();
void InitQuery(const std::string &queryAddr, unsigned short queryPort);
void setServerPassword(std::string passw) noexcept;
bool isPassworded() const;
static Networking &get();
static Networking *getPtr();
void postInit();
std::shared_ptr<ChatChannel> getChannel(unsigned id);
unsigned createChannel();
bool closeChannel(unsigned id);
private:
LuaState luaState;
PacketPreInit::PluginContainer getPluginListSample();
std::string serverPassword;
static Networking *sThis;
RakNet::RakPeerInterface *peer;
RakNet::BitStream bsOut;
std::unique_ptr<MasterClient> mclient;
BaseActorList baseActorList;
BaseObjectList baseObjectList;
std::unique_ptr<PlayerPacketController> playerPacketController;
std::unique_ptr<ActorPacketController> actorPacketController;
std::unique_ptr<ObjectPacketController> objectPacketController;
bool running;
int exitCode;
PacketPreInit::PluginContainer samples;
std::unordered_map<unsigned, std::shared_ptr<ChatChannel>> chatChannels;
};
}
#endif //OPENMW_NETWORKING_HPP