diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-08-18 12:38:15 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-08-18 12:38:15 +0200 |
commit | 1b5eaa92b562c09ed7cea4de7186ff6541e65e5f (patch) | |
tree | 7e196c6021c1777d25ad4d79bb6530fd933a65d4 /source/cServer.cpp | |
parent | Packet refactoring, phase two, partial. Rewritten a few packet handling functions not to use cPacket-descendant objects. (diff) | |
download | cuberite-1b5eaa92b562c09ed7cea4de7186ff6541e65e5f.tar cuberite-1b5eaa92b562c09ed7cea4de7186ff6541e65e5f.tar.gz cuberite-1b5eaa92b562c09ed7cea4de7186ff6541e65e5f.tar.bz2 cuberite-1b5eaa92b562c09ed7cea4de7186ff6541e65e5f.tar.lz cuberite-1b5eaa92b562c09ed7cea4de7186ff6541e65e5f.tar.xz cuberite-1b5eaa92b562c09ed7cea4de7186ff6541e65e5f.tar.zst cuberite-1b5eaa92b562c09ed7cea4de7186ff6541e65e5f.zip |
Diffstat (limited to 'source/cServer.cpp')
-rw-r--r-- | source/cServer.cpp | 51 |
1 files changed, 15 insertions, 36 deletions
diff --git a/source/cServer.cpp b/source/cServer.cpp index 1724dea40..ef626614a 100644 --- a/source/cServer.cpp +++ b/source/cServer.cpp @@ -437,45 +437,24 @@ void cServer::StartListenThread() -template <class T> -bool from_string( - T& t, - const std::string& s, - std::ios_base& (*f)(std::ios_base&) -) +bool cServer::Command(cClientHandle & a_Client, const AString & a_Cmd) { - std::istringstream iss(s); - return !(iss >> f >> t).fail(); + return cRoot::Get()->GetPluginManager()->CallHookChat(a_Client.GetPlayer(), a_Cmd); } -bool cServer::Command( cClientHandle & a_Client, const char* a_Cmd ) +void cServer::ServerCommand(const AString & a_Cmd) { - cPluginManager* PM = cRoot::Get()->GetPluginManager(); - if( PM->CallHook( cPluginManager::E_PLUGIN_CHAT, 2, a_Cmd, a_Client.GetPlayer() ) ) - { - return true; - } - return false; -} - - - - - -void cServer::ServerCommand( const char * a_Cmd ) -{ - AString Command( a_Cmd ); - AStringVector split = StringSplit( Command, " " ); - if( split.empty()) + AStringVector split = StringSplit(a_Cmd, " "); + if (split.empty()) { return; } - if( split[0].compare( "help" ) == 0 ) + if (split[0].compare( "help" ) == 0) { printf("================== ALL COMMANDS ===================\n"); printf("help - Shows this message\n"); @@ -491,11 +470,11 @@ void cServer::ServerCommand( const char * a_Cmd ) printf("===================================================\n"); return; } - if( split[0].compare( "stop" ) == 0 || split[0].compare( "restart" ) == 0 ) + if ((split[0].compare("stop") == 0) || (split[0].compare("restart") == 0)) { return; } - if( split[0].compare( "save-all" ) == 0 ) + if (split[0].compare("save-all") == 0) { cRoot::Get()->SaveAllChunks(); return; @@ -507,7 +486,7 @@ void cServer::ServerCommand( const char * a_Cmd ) LOG("Num loaded chunks after: %i", cRoot::Get()->GetTotalChunkCount() ); return; } - if( split[0].compare( "list" ) == 0 ) + if (split[0].compare("list") == 0) { class cPlayerLogger : public cPlayerListCallback { @@ -520,7 +499,7 @@ void cServer::ServerCommand( const char * a_Cmd ) cRoot::Get()->ForEachPlayer(Logger); return; } - if( split[0].compare( "numchunks" ) == 0 ) + if (split[0].compare("numchunks") == 0) { LOG("Num loaded chunks: %i", cRoot::Get()->GetTotalChunkCount() ); return; @@ -531,19 +510,19 @@ void cServer::ServerCommand( const char * a_Cmd ) return; } - if(split[0].compare("monsters") == 0 ) + if (split[0].compare("monsters") == 0) { // TODO: cWorld::ListMonsters(); return; } - if(split.size() > 1) + if (split.size() > 1) { - if( split[0].compare( "say" ) == 0 ) + if (split[0].compare("say") == 0) { - std::string Message = cChatColor::Purple + "[SERVER] " + Command.substr( Command.find_first_of("say") + 4 ); + AString Message = cChatColor::Purple + "[SERVER] " + a_Cmd.substr(a_Cmd.find_first_of("say") + 4); LOG("%s", Message.c_str() ); - Broadcast( cPacket_Chat(Message) ); + Broadcast(cPacket_Chat(Message)); return; } } |