diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-02-17 12:40:14 +0100 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-02-17 12:40:14 +0100 |
commit | 71097aa49b7ec3fc258167e528a0c9f37f259c71 (patch) | |
tree | 1fc97c2339345a7c31184b2bda1557d10ef7830f | |
parent | git-svn-id: http://mc-server.googlecode.com/svn/trunk@281 0a769ca7-a7f5-676a-18bf-c427514a06d6 (diff) | |
download | cuberite-71097aa49b7ec3fc258167e528a0c9f37f259c71.tar cuberite-71097aa49b7ec3fc258167e528a0c9f37f259c71.tar.gz cuberite-71097aa49b7ec3fc258167e528a0c9f37f259c71.tar.bz2 cuberite-71097aa49b7ec3fc258167e528a0c9f37f259c71.tar.lz cuberite-71097aa49b7ec3fc258167e528a0c9f37f259c71.tar.xz cuberite-71097aa49b7ec3fc258167e528a0c9f37f259c71.tar.zst cuberite-71097aa49b7ec3fc258167e528a0c9f37f259c71.zip |
-rw-r--r-- | source/WSSCompact.cpp | 5 | ||||
-rw-r--r-- | source/cLog.cpp | 7 | ||||
-rw-r--r-- | source/cMonsterConfig.cpp | 5 | ||||
-rw-r--r-- | source/cMonsterConfig.h | 6 | ||||
-rw-r--r-- | source/cRoot.cpp | 32 | ||||
-rw-r--r-- | source/cServer.cpp | 2 |
6 files changed, 45 insertions, 12 deletions
diff --git a/source/WSSCompact.cpp b/source/WSSCompact.cpp index c023875a5..04fb45351 100644 --- a/source/WSSCompact.cpp +++ b/source/WSSCompact.cpp @@ -64,6 +64,7 @@ bool cWSSCompact::LoadChunk(const cChunkCoords & a_Chunk) if (f == NULL)
{
// 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;
}
@@ -80,6 +81,7 @@ bool cWSSCompact::SaveChunk(const cChunkCoords & a_Chunk) if (f == NULL)
{
// 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 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
{
- LOGINFO("Parsing trailing JSON");
Json::Value root; // will contain the root value after parsing.
Json::Reader reader;
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())
{
// 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;
}
@@ -380,6 +382,7 @@ bool cWSSCompact::cPAKFile::SaveChunkToData(const cChunkCoords & a_Chunk, cWorld sChunkHeader * Header = new sChunkHeader;
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;
}
Header->m_CompressedSize = (int)CompressedData.size();
diff --git a/source/cLog.cpp b/source/cLog.cpp index 5a93ddd0f..f44dedf1f 100644 --- a/source/cLog.cpp +++ b/source/cLog.cpp @@ -127,8 +127,13 @@ void cLog::Log(const char * a_Format, va_list argList) fflush(m_File);
}
-
+ // Print to console:
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
}
diff --git a/source/cMonsterConfig.cpp b/source/cMonsterConfig.cpp index 7f4389e5f..a0ff9914d 100644 --- a/source/cMonsterConfig.cpp +++ b/source/cMonsterConfig.cpp @@ -26,7 +26,6 @@ struct cMonsterConfig::sAttributesStruct struct cMonsterConfig::sMonsterConfigState
{
- int TypeCount;
AString MonsterTypes;
std::list< sAttributesStruct > AttributesList;
};
@@ -35,10 +34,9 @@ struct cMonsterConfig::sMonsterConfigState -cMonsterConfig::cMonsterConfig(int TypeC)
+cMonsterConfig::cMonsterConfig(void)
: m_pState( new sMonsterConfigState )
{
- m_pState->TypeCount = TypeC;
Initialize();
}
@@ -114,6 +112,7 @@ void cMonsterConfig::AssignAttributes(cMonster *m, const char* n) +// _X: WTF?
cMonsterConfig *cMonsterConfig::Get() {
return this;
}
diff --git a/source/cMonsterConfig.h b/source/cMonsterConfig.h index 12b03d8e1..8c0807d73 100644 --- a/source/cMonsterConfig.h +++ b/source/cMonsterConfig.h @@ -4,9 +4,11 @@ class cMonster; class cMonsterConfig
{
public:
- cMonsterConfig(int TypeC);
+ cMonsterConfig(void);
~cMonsterConfig();
- cMonsterConfig *Get();
+
+ // _X: WTF? shouldn't this be static? Setting to OBSOLETE
+ OBSOLETE cMonsterConfig *Get();
void AssignAttributes(cMonster *m, const char* n);
diff --git a/source/cRoot.cpp b/source/cRoot.cpp index 6fa467e93..db5c20bd1 100644 --- a/source/cRoot.cpp +++ b/source/cRoot.cpp @@ -94,8 +94,10 @@ void cRoot::Start() cFileFormatUpdater::UpdateFileFormat();
+ LOG("Creating new server instance...");
m_Server = new cServer();
+ LOG("Starting server...");
cIniFile IniFile("settings.ini"); IniFile.ReadFile();
int Port = IniFile.GetValueI("Server", "Port", 25565 );
if(!m_Server->InitServer( Port ))
@@ -109,27 +111,39 @@ void cRoot::Start() {
if( WebIniFile.GetValueB("WebAdmin", "Enabled", false ) == true )
{
+ LOG("Creating WebAdmin...");
m_WebAdmin = new cWebAdmin(8080);
}
}
+ LOG("Loading settings...");
m_GroupManager = new cGroupManager();
m_RecipeChecker = new cRecipeChecker();
m_FurnaceRecipe = new cFurnaceRecipe();
+
+ LOG("Loading worlds...");
LoadWorlds();
+ LOG("Loading plugin manager...");
m_PluginManager = new cPluginManager(); // This should be last
m_PluginManager->ReloadPluginsNow();
- m_MonsterConfig = new cMonsterConfig(2);
+
+ LOG("Loading MonsterConfig...");
+ m_MonsterConfig = new cMonsterConfig;
// This sets stuff in motion
+ LOG("Starting Authenticator...");
m_Authenticator.Start();
+
+ LOG("Starting server...");
m_Server->StartListenThread();
//cHeartBeat* HeartBeat = new cHeartBeat();
+ LOG("Starting InputThread...");
m_InputThread = new cThread( InputThread, this, "cRoot::InputThread" );
m_InputThread->Start( true );
+ LOG("Initialization done, server running now.");
while( !m_bStop && !m_bRestart ) // These are modified by external threads
{
cSleep::MilliSleep( 1000 );
@@ -138,17 +152,27 @@ void cRoot::Start() delete m_InputThread; m_InputThread = 0;
// Deallocate stuffs
+ LOG("Shutting down server...");
m_Server->Shutdown(); // This waits for threads to stop and d/c clients
+ LOG("Stopping authenticator...");
m_Authenticator.Stop();
+ LOG("Stopping plugin manager...");
delete m_PluginManager; m_PluginManager = 0; // This should be first
+ LOG("Freeing MonsterConfig...");
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_RecipeChecker; m_RecipeChecker = 0;
+ LOG("Forgetting groups...");
delete m_GroupManager; m_GroupManager = 0;
+ LOG("Unloading worlds...");
UnloadWorlds();
+ LOG("Destroying server...");
//delete HeartBeat; HeartBeat = 0;
delete m_Server; m_Server = 0;
+ LOG("Shutdown done.");
}
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 );
if( strcmp(a_Cmd, "stop") == 0 )
{
diff --git a/source/cServer.cpp b/source/cServer.cpp index 4411dfb78..a1ff76292 100644 --- a/source/cServer.cpp +++ b/source/cServer.cpp @@ -476,7 +476,7 @@ void cServer::ServerCommand( const char * a_Cmd ) }
if( split[0].compare( "numchunks" ) == 0 )
{
- LOG("Num loaded chunks: %i\n", cRoot::Get()->GetTotalChunkCount() );
+ LOG("Num loaded chunks: %i", cRoot::Get()->GetTotalChunkCount() );
return;
}
|