1
0

Fixed a few obsoleted functions

git-svn-id: http://mc-server.googlecode.com/svn/trunk@397 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2012-03-10 22:27:24 +00:00
parent f90a8928e7
commit 219be8186c
12 changed files with 83 additions and 49 deletions

View File

@ -58,7 +58,6 @@
#include <cstdio> #include <cstdio>
#include <ctime> #include <ctime>
#include <cmath> #include <cmath>
#pragma warning(disable:4996;disable:4800)
class MTRand { class MTRand {
// Data // Data

View File

@ -306,7 +306,7 @@ void cClientHandle::Authenticate(void)
LoginResponse.m_MapSeed = cRoot::Get()->GetWorld()->GetWorldSeed(); LoginResponse.m_MapSeed = cRoot::Get()->GetWorld()->GetWorldSeed();
#endif #endif
LoginResponse.m_Dimension = 0; LoginResponse.m_Dimension = 0;
LoginResponse.m_MaxPlayers = (unsigned char)cRoot::Get()->GetWorld()->GetMaxPlayers(); LoginResponse.m_MaxPlayers = (unsigned char)cRoot::Get()->GetDefaultWorld()->GetMaxPlayers();
LoginResponse.m_Difficulty = 2; LoginResponse.m_Difficulty = 2;
Send(LoginResponse); Send(LoginResponse);
@ -627,11 +627,11 @@ void cClientHandle::HandlePing(void)
// Somebody tries to retrieve information about the server // Somebody tries to retrieve information about the server
AString Reply; AString Reply;
Printf(Reply, "%s%s%i%s%i", Printf(Reply, "%s%s%i%s%i",
cRoot::Get()->GetWorld()->GetDescription().c_str(), cRoot::Get()->GetDefaultWorld()->GetDescription().c_str(),
cChatColor::Delimiter.c_str(), cChatColor::Delimiter.c_str(),
cRoot::Get()->GetWorld()->GetNumPlayers(), cRoot::Get()->GetDefaultWorld()->GetNumPlayers(),
cChatColor::Delimiter.c_str(), cChatColor::Delimiter.c_str(),
cRoot::Get()->GetWorld()->GetMaxPlayers() cRoot::Get()->GetDefaultWorld()->GetMaxPlayers()
); );
Kick(Reply.c_str()); Kick(Reply.c_str());
} }
@ -656,7 +656,7 @@ void cClientHandle::HandleHandshake(cPacket_Handshake * a_Packet)
LOG("HANDSHAKE %s", m_Username.c_str()); LOG("HANDSHAKE %s", m_Username.c_str());
if (cRoot::Get()->GetWorld()->GetNumPlayers() >= cRoot::Get()->GetWorld()->GetMaxPlayers()) if (cRoot::Get()->GetDefaultWorld()->GetNumPlayers() >= cRoot::Get()->GetDefaultWorld()->GetMaxPlayers())
{ {
Kick("The server is currently full :(-- Try again later"); Kick("The server is currently full :(-- Try again later");
return; return;
@ -1647,8 +1647,10 @@ void cClientHandle::HandleKeepAlive(cPacket_KeepAlive * a_Packet)
bool cClientHandle::CheckBlockInteractionsRate(void) bool cClientHandle::CheckBlockInteractionsRate(void)
{ {
ASSERT(m_Player != NULL);
ASSERT(m_Player->GetWorld() != NULL);
int LastActionCnt = m_Player->GetLastBlockActionCnt(); int LastActionCnt = m_Player->GetLastBlockActionCnt();
if ((cRoot::Get()->GetWorld()->GetTime() - m_Player->GetLastBlockActionTime()) < 0.1) if ((m_Player->GetWorld()->GetTime() - m_Player->GetLastBlockActionTime()) < 0.1)
{ {
// Limit the number of block interactions per tick // Limit the number of block interactions per tick
m_Player->SetLastBlockActionTime(); //Player tried to interact with a block. Reset last block interation time. m_Player->SetLastBlockActionTime(); //Player tried to interact with a block. Reset last block interation time.

View File

@ -506,7 +506,7 @@ cPlayer * cMonster::FindClosestPlayer(void)
void cMonster::GetMonsterConfig(const char* pm_name) void cMonster::GetMonsterConfig(const char* pm_name)
{ {
cRoot::Get()->GetMonsterConfig()->Get()->AssignAttributes(this, pm_name); cRoot::Get()->GetMonsterConfig()->AssignAttributes(this, pm_name);
} }

View File

@ -112,11 +112,3 @@ void cMonsterConfig::AssignAttributes(cMonster *m, const char* n)
// _X: WTF?
cMonsterConfig *cMonsterConfig::Get() {
return this;
}

View File

@ -7,9 +7,6 @@ public:
cMonsterConfig(void); cMonsterConfig(void);
~cMonsterConfig(); ~cMonsterConfig();
// _X: WTF? shouldn't this be static? Setting to OBSOLETE
OBSOLETE cMonsterConfig *Get();
void AssignAttributes(cMonster *m, const char* n); void AssignAttributes(cMonster *m, const char* n);
private: private:

View File

@ -463,7 +463,10 @@ void cPlayer::CloseWindow(char a_WindowType)
void cPlayer::SetLastBlockActionTime() void cPlayer::SetLastBlockActionTime()
{ {
m_LastBlockActionTime = cRoot::Get()->GetWorld()->GetTime(); if (m_World != NULL)
{
m_LastBlockActionTime = m_World->GetTime();
}
} }

View File

@ -364,3 +364,31 @@ int cRoot::GetTotalChunkCount(void)
void cRoot::SaveAllChunks(void)
{
for (WorldMap::iterator itr = m_pState->WorldsByName.begin(); itr != m_pState->WorldsByName.end(); ++itr)
{
itr->second->SaveAllChunks();
}
}
bool cRoot::ForEachPlayer(cPlayerListCallback & a_Callback)
{
for (WorldMap::iterator itr = m_pState->WorldsByName.begin(); itr != m_pState->WorldsByName.end(); ++itr)
{
if (!itr->second->ForEachPlayer(a_Callback))
{
return false;
}
}
return true;
}

View File

@ -19,6 +19,8 @@ class cWebAdmin;
class cPluginManager; class cPluginManager;
class cServer; class cServer;
class cWorld; class cWorld;
class cPlayer;
typedef cItemCallback<cPlayer> cPlayerListCallback;
@ -56,6 +58,12 @@ public:
int GetTotalChunkCount(void); // tolua_export int GetTotalChunkCount(void); // tolua_export
/// Saves all chunks in all worlds
void SaveAllChunks(void);
/// Calls the callback for each player in all worlds
bool ForEachPlayer(cPlayerListCallback & a_Callback);
private: private:
void LoadGlobalSettings(); void LoadGlobalSettings();

View File

@ -520,7 +520,7 @@ void cServer::ServerCommand( const char * a_Cmd )
} }
if( split[0].compare( "save-all" ) == 0 ) if( split[0].compare( "save-all" ) == 0 )
{ {
cRoot::Get()->GetWorld()->SaveAllChunks(); // TODO - Force ALL worlds to save their chunks cRoot::Get()->SaveAllChunks(); // TODO - Force ALL worlds to save their chunks
return; return;
} }
if (split[0].compare("unload") == 0) if (split[0].compare("unload") == 0)
@ -540,7 +540,7 @@ void cServer::ServerCommand( const char * a_Cmd )
return false; return false;
} }
} Logger; } Logger;
cRoot::Get()->GetWorld()->ForEachPlayer(Logger); cRoot::Get()->ForEachPlayer(Logger);
return; return;
} }
if( split[0].compare( "numchunks" ) == 0 ) if( split[0].compare( "numchunks" ) == 0 )
@ -596,7 +596,7 @@ void cServer::Shutdown()
m_bRestarting = true; m_bRestarting = true;
m_pState->RestartEvent.Wait(); m_pState->RestartEvent.Wait();
cRoot::Get()->GetWorld()->SaveAllChunks(); cRoot::Get()->SaveAllChunks();
cCSLock Lock(m_CSClients); cCSLock Lock(m_CSClients);
for( ClientList::iterator itr = m_Clients.begin(); itr != m_Clients.end(); ++itr ) for( ClientList::iterator itr = m_Clients.begin(); itr != m_Clients.end(); ++itr )

