mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 13:53:52 +00:00
2d0840cb3a
This commit changes the style of tes3mp serverside scripting mods. Short list of changes: * Break compatibility with old server mods * OOP style lua API * Basic dependency checker, allowing the installation of multiple server mods without changing configs * Remove support for C++ plugins * Change outdated LuaBridge to [sol2](https://github.com/ThePhD/sol2); * Support GCC, Clang and MSVC compilers * New environment variables: "TES3MP_SERVER_DIR" and "TES3MP_SERVER_USERDIR"; * New entity "Command controller" for registering new chat commands; * New Event system * Simplified Timer API * All Lua mods now run in their own environments * Add global namespace - Data that can be used for communicating between mods * Player and Actor inherit base class NetActor
90 lines
2.7 KiB
C++
90 lines
2.7 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/WorldPacketController.hpp>
|
|
#include <components/openmw-mp/Packets/PacketPreInit.hpp>
|
|
#include <apps/openmw-mp/Script/LuaState.hpp>
|
|
|
|
class MasterClient;
|
|
namespace mwmp
|
|
{
|
|
class Networking
|
|
{
|
|
public:
|
|
Networking(RakNet::RakPeerInterface *peer);
|
|
~Networking();
|
|
|
|
void newPlayer(RakNet::RakNetGUID guid);
|
|
void disconnectPlayer(RakNet::RakNetGUID guid);
|
|
void kickPlayer(RakNet::RakNetGUID guid);
|
|
|
|
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 processWorldPacket(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;
|
|
WorldPacketController *getWorldPacketController() const;
|
|
|
|
LuaState &getState() {return luaState;}
|
|
|
|
BaseActorList *getLastActorList();
|
|
BaseEvent *getLastEvent();
|
|
|
|
int getCurrentMpNum();
|
|
void setCurrentMpNum(int value);
|
|
int incrementMpNum();
|
|
|
|
MasterClient *getMasterClient();
|
|
void InitQuery(std::string queryAddr, unsigned short queryPort);
|
|
void setServerPassword(std::string passw) noexcept;
|
|
bool isPassworded() const;
|
|
|
|
static Networking &get();
|
|
static Networking *getPtr();
|
|
|
|
void postInit();
|
|
private:
|
|
LuaState luaState;
|
|
PacketPreInit::PluginContainer getPluginListSample();
|
|
std::string serverPassword;
|
|
static Networking *sThis;
|
|
|
|
RakNet::RakPeerInterface *peer;
|
|
RakNet::BitStream bsOut;
|
|
MasterClient *mclient;
|
|
|
|
BaseActorList baseActorList;
|
|
BaseEvent baseEvent;
|
|
|
|
PlayerPacketController *playerPacketController;
|
|
ActorPacketController *actorPacketController;
|
|
WorldPacketController *worldPacketController;
|
|
|
|
bool running;
|
|
int exitCode;
|
|
PacketPreInit::PluginContainer samples;
|
|
};
|
|
}
|
|
|
|
|
|
#endif //OPENMW_NETWORKING_HPP
|