1
0

Chat packet handled in the new way; fixed missing packet sending for inventory slot.

Again, API change! cPlugin:OnChat() has had its parameters swapped, to match all the other callbacks - Player first, Message second

git-svn-id: http://mc-server.googlecode.com/svn/trunk@751 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com
2012-08-18 10:38:15 +00:00
parent 2691e8daed
commit 1b5eaa92b5
18 changed files with 213 additions and 210 deletions

View File

@@ -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;
}
}