1
0

Added total chunk count to webadmin

git-svn-id: http://mc-server.googlecode.com/svn/trunk@248 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2012-02-08 18:57:04 +00:00
parent 356981a51d
commit a204e33250
5 changed files with 134 additions and 8 deletions

View File

@ -283,3 +283,17 @@ void cRoot::AuthenticateUser(const AString & iUserName)
int cRoot::GetTotalChunkCount(void)
{
int res = 0;
for ( WorldMap::iterator itr = m_pState->WorldsByName.begin(); itr != m_pState->WorldsByName.end(); ++itr )
{
res += itr->second->GetNumChunks();
}
return res;
}

View File

@ -51,6 +51,8 @@ public:
void TickWorlds( float a_Dt ); void TickWorlds( float a_Dt );
int GetTotalChunkCount(void); // tolua_export
private: private:
void LoadWorlds(); void LoadWorlds();

View File

@ -232,11 +232,15 @@ void cWebAdmin::Request_Handler(webserver::http_request* r)
#endif #endif
// end mem usage // end mem usage
ReplaceString( Template, std::string("{USERNAME}"), r->username_ ); ReplaceString( Template, "{USERNAME}", r->username_ );
ReplaceString( Template, std::string("{MENU}"), Menu ); ReplaceString( Template, "{MENU}", Menu );
ReplaceString( Template, std::string("{PLUGIN_NAME}"), FoundPlugin ); ReplaceString( Template, "{PLUGIN_NAME}", FoundPlugin );
ReplaceString( Template, std::string("{CONTENT}"), Content ); ReplaceString( Template, "{CONTENT}", Content );
ReplaceString( Template, std::string("{TITLE}"), "MCServer" ); ReplaceString( Template, "{TITLE}", "MCServer" );
AString NumChunks;
Printf(NumChunks, "%d", cRoot::Get()->GetTotalChunkCount());
ReplaceString(Template, "{NUMCHUNKS}", NumChunks);
r->answer_ = Template; r->answer_ = Template;
} }

View File

