mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-29 15:47:46 +00:00
Add basic server info command
This commit is contained in:
parent
f3efcbe08d
commit
fd353792c2
4 changed files with 23 additions and 7 deletions
|
@ -1,6 +1,7 @@
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
#include <src/servers/Server_Common/Common.h>
|
#include <src/servers/Server_Common/Common.h>
|
||||||
|
#include <src/servers/Server_Common/Version.h>
|
||||||
#include <src/servers/Server_Common/Database/Database.h>
|
#include <src/servers/Server_Common/Database/Database.h>
|
||||||
#include <src/servers/Server_Common/Network/GamePacketNew.h>
|
#include <src/servers/Server_Common/Network/GamePacketNew.h>
|
||||||
#include <src/servers/Server_Common/Network/CommonNetwork.h>
|
#include <src/servers/Server_Common/Network/CommonNetwork.h>
|
||||||
|
@ -49,6 +50,7 @@ Core::DebugCommandHandler::DebugCommandHandler()
|
||||||
registerCommand( "injectc", &DebugCommandHandler::injectChatPacket, "Loads and injects a premade Packet.", Common::UserLevel::all );
|
registerCommand( "injectc", &DebugCommandHandler::injectChatPacket, "Loads and injects a premade Packet.", Common::UserLevel::all );
|
||||||
registerCommand( "script_reload", &DebugCommandHandler::scriptReload, "Loads and injects a premade Packet.", Common::UserLevel::all );
|
registerCommand( "script_reload", &DebugCommandHandler::scriptReload, "Loads and injects a premade Packet.", Common::UserLevel::all );
|
||||||
registerCommand( "nudge", &DebugCommandHandler::nudge, "Nudges you forward/up/down", Common::UserLevel::all );
|
registerCommand( "nudge", &DebugCommandHandler::nudge, "Nudges you forward/up/down", Common::UserLevel::all );
|
||||||
|
registerCommand("info", &DebugCommandHandler::serverInfo, "Send server info", Common::UserLevel::all);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,12 +72,6 @@ void Core::DebugCommandHandler::registerCommand( const std::string& n, Core::Deb
|
||||||
void Core::DebugCommandHandler::execCommand( char * data, Core::Entity::PlayerPtr pPlayer )
|
void Core::DebugCommandHandler::execCommand( char * data, Core::Entity::PlayerPtr pPlayer )
|
||||||
{
|
{
|
||||||
|
|
||||||
if( pPlayer->getGmRank() <= 0 )
|
|
||||||
{
|
|
||||||
pPlayer->sendUrgent( "You are not allowed to use debug commands." );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// define callback pointer
|
// define callback pointer
|
||||||
void ( DebugCommandHandler::*pf )( char *, Entity::PlayerPtr, boost::shared_ptr< DebugCommand > );
|
void ( DebugCommandHandler::*pf )( char *, Entity::PlayerPtr, boost::shared_ptr< DebugCommand > );
|
||||||
|
|
||||||
|
@ -92,13 +88,18 @@ void Core::DebugCommandHandler::execCommand( char * data, Core::Entity::PlayerPt
|
||||||
// no parameters, just get the command
|
// no parameters, just get the command
|
||||||
commandString = tmpCommand;
|
commandString = tmpCommand;
|
||||||
|
|
||||||
|
if (pPlayer->getGmRank() <= 0 && commandString != "info")
|
||||||
|
{
|
||||||
|
pPlayer->sendUrgent("You are not allowed to use debug commands.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// try to retrieve the command
|
// try to retrieve the command
|
||||||
auto it = m_commandMap.find( commandString );
|
auto it = m_commandMap.find( commandString );
|
||||||
|
|
||||||
if( it == m_commandMap.end() )
|
if( it == m_commandMap.end() )
|
||||||
// no command found, do something... or not
|
// no command found, do something... or not
|
||||||
pPlayer->sendUrgent( "Command not found." );
|
pPlayer->sendUrgent( "Command not found." );
|
||||||
// TODO Notify the client of the failed command
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// command found, call the callback function and pass parameters if present.
|
// command found, call the callback function and pass parameters if present.
|
||||||
|
@ -534,3 +535,10 @@ void Core::DebugCommandHandler::nudge( char * data, Entity::PlayerPtr pPlayer, b
|
||||||
pPlayer->queuePacket( setActorPosPacket );
|
pPlayer->queuePacket( setActorPosPacket );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Core::DebugCommandHandler::serverInfo(char * data, Core::Entity::PlayerPtr pPlayer, boost::shared_ptr< Core::DebugCommand > command)
|
||||||
|
{
|
||||||
|
pPlayer->sendDebug( "SapphireServer " + Version::VERSION + " - " + Version::GIT_HASH );
|
||||||
|
pPlayer->sendDebug( "Sessions: " + std::to_string( g_serverZone.getSessionCount() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ public:
|
||||||
void injectPacket( char * data, Entity::PlayerPtr pPlayer, boost::shared_ptr<DebugCommand> command );
|
void injectPacket( char * data, Entity::PlayerPtr pPlayer, boost::shared_ptr<DebugCommand> command );
|
||||||
void injectChatPacket( char * data, Entity::PlayerPtr pPlayer, boost::shared_ptr<DebugCommand> command );
|
void injectChatPacket( char * data, Entity::PlayerPtr pPlayer, boost::shared_ptr<DebugCommand> command );
|
||||||
void nudge( char* data, Entity::PlayerPtr pPlayer, boost::shared_ptr<DebugCommand> command );
|
void nudge( char* data, Entity::PlayerPtr pPlayer, boost::shared_ptr<DebugCommand> command );
|
||||||
|
void serverInfo(char * data, Entity::PlayerPtr pPlayer, boost::shared_ptr<DebugCommand> command);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,11 @@ Core::XMLConfigPtr Core::ServerZone::getConfig() const
|
||||||
return m_pConfig;
|
return m_pConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t Core::ServerZone::getSessionCount() const
|
||||||
|
{
|
||||||
|
return m_sessionMap.size();
|
||||||
|
}
|
||||||
|
|
||||||
bool Core::ServerZone::registerBnpcTemplate( std::string templateName, uint32_t bnpcBaseId,
|
bool Core::ServerZone::registerBnpcTemplate( std::string templateName, uint32_t bnpcBaseId,
|
||||||
uint32_t bnpcNameId, uint32_t modelId, std::string aiName )
|
uint32_t bnpcNameId, uint32_t modelId, std::string aiName )
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,6 +33,8 @@ namespace Core {
|
||||||
|
|
||||||
XMLConfigPtr getConfig() const;
|
XMLConfigPtr getConfig() const;
|
||||||
|
|
||||||
|
size_t Core::ServerZone::getSessionCount() const;
|
||||||
|
|
||||||
bool registerBnpcTemplate( std::string templateName, uint32_t bnpcBaseId,
|
bool registerBnpcTemplate( std::string templateName, uint32_t bnpcBaseId,
|
||||||
uint32_t bnpcNameId, uint32_t modelId, std::string aiName );
|
uint32_t bnpcNameId, uint32_t modelId, std::string aiName );
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue