1
0

AString logging fix 2

git-svn-id: http://mc-server.googlecode.com/svn/trunk@218 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2012-02-01 14:08:12 +00:00
parent ef196ec22f
commit cb1ce14169
7 changed files with 27 additions and 21 deletions

View File

@ -461,7 +461,7 @@ void cChunkMap::SaveLayer( cChunkLayer* a_Layer )
cFile f; cFile f;
if (!f.Open(SourceFile, cFile::fmWrite)) if (!f.Open(SourceFile, cFile::fmWrite))
{ {
LOGERROR("ERROR: Could not write to file %s", SourceFile ); LOGERROR("ERROR: Could not write to file %s", SourceFile.c_str());
return; return;
} }
@ -530,7 +530,7 @@ void cChunkMap::SaveLayer( cChunkLayer* a_Layer )
#define READ(File, Var) \ #define READ(File, Var) \
if (File.Read(&Var, sizeof(Var)) != sizeof(Var)) \ if (File.Read(&Var, sizeof(Var)) != sizeof(Var)) \
{ \ { \
LOGERROR("ERROR READING %s FROM FILE %s (line %d)", #Var, SourceFile, __LINE__); \ LOGERROR("ERROR READING %s FROM FILE %s (line %d)", #Var, SourceFile.c_str(), __LINE__); \
return NULL; \ return NULL; \
} }
@ -553,21 +553,21 @@ cChunkMap::cChunkLayer* cChunkMap::LoadLayer(int a_LayerX, int a_LayerZ )
READ(f, PakVersion); READ(f, PakVersion);
if (PakVersion != 1) if (PakVersion != 1)
{ {
LOGERROR("WRONG PAK VERSION in file \"%s\"!", SourceFile); LOGERROR("WRONG PAK VERSION in file \"%s\"!", SourceFile.c_str());
return NULL; return NULL;
} }
READ(f, ChunkVersion); READ(f, ChunkVersion);
if (ChunkVersion != 1 ) if (ChunkVersion != 1 )
{ {
LOGERROR("WRONG CHUNK VERSION in file \"%s\"!", SourceFile); LOGERROR("WRONG CHUNK VERSION in file \"%s\"!", SourceFile.c_str());
return NULL; return NULL;
} }
short NumChunks = 0; short NumChunks = 0;
READ(f, NumChunks); READ(f, NumChunks);
LOG("Num chunks in file \"%s\": %i", SourceFile, NumChunks); LOG("Num chunks in file \"%s\": %i", SourceFile.c_str(), NumChunks);
std::auto_ptr<cChunkLayer> Layer(new cChunkLayer(LAYER_SIZE * LAYER_SIZE)); // The auto_ptr deletes the Layer if we exit with an error std::auto_ptr<cChunkLayer> Layer(new cChunkLayer(LAYER_SIZE * LAYER_SIZE)); // The auto_ptr deletes the Layer if we exit with an error
Layer->m_X = a_LayerX; Layer->m_X = a_LayerX;
@ -586,7 +586,7 @@ cChunkMap::cChunkLayer* cChunkMap::LoadLayer(int a_LayerX, int a_LayerZ )
if (Data == NULL) if (Data == NULL)
{ {
LOGERROR("Chunk with wrong coordinates in pak file! %i %i", ChunkX, ChunkZ ); LOGERROR("Chunk with wrong coordinates [%i, %i] in pak file \"%s\"!", ChunkX, ChunkZ, SourceFile.c_str());
return NULL; return NULL;
} }
else else
@ -604,7 +604,7 @@ cChunkMap::cChunkLayer* cChunkMap::LoadLayer(int a_LayerX, int a_LayerZ )
Data->m_Compressed = new char[ Data->m_CompressedSize ]; Data->m_Compressed = new char[ Data->m_CompressedSize ];
if (f.Read(Data->m_Compressed, Data->m_CompressedSize) != Data->m_CompressedSize) if (f.Read(Data->m_Compressed, Data->m_CompressedSize) != Data->m_CompressedSize)
{ {
LOGERROR("ERROR 8 READING FROM FILE %s", SourceFile); LOGERROR("ERROR reading compressed data for chunk #%i from file \"%s\"", i, SourceFile.c_str());
return NULL; return NULL;
} }
} }

View File

