1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-01 16:37:45 +00:00
sapphire/src/world/ServerMgr.h

80 lines
1.8 KiB
C
Raw Normal View History

2017-08-08 13:53:47 +02:00
#ifndef __GAMESERVER_H
#define __GAMESERVER_H
2018-03-06 22:22:19 +01:00
#include <Common.h>
2017-08-08 13:53:47 +02:00
#include <mutex>
#include <map>
#include "ForwardsZone.h"
#include <Config/ConfigDef.h>
namespace Sapphire::World
{
2017-08-08 13:53:47 +02:00
2020-03-01 01:00:57 +11:00
class ServerMgr
{
public:
2020-03-01 01:00:57 +11:00
ServerMgr( const std::string& configName );
2020-03-01 01:00:57 +11:00
~ServerMgr();
2017-08-08 13:53:47 +02:00
using WorldConfigPtr = std::shared_ptr< Sapphire::Common::Config::WorldConfig >;
void run( int32_t argc, char* argv[] );
2017-08-08 13:53:47 +02:00
bool createSession( uint32_t sessionId );
2017-08-08 13:53:47 +02:00
void removeSession( uint32_t sessionId );
void removeSession( const std::string& playerName );
2017-10-01 17:58:11 +02:00
World::SessionPtr getSession( uint32_t id );
World::SessionPtr getSession( const std::string& playerName );
size_t getSessionCount() const;
2017-08-08 13:53:47 +02:00
uint16_t getWorldId() const;
void setWorldId( uint16_t worldId );
void mainLoop();
2017-08-08 13:53:47 +02:00
bool isRunning() const;
2017-10-01 17:58:11 +02:00
void printBanner() const;
2017-08-08 13:53:47 +02:00
bool loadSettings( int32_t argc, char* argv[] );
void loadBNpcTemplates();
Entity::BNpcTemplatePtr getBNpcTemplate( const std::string& key );
Entity::BNpcTemplatePtr getBNpcTemplate( uint32_t id );
2017-08-08 13:53:47 +02:00
std::string getPlayerNameFromDb( uint32_t playerId, bool forceDbLoad = false );
void updatePlayerName( uint32_t playerId, const std::string& playerNewName );
Sapphire::Common::Config::WorldConfig& getConfig();
private:
uint16_t m_port;
std::string m_ip;
int64_t m_lastDBPingTime;
bool m_bRunning;
uint16_t m_worldId;
2017-08-08 13:53:47 +02:00
std::string m_configName;
std::mutex m_sessionMutex;
Sapphire::Common::Config::WorldConfig m_config;
std::map< uint32_t, SessionPtr > m_sessionMapById;
std::map< std::string, SessionPtr > m_sessionMapByName;
std::map< uint32_t, std::string > m_playerNameMapById;
std::map< uint32_t, uint32_t > m_zones;
std::map< std::string, Entity::BNpcTemplatePtr > m_bNpcTemplateMap;
};
2017-08-08 13:53:47 +02:00
}
#endif