View File

@ -213,7 +213,7 @@ void cWebAdmin::Request_Handler(webserver::http_request* r)
Content += "<h4>Players:</h4><ul>"; Content += "<h4>Players:</h4><ul>";
cPlayerAccum PlayerAccum; cPlayerAccum PlayerAccum;
cWorld * World = cRoot::Get()->GetWorld(); // TODO - Create a list of worlds and players cWorld * World = cRoot::Get()->GetDefaultWorld(); // TODO - Create a list of worlds and players
World->ForEachPlayer(PlayerAccum); World->ForEachPlayer(PlayerAccum);
Content.append(PlayerAccum.m_Contents); Content.append(PlayerAccum.m_Contents);
Content += "</ul><br>"; Content += "</ul><br>";

View File

@ -132,8 +132,8 @@ protected:
cWorld* cWorld::GetWorld() cWorld* cWorld::GetWorld()
{ {
LOGWARN("WARNING: Using deprecated function cWorld::GetWorld() use cRoot::Get()->GetWorld() instead!"); LOGWARN("WARNING: Using deprecated function cWorld::GetWorld() use cRoot::Get()->GetDefaultWorld() instead!");
return cRoot::Get()->GetWorld(); return cRoot::Get()->GetDefaultWorld();
} }
@ -296,8 +296,13 @@ cWorld::cWorld( const AString & a_WorldName )
g_BlockTransparent[ E_BLOCK_TORCH ] = true; g_BlockTransparent[ E_BLOCK_TORCH ] = true;
g_BlockTransparent[ E_BLOCK_SIGN_POST ] = true; g_BlockTransparent[ E_BLOCK_SIGN_POST ] = true;
g_BlockTransparent[ E_BLOCK_WALLSIGN ] = true; g_BlockTransparent[ E_BLOCK_WALLSIGN ] = true;
g_BlockTransparent[ E_BLOCK_TALL_GRASS ] = true;
g_BlockTransparent[ E_BLOCK_YELLOW_FLOWER ] = true;
g_BlockTransparent[ E_BLOCK_RED_ROSE ] = true;
g_BlockTransparent[ E_BLOCK_RED_MUSHROOM ] = true;
g_BlockTransparent[ E_BLOCK_BROWN_MUSHROOM ] = true;
// TODO: Also set flowers, mushrooms etc as transparent // TODO: Any other transparent blocks?
// One hit break blocks // One hit break blocks
g_BlockOneHitDig[ E_BLOCK_SAPLING ] = true; g_BlockOneHitDig[ E_BLOCK_SAPLING ] = true;

View File

@ -48,7 +48,7 @@ class cWorld //tolua_export
{ //tolua_export { //tolua_export
public: public:
static cWorld* GetWorld(); //tolua_export OBSOLETE static cWorld* GetWorld(); //tolua_export
// Return time in seconds // Return time in seconds
inline static float GetTime() //tolua_export inline static float GetTime() //tolua_export