diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-02-08 19:57:04 +0100 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-02-08 19:57:04 +0100 |
commit | a204e3325010fd7baa8f30a5b05e3ba8450a73c7 (patch) | |
tree | f2ce933d000a1294c67cb92ab300ffd2aa56a7f8 /source | |
parent | cPluginManager: slight cleanup (diff) | |
download | cuberite-a204e3325010fd7baa8f30a5b05e3ba8450a73c7.tar cuberite-a204e3325010fd7baa8f30a5b05e3ba8450a73c7.tar.gz cuberite-a204e3325010fd7baa8f30a5b05e3ba8450a73c7.tar.bz2 cuberite-a204e3325010fd7baa8f30a5b05e3ba8450a73c7.tar.lz cuberite-a204e3325010fd7baa8f30a5b05e3ba8450a73c7.tar.xz cuberite-a204e3325010fd7baa8f30a5b05e3ba8450a73c7.tar.zst cuberite-a204e3325010fd7baa8f30a5b05e3ba8450a73c7.zip |
Diffstat (limited to '')
-rw-r--r-- | source/cRoot.cpp | 14 | ||||
-rw-r--r-- | source/cRoot.h | 2 | ||||
-rw-r--r-- | source/cWebAdmin.cpp | 14 | ||||
-rw-r--r-- | source/cWorld.cpp | 110 |
4 files changed, 133 insertions, 7 deletions
diff --git a/source/cRoot.cpp b/source/cRoot.cpp index 273bbe318..bea466092 100644 --- a/source/cRoot.cpp +++ b/source/cRoot.cpp @@ -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;
+}
+
+
+
+
diff --git a/source/cRoot.h b/source/cRoot.h index 3179d72b0..be5480e9e 100644 --- a/source/cRoot.h +++ b/source/cRoot.h @@ -51,6 +51,8 @@ public: void TickWorlds( float a_Dt );
+ int GetTotalChunkCount(void); // tolua_export
+
private:
void LoadWorlds();
diff --git a/source/cWebAdmin.cpp b/source/cWebAdmin.cpp index efac32866..b33d28e16 100644 --- a/source/cWebAdmin.cpp +++ b/source/cWebAdmin.cpp @@ -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;
}
diff --git a/source/cWorld.cpp b/source/cWorld.cpp index ba103c906..00dcbd80e 100644 --- a/source/cWorld.cpp +++ b/source/cWorld.cpp @@ -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;
-}
\ No newline at end of file +}
+
+
+
+
|