1
0

Lots of logging added

git-svn-id: http://mc-server.googlecode.com/svn/trunk@282 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2012-02-17 11:40:14 +00:00
parent 4a7883a5e3
commit 71097aa49b
6 changed files with 45 additions and 12 deletions

View File

@ -64,6 +64,7 @@ bool cWSSCompact::LoadChunk(const cChunkCoords & a_Chunk)
if (f == NULL) if (f == NULL)
{ {
// For some reason we couldn't locate the file // For some reason we couldn't locate the file
LOG("Cannot locate a proper PAK file for chunk [%d, %d]", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ);
return false; return false;
} }
@ -80,6 +81,7 @@ bool cWSSCompact::SaveChunk(const cChunkCoords & a_Chunk)
if (f == NULL) if (f == NULL)
{ {
// For some reason we couldn't locate the file // For some reason we couldn't locate the file
LOG("Cannot locate a proper PAK file for chunk [%d, %d]", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ);
return false; return false;
} }
return f->SaveChunk(a_Chunk, m_World); return f->SaveChunk(a_Chunk, m_World);
@ -299,7 +301,6 @@ bool cWSSCompact::cPAKFile::LoadChunk(const cChunkCoords & a_Chunk, int a_Offset
if (a_Header->m_UncompressedSize > cChunk::c_BlockDataSize ) // We gots some extra data :D if (a_Header->m_UncompressedSize > cChunk::c_BlockDataSize ) // We gots some extra data :D
{ {
LOGINFO("Parsing trailing JSON");
Json::Value root; // will contain the root value after parsing. Json::Value root; // will contain the root value after parsing.
Json::Reader reader; Json::Reader reader;
if ( !reader.parse( UncompressedData.data() + cChunk::c_BlockDataSize, root, false ) ) if ( !reader.parse( UncompressedData.data() + cChunk::c_BlockDataSize, root, false ) )
@ -351,6 +352,7 @@ bool cWSSCompact::cPAKFile::SaveChunkToData(const cChunkCoords & a_Chunk, cWorld
if (Serializer.GetBlockData().empty()) if (Serializer.GetBlockData().empty())
{ {
// Chunk not valid // Chunk not valid
LOG("cWSSCompact: Trying to save chunk [%d, %d] that has no data, ignoring request.", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ);
return false; return false;
} }
@ -380,6 +382,7 @@ bool cWSSCompact::cPAKFile::SaveChunkToData(const cChunkCoords & a_Chunk, cWorld
sChunkHeader * Header = new sChunkHeader; sChunkHeader * Header = new sChunkHeader;
if (Header == NULL) if (Header == NULL)
{ {
LOGWARNING("Cannot create a new chunk header to save chunk [%d, %d]", a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ);
return false; return false;
} }
Header->m_CompressedSize = (int)CompressedData.size(); Header->m_CompressedSize = (int)CompressedData.size();

View File

@ -127,8 +127,13 @@ void cLog::Log(const char * a_Format, va_list argList)
fflush(m_File); fflush(m_File);
} }
// Print to console:
printf("%s", Line.c_str()); printf("%s", Line.c_str());
#if defined (_WIN32) && defined(_DEBUG)
// In a Windows Debug build, output the log to debug console as well:
OutputDebugString(Line.c_str());
#endif // _WIN32
} }

View File

@ -26,7 +26,6 @@ struct cMonsterConfig::sAttributesStruct
struct cMonsterConfig::sMonsterConfigState struct cMonsterConfig::sMonsterConfigState
{ {
int TypeCount;
AString MonsterTypes; AString MonsterTypes;
std::list< sAttributesStruct > AttributesList; std::list< sAttributesStruct > AttributesList;
}; };
@ -35,10 +34,9 @@ struct cMonsterConfig::sMonsterConfigState
cMonsterConfig::cMonsterConfig(int TypeC) cMonsterConfig::cMonsterConfig(void)
: m_pState( new sMonsterConfigState ) : m_pState( new sMonsterConfigState )
{ {
m_pState->TypeCount = TypeC;
Initialize(); Initialize();
} }
@ -114,6 +112,7 @@ void cMonsterConfig::AssignAttributes(cMonster *m, const char* n)
// _X: WTF?
cMonsterConfig *cMonsterConfig::Get() { cMonsterConfig *cMonsterConfig::Get() {
return this; return this;
} }

View File

@ -4,9 +4,11 @@ class cMonster;
class cMonsterConfig class cMonsterConfig
{ {
public: public:
cMonsterConfig(int TypeC); cMonsterConfig(void);
~cMonsterConfig(); ~cMonsterConfig();
cMonsterConfig *Get();
// _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);

View File

@ -94,8 +94,10 @@ void cRoot::Start()
cFileFormatUpdater::UpdateFileFormat(); cFileFormatUpdater::UpdateFileFormat();
LOG("Creating new server instance...");
m_Server = new cServer(); m_Server = new cServer();
LOG("Starting server...");
cIniFile IniFile("settings.ini"); IniFile.ReadFile(); cIniFile IniFile("settings.ini"); IniFile.ReadFile();
int Port = IniFile.GetValueI("Server", "Port", 25565 ); int Port = IniFile.GetValueI("Server", "Port", 25565 );
if(!m_Server->InitServer( Port )) if(!m_Server->InitServer( Port ))
@ -109,27 +111,39 @@ void cRoot::Start()
{ {
if( WebIniFile.GetValueB("WebAdmin", "Enabled", false ) == true ) if( WebIniFile.GetValueB("WebAdmin", "Enabled", false ) == true )
{ {
LOG("Creating WebAdmin...");
m_WebAdmin = new cWebAdmin(8080); m_WebAdmin = new cWebAdmin(8080);
} }
} }
LOG("Loading settings...");
m_GroupManager = new cGroupManager(); m_GroupManager = new cGroupManager();
m_RecipeChecker = new cRecipeChecker(); m_RecipeChecker = new cRecipeChecker();
m_FurnaceRecipe = new cFurnaceRecipe(); m_FurnaceRecipe = new cFurnaceRecipe();
LOG("Loading worlds...");
LoadWorlds(); LoadWorlds();
LOG("Loading plugin manager...");
m_PluginManager = new cPluginManager(); // This should be last m_PluginManager = new cPluginManager(); // This should be last
m_PluginManager->ReloadPluginsNow(); m_PluginManager->ReloadPluginsNow();
m_MonsterConfig = new cMonsterConfig(2);
LOG("Loading MonsterConfig...");
m_MonsterConfig = new cMonsterConfig;
// This sets stuff in motion // This sets stuff in motion
LOG("Starting Authenticator...");
m_Authenticator.Start(); m_Authenticator.Start();
LOG("Starting server...");
m_Server->StartListenThread(); m_Server->StartListenThread();
//cHeartBeat* HeartBeat = new cHeartBeat(); //cHeartBeat* HeartBeat = new cHeartBeat();
LOG("Starting InputThread...");
m_InputThread = new cThread( InputThread, this, "cRoot::InputThread" ); m_InputThread = new cThread( InputThread, this, "cRoot::InputThread" );
m_InputThread->Start( true ); m_InputThread->Start( true );
LOG("Initialization done, server running now.");
while( !m_bStop && !m_bRestart ) // These are modified by external threads while( !m_bStop && !m_bRestart ) // These are modified by external threads
{ {
cSleep::MilliSleep( 1000 ); cSleep::MilliSleep( 1000 );
@ -138,17 +152,27 @@ void cRoot::Start()
delete m_InputThread; m_InputThread = 0; delete m_InputThread; m_InputThread = 0;
// Deallocate stuffs // Deallocate stuffs
LOG("Shutting down server...");
m_Server->Shutdown(); // This waits for threads to stop and d/c clients m_Server->Shutdown(); // This waits for threads to stop and d/c clients
LOG("Stopping authenticator...");
m_Authenticator.Stop(); m_Authenticator.Stop();
LOG("Stopping plugin manager...");
delete m_PluginManager; m_PluginManager = 0; // This should be first delete m_PluginManager; m_PluginManager = 0; // This should be first
LOG("Freeing MonsterConfig...");
delete m_MonsterConfig; m_MonsterConfig = 0; delete m_MonsterConfig; m_MonsterConfig = 0;
if( m_WebAdmin ) { delete m_WebAdmin; m_WebAdmin = 0; } LOG("Stopping WebAdmin...");
delete m_WebAdmin; m_WebAdmin = 0;
LOG("Unloading recipes...");
delete m_FurnaceRecipe; m_FurnaceRecipe = 0; delete m_FurnaceRecipe; m_FurnaceRecipe = 0;
delete m_RecipeChecker; m_RecipeChecker = 0; delete m_RecipeChecker; m_RecipeChecker = 0;
LOG("Forgetting groups...");
delete m_GroupManager; m_GroupManager = 0; delete m_GroupManager; m_GroupManager = 0;
LOG("Unloading worlds...");
UnloadWorlds(); UnloadWorlds();
LOG("Destroying server...");
//delete HeartBeat; HeartBeat = 0; //delete HeartBeat; HeartBeat = 0;
delete m_Server; m_Server = 0; delete m_Server; m_Server = 0;
LOG("Shutdown done.");
} }
delete m_Log; m_Log = 0; delete m_Log; m_Log = 0;
@ -249,9 +273,9 @@ void cRoot::TickWorlds( float a_Dt )
void cRoot::ServerCommand( const char* a_Cmd ) void cRoot::ServerCommand( const char * a_Cmd )
{ {
//LOG("Command: %s", a_Cmd ); LOG("Server console command: \"%s\"", a_Cmd );
m_Server->ServerCommand( a_Cmd ); m_Server->ServerCommand( a_Cmd );
if( strcmp(a_Cmd, "stop") == 0 ) if( strcmp(a_Cmd, "stop") == 0 )
{ {

View File

@ -476,7 +476,7 @@ void cServer::ServerCommand( const char * a_Cmd )
} }
if( split[0].compare( "numchunks" ) == 0 ) if( split[0].compare( "numchunks" ) == 0 )
{ {
LOG("Num loaded chunks: %i\n", cRoot::Get()->GetTotalChunkCount() ); LOG("Num loaded chunks: %i", cRoot::Get()->GetTotalChunkCount() );
return; return;
} }