diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-02-01 15:08:12 +0100 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-02-01 15:08:12 +0100 |
commit | cb1ce1416948bea94bd0bb4bb3a66a74cc16557b (patch) | |
tree | 9809332db528931f427a3ca6f46d46f561a644be | |
parent | AString logging fix (diff) | |
download | cuberite-cb1ce1416948bea94bd0bb4bb3a66a74cc16557b.tar cuberite-cb1ce1416948bea94bd0bb4bb3a66a74cc16557b.tar.gz cuberite-cb1ce1416948bea94bd0bb4bb3a66a74cc16557b.tar.bz2 cuberite-cb1ce1416948bea94bd0bb4bb3a66a74cc16557b.tar.lz cuberite-cb1ce1416948bea94bd0bb4bb3a66a74cc16557b.tar.xz cuberite-cb1ce1416948bea94bd0bb4bb3a66a74cc16557b.tar.zst cuberite-cb1ce1416948bea94bd0bb4bb3a66a74cc16557b.zip |
Diffstat (limited to '')
-rw-r--r-- | source/cChunkMap.cpp | 14 | ||||
-rw-r--r-- | source/cEvent.cpp | 2 | ||||
-rw-r--r-- | source/cHeartBeat.cpp | 2 | ||||
-rw-r--r-- | source/cLog.cpp | 14 | ||||
-rw-r--r-- | source/cPlayer.cpp | 8 | ||||
-rw-r--r-- | source/cSemaphore.cpp | 2 | ||||
-rw-r--r-- | source/cWebAdmin.cpp | 6 |
7 files changed, 27 insertions, 21 deletions
diff --git a/source/cChunkMap.cpp b/source/cChunkMap.cpp index 92a9b67eb..a5721026f 100644 --- a/source/cChunkMap.cpp +++ b/source/cChunkMap.cpp @@ -461,7 +461,7 @@ void cChunkMap::SaveLayer( cChunkLayer* a_Layer ) cFile f;
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;
}
@@ -530,7 +530,7 @@ void cChunkMap::SaveLayer( cChunkLayer* a_Layer ) #define READ(File, 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; \
}
@@ -553,21 +553,21 @@ cChunkMap::cChunkLayer* cChunkMap::LoadLayer(int a_LayerX, int a_LayerZ ) READ(f, PakVersion);
if (PakVersion != 1)
{
- LOGERROR("WRONG PAK VERSION in file \"%s\"!", SourceFile);
+ LOGERROR("WRONG PAK VERSION in file \"%s\"!", SourceFile.c_str());
return NULL;
}
READ(f, ChunkVersion);
if (ChunkVersion != 1 )
{
- LOGERROR("WRONG CHUNK VERSION in file \"%s\"!", SourceFile);
+ LOGERROR("WRONG CHUNK VERSION in file \"%s\"!", SourceFile.c_str());
return NULL;
}
short NumChunks = 0;
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
Layer->m_X = a_LayerX;
@@ -586,7 +586,7 @@ cChunkMap::cChunkLayer* cChunkMap::LoadLayer(int a_LayerX, int a_LayerZ ) 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;
}
else
@@ -604,7 +604,7 @@ cChunkMap::cChunkLayer* cChunkMap::LoadLayer(int a_LayerX, int a_LayerZ ) Data->m_Compressed = new char[ 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;
}
}
diff --git a/source/cEvent.cpp b/source/cEvent.cpp index 9b3ddcfdf..bf3109cf4 100644 --- a/source/cEvent.cpp +++ b/source/cEvent.cpp @@ -44,7 +44,7 @@ cEvent::cEvent(void) }
else
{
- if( sem_unlink( c_Str ) != 0 )
+ if( sem_unlink(EventName.c_str()) != 0 )
{
LOGWARN("ERROR: Could not unlink cEvent. (%i)", errno);
}
diff --git a/source/cHeartBeat.cpp b/source/cHeartBeat.cpp index fd1cdc805..e8c49454d 100644 --- a/source/cHeartBeat.cpp +++ b/source/cHeartBeat.cpp @@ -119,7 +119,7 @@ void cHeartBeat::SendUpdate() AString sPort;
Printf(sPort, "%i", Port);
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());
}
}
diff --git a/source/cLog.cpp b/source/cLog.cpp index b83d3cc37..5a93ddd0f 100644 --- a/source/cLog.cpp +++ b/source/cLog.cpp @@ -69,7 +69,7 @@ void cLog::OpenLog( const char* a_FileName ) #ifdef _WIN32
fopen_s( &m_File, a_FileName, "a+" );
#else
- m_File = fopen(a_FileName, "a+" );
+ m_File = fopen(a_FileName, "a+" );
#endif
}
@@ -94,10 +94,18 @@ 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;
- AppendVPrintf(Message, a_Format, argList);
+ if (argList != NULL)
+ {
+ 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 ( &rawtime );
diff --git a/source/cPlayer.cpp b/source/cPlayer.cpp index f10dc3586..982427a86 100644 --- a/source/cPlayer.cpp +++ b/source/cPlayer.cpp @@ -799,7 +799,7 @@ bool cPlayer::LoadFromDisk() std::auto_ptr<char> buffer(new char[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;
}
f.Close();
@@ -808,7 +808,7 @@ bool cPlayer::LoadFromDisk() Json::Reader reader;
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();
@@ -882,12 +882,12 @@ bool cPlayer::SaveToDisk() cFile f;
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;
}
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 true;
diff --git a/source/cSemaphore.cpp b/source/cSemaphore.cpp index 438b83e2c..6fe8f6d5b 100644 --- a/source/cSemaphore.cpp +++ b/source/cSemaphore.cpp @@ -28,7 +28,7 @@ cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /* }
else
{
- if( sem_unlink( c_Str ) != 0 )
+ if( sem_unlink(Name.c_str()) != 0 )
{
LOG("ERROR: Could not unlink cSemaphore. (%i)", errno);
}
diff --git a/source/cWebAdmin.cpp b/source/cWebAdmin.cpp index 9707d3158..cd663d7b6 100644 --- a/source/cWebAdmin.cpp +++ b/source/cWebAdmin.cpp @@ -190,10 +190,8 @@ void cWebAdmin::Request_Handler(webserver::http_request* r) const cPluginManager::PluginList & List = PM->GetAllPlugins();
for( cPluginManager::PluginList::const_iterator itr = List.begin(); itr != List.end(); ++itr )
{
- char c_VersionNum[32]; // 32 digits should be enough? XD
- sprintf_s( c_VersionNum, 32, "%i", (*itr)->GetVersion() );
- Content += std::string("<li>") + std::string( (*itr)->GetName() ) + " V. " + std::string( c_VersionNum ) + "</li>";
-
+ AString VersionNum;
+ AppendPrintf(Content, "<li>%s V.%i</li>", (*itr)->GetName(), (*itr)->GetVersion());
}
}
Content += "</ul>";
|