diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-05-25 09:18:52 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-05-25 09:18:52 +0200 |
commit | a4a418a679f1ac760a8763edd856f0178cfc6dde (patch) | |
tree | 85300ca3a2b3a942998a0c864ae90894857ebf5f /source/cServer.cpp | |
parent | Fixed output directory structure in the "Release profiled" configuration (diff) | |
download | cuberite-a4a418a679f1ac760a8763edd856f0178cfc6dde.tar cuberite-a4a418a679f1ac760a8763edd856f0178cfc6dde.tar.gz cuberite-a4a418a679f1ac760a8763edd856f0178cfc6dde.tar.bz2 cuberite-a4a418a679f1ac760a8763edd856f0178cfc6dde.tar.lz cuberite-a4a418a679f1ac760a8763edd856f0178cfc6dde.tar.xz cuberite-a4a418a679f1ac760a8763edd856f0178cfc6dde.tar.zst cuberite-a4a418a679f1ac760a8763edd856f0178cfc6dde.zip |
Diffstat (limited to '')
-rw-r--r-- | source/cServer.cpp | 143 |
1 files changed, 79 insertions, 64 deletions
diff --git a/source/cServer.cpp b/source/cServer.cpp index 332631b47..36183f3bc 100644 --- a/source/cServer.cpp +++ b/source/cServer.cpp @@ -475,77 +475,92 @@ void cServer::ServerCommand( const char * a_Cmd ) {
AString Command( a_Cmd );
AStringVector split = StringSplit( Command, " " );
- if( split.size() > 0 )
+ if( split.empty())
{
- if( split[0].compare( "help" ) == 0 )
- {
- printf("================== ALL COMMANDS ===================\n");
- printf("help - Shows this message\n");
- printf("save-all - Saves all loaded chunks to disk\n");
- printf("list - Lists all players currently in server\n");
- printf("unload - Unloads all unused chunks\n");
- printf("numchunks - Shows number of chunks currently loaded\n");
- printf("say - Sends a chat message to all players\n");
- printf("restart - Kicks all clients, and saves everything\n");
- printf(" and clears memory\n");
- printf("stop - Saves everything and closes server\n");
- printf("===================================================\n");
- return;
- }
- if( split[0].compare( "stop" ) == 0 || split[0].compare( "restart" ) == 0 )
- {
- return;
- }
- if( split[0].compare( "save-all" ) == 0 )
- {
- cRoot::Get()->SaveAllChunks(); // TODO - Force ALL worlds to save their chunks
- return;
- }
- if (split[0].compare("unload") == 0)
- {
- LOG("Num loaded chunks before: %i", cRoot::Get()->GetTotalChunkCount() );
- cRoot::Get()->GetDefaultWorld()->UnloadUnusedChunks(); // TODO: Iterate through ALL worlds
- LOG("Num loaded chunks after: %i", cRoot::Get()->GetTotalChunkCount() );
- return;
- }
- if( split[0].compare( "list" ) == 0 )
+ return;
+ }
+
+ if( split[0].compare( "help" ) == 0 )
+ {
+ printf("================== ALL COMMANDS ===================\n");
+ printf("help - Shows this message\n");
+ printf("save-all - Saves all loaded chunks to disk\n");
+ printf("list - Lists all players currently in server\n");
+ printf("unload - Unloads all unused chunks\n");
+ printf("numchunks - Shows number of chunks currently loaded\n");
+ printf("chunkstats - Shows chunks statistics\n");
+ printf("say - Sends a chat message to all players\n");
+ printf("restart - Kicks all clients, and saves everything\n");
+ printf(" and clears memory\n");
+ printf("stop - Saves everything and closes server\n");
+ printf("===================================================\n");
+ return;
+ }
+ if( split[0].compare( "stop" ) == 0 || split[0].compare( "restart" ) == 0 )
+ {
+ return;
+ }
+ if( split[0].compare( "save-all" ) == 0 )
+ {
+ cRoot::Get()->SaveAllChunks(); // TODO - Force ALL worlds to save their chunks
+ return;
+ }
+ if (split[0].compare("unload") == 0)
+ {
+ LOG("Num loaded chunks before: %i", cRoot::Get()->GetTotalChunkCount() );
+ cRoot::Get()->GetDefaultWorld()->UnloadUnusedChunks(); // TODO: Iterate through ALL worlds
+ LOG("Num loaded chunks after: %i", cRoot::Get()->GetTotalChunkCount() );
+ return;
+ }
+ if( split[0].compare( "list" ) == 0 )
+ {
+ class cPlayerLogger : public cPlayerListCallback
{
- class cPlayerLogger : public cPlayerListCallback
+ virtual bool Item(cPlayer * a_Player) override
{
- virtual bool Item(cPlayer * a_Player) override
- {
- LOG("\t%s @ %s", a_Player->GetName().c_str(), a_Player->GetClientHandle()->GetSocket().GetIPString().c_str());
- return false;
- }
- } Logger;
- cRoot::Get()->ForEachPlayer(Logger);
- return;
- }
- if( split[0].compare( "numchunks" ) == 0 )
- {
- LOG("Num loaded chunks: %i", cRoot::Get()->GetTotalChunkCount() );
- return;
- }
-
- if(split[0].compare("monsters") == 0 )
+ LOG("\t%s @ %s", a_Player->GetName().c_str(), a_Player->GetClientHandle()->GetSocket().GetIPString().c_str());
+ return false;
+ }
+ } Logger;
+ cRoot::Get()->ForEachPlayer(Logger);
+ return;
+ }
+ if( split[0].compare( "numchunks" ) == 0 )
+ {
+ LOG("Num loaded chunks: %i", cRoot::Get()->GetTotalChunkCount() );
+ return;
+ }
+ if (split[0].compare("chunkstats") == 0)
+ {
+ // TODO: For each world
+ int NumValid = 0;
+ int NumDirty = 0;
+ int NumInLighting = 0;
+ cRoot::Get()->GetDefaultWorld()->GetChunkStats(NumValid, NumDirty, NumInLighting);
+ LOG("Num loaded chunks: %d", NumValid);
+ LOG("Num dirty chunks: %d", NumDirty);
+ LOG("Num chunks in lighting queue: %d", NumInLighting);
+ return;
+ }
+
+ if(split[0].compare("monsters") == 0 )
+ {
+ // TODO: cWorld::ListMonsters();
+ return;
+ }
+
+ if(split.size() > 1)
+ {
+ if( split[0].compare( "say" ) == 0 )
{
- // TODO: cWorld::ListMonsters();
+ std::string Message = cChatColor::Purple + "[SERVER] " + Command.substr( Command.find_first_of("say") + 4 );
+ LOG("%s", Message.c_str() );
+ Broadcast( cPacket_Chat(Message) );
return;
}
-
- if(split.size() > 1)
- {
- if( split[0].compare( "say" ) == 0 )
- {
- std::string Message = cChatColor::Purple + "[SERVER] " + Command.substr( Command.find_first_of("say") + 4 );
- LOG("%s", Message.c_str() );
- Broadcast( cPacket_Chat(Message) );
- return;
- }
- }
- printf("Unknown command, type 'help' for all commands.\n");
}
- //LOG("You didn't enter anything? (%s)", a_Cmd.c_str() );
+ printf("Unknown command, type 'help' for all commands.\n");
+ // LOG("You didn't enter anything? (%s)", a_Cmd.c_str() );
}
|