mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
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:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user