avoid static initialization order fiasco in soundman.cpp (#80)

when running the cmake Debug build instead of the ja2_vs2019.sln file s_SoundLog is undefined.
the most likely reason for that is that static objects in global scope
have unspecified initialization order. the problem is fixed if the
static SoundLog object is created inside the SoundLog(CHAR8*) function
instead.

also remove the comment whose meaning apparently has been lost to the
sands of time
This commit is contained in:
majcosta
2023-01-17 23:33:06 -08:00
committed by GitHub
parent e4295acfec
commit 6b0c704b19
+7 -10
View File
@@ -1852,16 +1852,6 @@ UINT32 uiCount;
return(FALSE);
}
// Lesh modifications
// Sound debug
static struct SoundLog {
sgp::Logger_ID id;
SoundLog() {
id = sgp::Logger::instance().createLogger();
sgp::Logger::instance().connectFile(id, SndDebugFileName, true, sgp::Logger::FLUSH_ON_DELETE);
}
} s_SoundLog;
//*****************************************************************************************
// SoundLog
// Writes string into log file
@@ -1872,6 +1862,13 @@ static struct SoundLog {
//*****************************************************************************************
void SoundLog(CHAR8 *strMessage)
{
static struct SoundLog {
sgp::Logger_ID id;
SoundLog() {
id = sgp::Logger::instance().createLogger();
sgp::Logger::instance().connectFile(id, SndDebugFileName, true, sgp::Logger::FLUSH_ON_DELETE);
}
} s_SoundLog;
#ifndef USE_VFS
if ((SndDebug = fopen(SndDebugFileName, "a+t")) != NULL)
{