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 );
int GetTotalChunkCount(void); // tolua_export
private:
void LoadWorlds();

View File

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

View File

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

View File

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