@ -44,7 +44,7 @@ cEvent::cEvent(void)
} }
else else
{ {
if( sem_unlink( c_Str ) != 0 ) if( sem_unlink(EventName.c_str()) != 0 )
{ {
LOGWARN("ERROR: Could not unlink cEvent. (%i)", errno); LOGWARN("ERROR: Could not unlink cEvent. (%i)", errno);
} }

View File

@ -119,7 +119,7 @@ void cHeartBeat::SendUpdate()
AString sPort; AString sPort;
Printf(sPort, "%i", Port); Printf(sPort, "%i", Port);
AString sChecksum = md5( m_ServerID + sPort ); AString sChecksum = md5( m_ServerID + sPort );
Printf(Msg, "GET http://master.mc-server.org/?update=%s&checksum=%s&port=%d\n", m_ServerID, sChecksum , Port); Printf(Msg, "GET http://master.mc-server.org/?update=%s&checksum=%s&port=%d\n", m_ServerID.c_str(), sChecksum.c_str(), Port);
SendMessage(Msg.c_str()); SendMessage(Msg.c_str());
} }
} }

View File

@ -97,7 +97,15 @@ void cLog::ClearLog()
void cLog::Log(const char * a_Format, va_list argList) void cLog::Log(const char * a_Format, va_list argList)
{ {
AString Message; AString Message;
if (argList != NULL)
{
AppendVPrintf(Message, a_Format, argList); AppendVPrintf(Message, a_Format, argList);
}
else
{
// This branch needs to be here because of *nix crashing in vsnprintf() when argList is NULL
Message.assign(a_Format);
}
time_t rawtime; time_t rawtime;
time ( &rawtime ); time ( &rawtime );

View File

@ -799,7 +799,7 @@ bool cPlayer::LoadFromDisk()
std::auto_ptr<char> buffer(new char[FileSize]); std::auto_ptr<char> buffer(new char[FileSize]);
if (f.Read(buffer.get(), FileSize) != FileSize) if (f.Read(buffer.get(), FileSize) != FileSize)
{ {
LOGERROR("ERROR READING FROM FILE \"%s\"", SourceFile); LOGERROR("ERROR READING FROM FILE \"%s\"", SourceFile.c_str());
return false; return false;
} }
f.Close(); f.Close();
@ -808,7 +808,7 @@ bool cPlayer::LoadFromDisk()
Json::Reader reader; Json::Reader reader;
if (!reader.parse(buffer.get(), root, false)) if (!reader.parse(buffer.get(), root, false))
{ {
LOGERROR("ERROR WHILE PARSING JSON FROM FILE %s", SourceFile); LOGERROR("ERROR WHILE PARSING JSON FROM FILE %s", SourceFile.c_str());
} }
buffer.reset(); buffer.reset();
@ -882,12 +882,12 @@ bool cPlayer::SaveToDisk()
cFile f; cFile f;
if (!f.Open(SourceFile, cFile::fmWrite)) if (!f.Open(SourceFile, cFile::fmWrite))
{ {
LOGERROR("ERROR WRITING PLAYER \"%s\" TO FILE \"%s\" - cannot open file", m_pState->PlayerName.c_str(), SourceFile); LOGERROR("ERROR WRITING PLAYER \"%s\" TO FILE \"%s\" - cannot open file", m_pState->PlayerName.c_str(), SourceFile.c_str());
return false; return false;
} }
if (f.Write(JsonData.c_str(), JsonData.size()) != JsonData.size()) if (f.Write(JsonData.c_str(), JsonData.size()) != JsonData.size())
{ {
LOGERROR("ERROR WRITING PLAYER JSON TO FILE \"%s\"", SourceFile); LOGERROR("ERROR WRITING PLAYER JSON TO FILE \"%s\"", SourceFile.c_str());
return false; return false;
} }
return true; return true;

View File

@ -28,7 +28,7 @@ cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /*
} }
else else
{ {
if( sem_unlink( c_Str ) != 0 ) if( sem_unlink(Name.c_str()) != 0 )
{ {
LOG("ERROR: Could not unlink cSemaphore. (%i)", errno); LOG("ERROR: Could not unlink cSemaphore. (%i)", errno);
} }

View File

@ -190,10 +190,8 @@ void cWebAdmin::Request_Handler(webserver::http_request* r)
const cPluginManager::PluginList & List = PM->GetAllPlugins(); const cPluginManager::PluginList & List = PM->GetAllPlugins();
for( cPluginManager::PluginList::const_iterator itr = List.begin(); itr != List.end(); ++itr ) for( cPluginManager::PluginList::const_iterator itr = List.begin(); itr != List.end(); ++itr )
{ {
char c_VersionNum[32]; // 32 digits should be enough? XD AString VersionNum;
sprintf_s( c_VersionNum, 32, "%i", (*itr)->GetVersion() ); AppendPrintf(Content, "<li>%s V.%i</li>", (*itr)->GetName(), (*itr)->GetVersion());
Content += std::string("<li>") + std::string( (*itr)->GetName() ) + " V. " + std::string( c_VersionNum ) + "</li>";
} }
} }
Content += "</ul>"; Content += "</ul>";