@ -945,17 +945,29 @@ void cWorld::SetMaxPlayers(int iMax)
} }
} }
void cWorld::AddPlayer( cPlayer* a_Player ) void cWorld::AddPlayer( cPlayer* a_Player )
{ {
m_pState->Players.remove( a_Player ); m_pState->Players.remove( a_Player );
m_pState->Players.push_back( a_Player ); m_pState->Players.push_back( a_Player );
} }
void cWorld::RemovePlayer( cPlayer* a_Player ) void cWorld::RemovePlayer( cPlayer* a_Player )
{ {
m_pState->Players.remove( a_Player ); m_pState->Players.remove( a_Player );
} }
void cWorld::GetAllPlayers( lua_State* L ) void cWorld::GetAllPlayers( lua_State* L )
{ {
lua_createtable(L, m_pState->Players.size(), 0); lua_createtable(L, m_pState->Players.size(), 0);
@ -970,6 +982,10 @@ void cWorld::GetAllPlayers( lua_State* L )
} }
} }
cPlayer* cWorld::GetPlayer( const char* a_PlayerName ) cPlayer* cWorld::GetPlayer( const char* a_PlayerName )
{ {
cPlayer* BestMatch = 0; cPlayer* BestMatch = 0;
@ -1034,6 +1050,10 @@ cEntity* cWorld::GetEntity( int a_UniqueID )
return 0; return 0;
} }
// void cWorld::RemoveClient( cClientHandle* a_Client ) // void cWorld::RemoveClient( cClientHandle* a_Client )
// { // {
// m_pState->m_Clients.remove( a_Client ); // m_pState->m_Clients.remove( a_Client );
@ -1044,6 +1064,10 @@ cEntity* cWorld::GetEntity( int a_UniqueID )
// } // }
// } // }
void cWorld::RemoveEntity( cEntity* a_Entity ) void cWorld::RemoveEntity( cEntity* a_Entity )
{ {
m_pState->RemoveEntityQueue.remove( a_Entity ); m_pState->RemoveEntityQueue.remove( a_Entity );
@ -1054,6 +1078,10 @@ void cWorld::RemoveEntity( cEntity* a_Entity )
} }
} }
bool cWorld::RemoveEntityFromChunk( cEntity & a_Entity, cChunk* a_CalledFrom /* = 0 */ ) bool cWorld::RemoveEntityFromChunk( cEntity & a_Entity, cChunk* a_CalledFrom /* = 0 */ )
{ {
LockChunks(); LockChunks();
@ -1062,6 +1090,10 @@ bool cWorld::RemoveEntityFromChunk( cEntity & a_Entity, cChunk* a_CalledFrom /*
return retVal; return retVal;
} }
void cWorld::SaveAllChunks() void cWorld::SaveAllChunks()
{ {
LOG("Saving all chunks..."); LOG("Saving all chunks...");
@ -1072,36 +1104,64 @@ void cWorld::SaveAllChunks()
LOG("Done saving chunks"); LOG("Done saving chunks");
} }
void cWorld::LockClientHandle() void cWorld::LockClientHandle()
{ {
m_ClientHandleCriticalSection->Lock(); m_ClientHandleCriticalSection->Lock();
} }
void cWorld::UnlockClientHandle() void cWorld::UnlockClientHandle()
{ {
m_ClientHandleCriticalSection->Unlock(); m_ClientHandleCriticalSection->Unlock();
} }
void cWorld::LockEntities() void cWorld::LockEntities()
{ {
m_EntitiesCriticalSection->Lock(); m_EntitiesCriticalSection->Lock();
} }
void cWorld::UnlockEntities() void cWorld::UnlockEntities()
{ {
m_EntitiesCriticalSection->Unlock(); m_EntitiesCriticalSection->Unlock();
} }
void cWorld::LockChunks() void cWorld::LockChunks()
{ {
m_ChunksCriticalSection->Lock(); m_ChunksCriticalSection->Lock();
} }
void cWorld::UnlockChunks() void cWorld::UnlockChunks()
{ {
m_ChunksCriticalSection->Unlock(); m_ChunksCriticalSection->Unlock();
} }
void cWorld::ReSpreadLighting( const ptr_cChunk& a_Chunk ) void cWorld::ReSpreadLighting( const ptr_cChunk& a_Chunk )
{ {
LockChunks(); LockChunks();
@ -1112,6 +1172,10 @@ void cWorld::ReSpreadLighting( const ptr_cChunk& a_Chunk )
UnlockChunks(); UnlockChunks();
} }
void cWorld::RemoveSpread( const ptr_cChunk& a_Chunk ) void cWorld::RemoveSpread( const ptr_cChunk& a_Chunk )
{ {
LockChunks(); LockChunks();
@ -1120,6 +1184,9 @@ void cWorld::RemoveSpread( const ptr_cChunk& a_Chunk )
} }
/************************************************************************/ /************************************************************************/
/* Get and set */ /* Get and set */
/************************************************************************/ /************************************************************************/
@ -1131,35 +1198,74 @@ void cWorld::RemoveSpread( const ptr_cChunk& a_Chunk )
// { // {
// return m_pState->m_Clients; // return m_pState->m_Clients;
// } // }
cWorld::EntityList & cWorld::GetEntities() cWorld::EntityList & cWorld::GetEntities()
{ {
return m_pState->AllEntities; return m_pState->AllEntities;
} }
void cWorld::AddEntity( cEntity* a_Entity ) void cWorld::AddEntity( cEntity* a_Entity )
{ {
m_pState->AllEntities.push_back( a_Entity ); m_pState->AllEntities.push_back( a_Entity );
} }
cWorld::PlayerList & cWorld::GetAllPlayers() cWorld::PlayerList & cWorld::GetAllPlayers()
{ {
return m_pState->Players; return m_pState->Players;
} }
unsigned int cWorld::GetNumPlayers() unsigned int cWorld::GetNumPlayers()
{ {
return m_pState->Players.size(); return m_pState->Players.size();
} }
void cWorld::AddToRemoveEntityQueue( cEntity & a_Entity ) void cWorld::AddToRemoveEntityQueue( cEntity & a_Entity )
{ {
m_pState->AllEntities.remove( &a_Entity); m_pState->AllEntities.remove( &a_Entity);
m_pState->RemoveEntityQueue.push_back( &a_Entity ); m_pState->RemoveEntityQueue.push_back( &a_Entity );
} }
const char* cWorld::GetName() const char* cWorld::GetName()
{ {
return m_pState->WorldName.c_str(); return m_pState->WorldName.c_str();
} }
int cWorld::GetNumChunks()
int cWorld::GetNumChunks(void)
{ {
LockChunks(); LockChunks();
int NumChunks = m_ChunkMap->GetNumChunks(); int NumChunks = m_ChunkMap->GetNumChunks();
UnlockChunks(); UnlockChunks();
return NumChunks; return NumChunks;
} }

View File

@ -364,7 +364,7 @@
</div> </div>
<!-- // #containerHolder --> <!-- // #containerHolder -->
<p id="footer">Memory Usage: {MEM}Mb</p> <p id="footer">Memory Usage: {MEM}Mb; Current chunk count: {NUMCHUNKS} </p>
</div> </div>
<!-- // #wrapper --> <!-- // #wrapper -->
</body> </body>