Replaced CLogger::GetInstancePointer() calls with GetLogger()

master
krzys-h 2015-07-16 21:30:55 +02:00
parent c115d72d71
commit c8f6e8124e
12 changed files with 60 additions and 61 deletions

View File

@ -161,7 +161,7 @@ bool CInput::GetMouseButtonState(int index) const
void CInput::ResetKeyStates()
{
CLogger::GetInstancePointer()->Trace("Reset key states\n");
GetLogger()->Trace("Reset key states\n");
m_kmodState = 0;
m_keyMotion = Math::Vector(0.0f, 0.0f, 0.0f);
m_joyMotion = Math::Vector(0.0f, 0.0f, 0.0f);

View File

@ -46,7 +46,7 @@ void CPauseManager::SetPause(PauseType pause)
{
if (m_pause != pause)
{
CLogger::GetInstancePointer()->Info("Game paused - %s\n", GetPauseName(pause).c_str());
GetLogger()->Info("Game paused - %s\n", GetPauseName(pause).c_str());
CRobotMain::GetInstancePointer()->StartPauseMusic(pause);
}
@ -60,7 +60,7 @@ void CPauseManager::ClearPause()
{
if(m_pause != PAUSE_NONE)
{
CLogger::GetInstancePointer()->Info("Game resumed\n");
GetLogger()->Info("Game resumed\n");
m_sound->StopPauseMusic();
}

View File

@ -130,6 +130,5 @@ private:
//! Global function to get Logger instance
inline CLogger* GetLogger()
{
return CLogger::GetInstancePointer();
return GetLogger();
}

View File

@ -79,7 +79,7 @@ void CPathManager::SetSavePath(std::string savePath)
void CPathManager::AddMod(std::string modPath)
{
CLogger::GetInstancePointer()->Info("Loading mod: '%s'\n", modPath.c_str());
GetLogger()->Info("Loading mod: '%s'\n", modPath.c_str());
CResourceManager::AddLocation(modPath, true);
}
@ -107,7 +107,7 @@ std::string CPathManager::VerifyPaths()
#endif
if (! (boost::filesystem::exists(dataPath) && boost::filesystem::is_directory(dataPath)) )
{
CLogger::GetInstancePointer()->Error("Data directory '%s' doesn't exist or is not a directory\n", m_dataPath.c_str());
GetLogger()->Error("Data directory '%s' doesn't exist or is not a directory\n", m_dataPath.c_str());
return std::string("Could not read from data directory:\n") +
std::string("'") + m_dataPath + std::string("'\n") +
std::string("Please check your installation, or supply a valid data directory by -datadir option.");
@ -120,7 +120,7 @@ std::string CPathManager::VerifyPaths()
#endif
if (! (boost::filesystem::exists(langPath) && boost::filesystem::is_directory(langPath)) )
{
CLogger::GetInstancePointer()->Warn("Language path '%s' is invalid, assuming translation files not installed\n", m_langPath.c_str());
GetLogger()->Warn("Language path '%s' is invalid, assuming translation files not installed\n", m_langPath.c_str());
}
#if PLATFORM_WINDOWS
@ -139,8 +139,8 @@ void CPathManager::InitPaths()
LoadModsFromDir(m_dataPath+"/mods");
LoadModsFromDir(m_savePath+"/mods");
CLogger::GetInstancePointer()->Info("Data path: %s\n", m_dataPath.c_str());
CLogger::GetInstancePointer()->Info("Save path: %s\n", m_savePath.c_str());
GetLogger()->Info("Data path: %s\n", m_dataPath.c_str());
GetLogger()->Info("Save path: %s\n", m_savePath.c_str());
CResourceManager::AddLocation(m_dataPath, false);
CResourceManager::SetSaveLocation(m_savePath);
CResourceManager::AddLocation(m_savePath, true);
@ -165,7 +165,7 @@ void CPathManager::LoadModsFromDir(const std::string &dir)
}
catch(std::exception &e)
{
CLogger::GetInstancePointer()->Warn("Unable to load mods from directory '%s': %s\n", dir.c_str(), e.what());
GetLogger()->Warn("Unable to load mods from directory '%s': %s\n", dir.c_str(), e.what());
}
}

View File

@ -39,7 +39,7 @@ CResourceManager::CResourceManager(const char *argv0)
{
if (!PHYSFS_init(argv0))
{
CLogger::GetInstancePointer()->Error("Error while initializing physfs: %s\n", PHYSFS_getLastError());
GetLogger()->Error("Error while initializing physfs: %s\n", PHYSFS_getLastError());
assert(false);
}
PHYSFS_permitSymbolicLinks(1);
@ -52,7 +52,7 @@ CResourceManager::~CResourceManager()
{
if (!PHYSFS_deinit())
{
CLogger::GetInstancePointer()->Error("Error while deinitializing physfs: %s\n", PHYSFS_getLastError());
GetLogger()->Error("Error while deinitializing physfs: %s\n", PHYSFS_getLastError());
}
}
}
@ -67,7 +67,7 @@ bool CResourceManager::AddLocation(const std::string &location, bool prepend)
{
if (!PHYSFS_mount(location.c_str(), nullptr, prepend ? 0 : 1))
{
CLogger::GetInstancePointer()->Error("Error while mounting \"%s\": %s\n", location.c_str(), PHYSFS_getLastError());
GetLogger()->Error("Error while mounting \"%s\": %s\n", location.c_str(), PHYSFS_getLastError());
return false;
}
@ -79,7 +79,7 @@ bool CResourceManager::RemoveLocation(const std::string &location)
{
if (!PHYSFS_removeFromSearchPath(location.c_str()))
{
CLogger::GetInstancePointer()->Error("Error while unmounting \"%s\": %s\n", location.c_str(), PHYSFS_getLastError());
GetLogger()->Error("Error while unmounting \"%s\": %s\n", location.c_str(), PHYSFS_getLastError());
return false;
}
@ -91,7 +91,7 @@ bool CResourceManager::SetSaveLocation(const std::string &location)
{
if (!PHYSFS_setWriteDir(location.c_str()))
{
CLogger::GetInstancePointer()->Error("Error while setting save location to \"%s\": %s\n", location.c_str(), PHYSFS_getLastError());
GetLogger()->Error("Error while setting save location to \"%s\": %s\n", location.c_str(), PHYSFS_getLastError());
return false;
}

View File

@ -34,21 +34,21 @@ CSDLFileWrapper::CSDLFileWrapper(const std::string& filename)
{
if (!PHYSFS_isInit())
{
CLogger::GetInstancePointer()->Error("PHYSFS not initialized!\n");
GetLogger()->Error("PHYSFS not initialized!\n");
return;
}
PHYSFS_File *file = PHYSFS_openRead(filename.c_str());
if (file == nullptr)
{
CLogger::GetInstancePointer()->Error("Error opening file with PHYSFS: \"%s\"\n", filename.c_str());
GetLogger()->Error("Error opening file with PHYSFS: \"%s\"\n", filename.c_str());
return;
}
m_rwops = SDL_AllocRW();
if (m_rwops == nullptr)
{
CLogger::GetInstancePointer()->Error("Unable to allocate SDL_RWops for \"%s\"\n", filename.c_str());
GetLogger()->Error("Unable to allocate SDL_RWops for \"%s\"\n", filename.c_str());
return;
}

View File

@ -574,8 +574,8 @@ void CRobotMain::ChangePhase(Phase phase)
}
catch (const std::runtime_error& e)
{
CLogger::GetInstancePointer()->Error("An error occured while trying to load a level\n");
CLogger::GetInstancePointer()->Error("%s\n", e.what());
GetLogger()->Error("An error occured while trying to load a level\n");
GetLogger()->Error("%s\n", e.what());
ChangePhase(PHASE_INIT);
}
}
@ -621,8 +621,8 @@ void CRobotMain::ChangePhase(Phase phase)
}
catch (const std::runtime_error& e)
{
CLogger::GetInstancePointer()->Error("An error occured while trying to load win scene\n");
CLogger::GetInstancePointer()->Error("%s\n", e.what());
GetLogger()->Error("An error occured while trying to load win scene\n");
GetLogger()->Error("%s\n", e.what());
ChangePhase(PHASE_TERM);
}
}
@ -654,8 +654,8 @@ void CRobotMain::ChangePhase(Phase phase)
}
catch (const std::runtime_error& e)
{
CLogger::GetInstancePointer()->Error("An error occured while trying to load lost scene\n");
CLogger::GetInstancePointer()->Error("%s\n", e.what());
GetLogger()->Error("An error occured while trying to load lost scene\n");
GetLogger()->Error("%s\n", e.what());
ChangePhase(PHASE_TERM);
}
}
@ -2837,8 +2837,8 @@ void CRobotMain::ScenePerso()
}
catch (const std::runtime_error& e)
{
CLogger::GetInstancePointer()->Error("An error occured while trying to load apperance scene\n");
CLogger::GetInstancePointer()->Error("%s\n", e.what());
GetLogger()->Error("An error occured while trying to load apperance scene\n");
GetLogger()->Error("%s\n", e.what());
}
m_engine->SetDrawWorld(false); // does not draw anything on the interface
@ -3084,7 +3084,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
if (line->GetParam("filename")->IsDefined())
throw CLevelParserException("You can't use track and filename at the same time");
CLogger::GetInstancePointer()->Warn("Using track= is deprecated. Please replace this with filename=\n");
GetLogger()->Warn("Using track= is deprecated. Please replace this with filename=\n");
int trackid = line->GetParam("track")->AsInt();
if (trackid != 0)
{
@ -4545,7 +4545,7 @@ void CRobotMain::CompileScript(bool soluce)
std::string name = "ai/" + program->filename;
if (! brain->ReadProgram(program, const_cast<char*>(name.c_str())))
{
CLogger::GetInstancePointer()->Error("Unable to read script from file \"%s\"\n", name.c_str());
GetLogger()->Error("Unable to read script from file \"%s\"\n", name.c_str());
}
if (!brain->GetCompile(program)) nbError++;
}
@ -4987,7 +4987,7 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char *
}
catch (CLevelParserException& e)
{
CLogger::GetInstancePointer()->Error("Failed to save level state - %s\n", e.what());
GetLogger()->Error("Failed to save level state - %s\n", e.what());
return false;
}
@ -5248,7 +5248,7 @@ void CRobotMain::WriteFreeParam()
file.open(std::string(GetSavegameDir()) + "/" + m_gamerName + "/research.gam");
if (!file.is_open())
{
CLogger::GetInstancePointer()->Error("Unable to write free game unlock state\n");
GetLogger()->Error("Unable to write free game unlock state\n");
return;
}
@ -5272,7 +5272,7 @@ void CRobotMain::ReadFreeParam()
file.open(std::string(GetSavegameDir()) + "/" + m_gamerName + "/research.gam");
if (!file.is_open())
{
CLogger::GetInstancePointer()->Error("Unable to read free game unlock state\n");
GetLogger()->Error("Unable to read free game unlock state\n");
return;
}
@ -5327,8 +5327,8 @@ void CRobotMain::ResetCreate()
}
catch (const std::runtime_error& e)
{
CLogger::GetInstancePointer()->Error("An error occured while trying to reset scene\n");
CLogger::GetInstancePointer()->Error("%s\n", e.what());
GetLogger()->Error("An error occured while trying to reset scene\n");
GetLogger()->Error("%s\n", e.what());
ChangePhase(PHASE_TERM);
}
}
@ -5342,7 +5342,7 @@ void CRobotMain::UpdateAudio(bool frame)
if (audioChange->Check())
{
CLogger::GetInstancePointer()->Info("Changing music to \"%s\"\n", audioChange->music.c_str());
GetLogger()->Info("Changing music to \"%s\"\n", audioChange->music.c_str());
m_sound->PlayMusic(audioChange->music, audioChange->repeat);
audioChange->changed = true;
}
@ -5426,7 +5426,7 @@ Error CRobotMain::CheckEndMission(bool frame)
m_missionResult = ERR_MISSION_NOTERM;
if (teamCount == 0) {
CLogger::GetInstancePointer()->Info("All teams died, mission ended with failure\n");
GetLogger()->Info("All teams died, mission ended with failure\n");
m_missionResult = INFO_LOST;
}
else
@ -5440,7 +5440,7 @@ Error CRobotMain::CheckEndMission(bool frame)
Error result = CheckEndMissionForGroup(it.second);
if (result == INFO_LOST || result == INFO_LOSTq)
{
CLogger::GetInstancePointer()->Info("Team %d lost\n", team);
GetLogger()->Info("Team %d lost\n", team);
m_displayText->DisplayText(("<<< Team "+boost::lexical_cast<std::string>(team)+" lost! >>>").c_str(), Math::Vector(0.0f,0.0f,0.0f), 15.0f, 60.0f, 10.0f, Ui::TT_ERROR);
m_displayText->SetEnable(false); // To prevent "bot destroyed" messages
@ -5451,12 +5451,12 @@ Error CRobotMain::CheckEndMission(bool frame)
{
if (m_winDelay == 0.0f)
{
CLogger::GetInstancePointer()->Info("Team %d won\n", team);
GetLogger()->Info("Team %d won\n", team);
m_displayText->DisplayText(("<<< Team "+boost::lexical_cast<std::string>(team)+" won the game >>>").c_str(), Math::Vector(0.0f,0.0f,0.0f));
if (m_missionTimerEnabled && m_missionTimerStarted)
{
CLogger::GetInstancePointer()->Info("Mission time: %s\n", TimeFormat(m_missionTimer).c_str());
GetLogger()->Info("Mission time: %s\n", TimeFormat(m_missionTimer).c_str());
m_displayText->DisplayText(("Time: " + TimeFormat(m_missionTimer)).c_str(), Math::Vector(0.0f,0.0f,0.0f));
}
m_missionTimerEnabled = m_missionTimerStarted = false;
@ -5536,7 +5536,7 @@ Error CRobotMain::CheckEndMission(bool frame)
m_displayText->DisplayError(INFO_WIN, Math::Vector(0.0f,0.0f,0.0f));
if (m_missionTimerEnabled && m_missionTimerStarted)
{
CLogger::GetInstancePointer()->Info("Mission time: %s\n", TimeFormat(m_missionTimer).c_str());
GetLogger()->Info("Mission time: %s\n", TimeFormat(m_missionTimer).c_str());
m_displayText->DisplayText(("Time: " + TimeFormat(m_missionTimer)).c_str(), Math::Vector(0.0f,0.0f,0.0f));
}
m_missionTimerEnabled = m_missionTimerStarted = false;
@ -5921,7 +5921,7 @@ float CRobotMain::GetTracePrecision()
//! Starts music with a mission
void CRobotMain::StartMusic()
{
CLogger::GetInstancePointer()->Debug("Starting music...\n");
GetLogger()->Debug("Starting music...\n");
if (m_audioTrack != "")
{
m_sound->PlayMusic(m_audioTrack, m_audioRepeat, 0.0f);
@ -5975,7 +5975,7 @@ void CRobotMain::StartMissionTimer()
{
if (m_missionTimerEnabled && !m_missionTimerStarted)
{
CLogger::GetInstancePointer()->Info("Starting mission timer...\n");
GetLogger()->Info("Starting mission timer...\n");
m_missionTimerStarted = true;
}
}
@ -6016,7 +6016,7 @@ int CRobotMain::GetAutosaveSlots()
int CRobotMain::AutosaveRotate(bool freeOne)
{
CLogger::GetInstancePointer()->Debug("Rotate autosaves...\n");
GetLogger()->Debug("Rotate autosaves...\n");
// Find autosave dirs
auto saveDirs = CResourceManager::ListDirectories(std::string(GetSavegameDir()) + "/" + GetGamerName());
std::map<int, std::string> autosaveDirs;
@ -6033,7 +6033,7 @@ int CRobotMain::AutosaveRotate(bool freeOne)
}
catch (...)
{
CLogger::GetInstancePointer()->Info("Bad autosave found: %s\n", dir.c_str());
GetLogger()->Info("Bad autosave found: %s\n", dir.c_str());
// skip
}
}
@ -6053,13 +6053,13 @@ int CRobotMain::AutosaveRotate(bool freeOne)
count++;
if (count > m_autosaveSlots-(freeOne ? 1 : 0) || !m_autosave)
{
CLogger::GetInstancePointer()->Trace("Remove %s\n", autosaveDirs[i].c_str());
GetLogger()->Trace("Remove %s\n", autosaveDirs[i].c_str());
CResourceManager::RemoveDirectory(autosaveDirs[i]);
rotate = true;
}
else
{
CLogger::GetInstancePointer()->Trace("Keep %s\n", autosaveDirs[i].c_str());
GetLogger()->Trace("Keep %s\n", autosaveDirs[i].c_str());
autosavesToKeep[new_last_id-count+1] = autosaveDirs[i];
}
}
@ -6071,7 +6071,7 @@ int CRobotMain::AutosaveRotate(bool freeOne)
for (auto& save : autosavesToKeep)
{
std::string newDir = std::string(GetSavegameDir()) + "/" + GetGamerName() + "/autosave" + boost::lexical_cast<std::string>(save.first);
CLogger::GetInstancePointer()->Trace("Rename %s -> %s\n", save.second.c_str(), newDir.c_str());
GetLogger()->Trace("Rename %s -> %s\n", save.second.c_str(), newDir.c_str());
CResourceManager::Move(save.second, newDir);
}
}
@ -6082,7 +6082,7 @@ int CRobotMain::AutosaveRotate(bool freeOne)
void CRobotMain::Autosave()
{
int id = AutosaveRotate(true);
CLogger::GetInstancePointer()->Info("Autosave!\n");
GetLogger()->Info("Autosave!\n");
std::string dir = std::string(GetSavegameDir()) + "/" + GetGamerName() + "/autosave" + boost::lexical_cast<std::string>(id);

View File

@ -758,7 +758,7 @@ bool CScriptFunctions::rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* resul
{
exception = ERR_GENERIC;
result->SetValInt(ERR_GENERIC);
CLogger::GetInstancePointer()->Error("in object.factory() - factory is nullptr");
GetLogger()->Error("in object.factory() - factory is nullptr");
return false;
}
@ -776,7 +776,7 @@ bool CScriptFunctions::rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* resul
{
exception = ERR_GENERIC;
result->SetValInt(ERR_GENERIC);
CLogger::GetInstancePointer()->Error("in object.factory() - automat is nullptr");
GetLogger()->Error("in object.factory() - automat is nullptr");
return false;
}
@ -3165,7 +3165,7 @@ void PrepareFilename(CBotString &filename)
boost::filesystem::create_directories(CScriptFunctions::m_filesDir);
#endif
filename = CBotString(CScriptFunctions::m_filesDir.c_str()) + CBotString("/") + filename;
CLogger::GetInstancePointer()->Debug("CBot accessing file '%s'\n", static_cast<const char*>(filename));
GetLogger()->Debug("CBot accessing file '%s'\n", static_cast<const char*>(filename));
}

View File

@ -1449,7 +1449,7 @@ bool CEdit::ReadText(std::string filename, int addSize)
if (!stream.is_open())
{
CLogger::GetInstancePointer()->Error("Failed to load text file %s\n", filename.c_str());
GetLogger()->Error("Failed to load text file %s\n", filename.c_str());
return false;
}
@ -1627,7 +1627,7 @@ bool CEdit::ReadText(std::string filename, int addSize)
{
if (iIndex >= EDITIMAGEMAX)
{
CLogger::GetInstancePointer()->Warn("Too many images, current limit is %d image lines. This limit will be removed in the future.\n", EDITIMAGEMAX);
GetLogger()->Warn("Too many images, current limit is %d image lines. This limit will be removed in the future.\n", EDITIMAGEMAX);
break;
}
m_image[iIndex].name = iName;

View File

@ -347,7 +347,7 @@ void CMainDialog::ChangePhase(Phase phase)
}
catch (CLevelParserException& e)
{
CLogger::GetInstancePointer()->Error("Failed loading userlevel button name: %s\n", e.what());
GetLogger()->Error("Failed loading userlevel button name: %s\n", e.what());
}
}
@ -4002,7 +4002,7 @@ void CMainDialog::IOReadName()
}
catch (CLevelParserException& e)
{
CLogger::GetInstancePointer()->Warn("%s\n", e.what());
GetLogger()->Warn("%s\n", e.what());
}
time(&now);
@ -6033,7 +6033,7 @@ void CMainDialog::WriteGamerPerso(char *gamer)
}
catch (CLevelParserException& e)
{
CLogger::GetInstancePointer()->Error("Unable to write personalized player apperance: %s\n", e.what());
GetLogger()->Error("Unable to write personalized player apperance: %s\n", e.what());
}
}
@ -6064,7 +6064,7 @@ void CMainDialog::ReadGamerPerso(char *gamer)
}
catch (CLevelParserException& e)
{
CLogger::GetInstancePointer()->Error("Unable to read personalized player apperance: %s\n", e.what());
GetLogger()->Error("Unable to read personalized player apperance: %s\n", e.what());
}
}
@ -6142,7 +6142,7 @@ bool CMainDialog::ReadGamerInfo()
file.open(GetSavegameDir()+"/"+m_main->GetGamerName()+"/"+m_sceneName+".gam");
if (!file.is_open())
{
CLogger::GetInstancePointer()->Error("Unable to read list of finished missions\n");
GetLogger()->Error("Unable to read list of finished missions\n");
return false;
}
@ -6185,7 +6185,7 @@ bool CMainDialog::WriteGamerInfo()
file.open(GetSavegameDir()+"/"+m_main->GetGamerName()+"/"+m_sceneName+".gam");
if (!file.is_open())
{
CLogger::GetInstancePointer()->Error("Unable to read list of finished missions\n");
GetLogger()->Error("Unable to read list of finished missions\n");
return false;
}

View File

@ -148,7 +148,7 @@ bool CMainShort::CreateShortcuts()
if (rank > EVENT_OBJECT_SHORTCUT_MAX-EVENT_OBJECT_SHORTCUT)
{
CLogger::GetInstancePointer()->Warn("Not enough shortcut slots!\n");
GetLogger()->Warn("Not enough shortcut slots!\n");
break;
}
}

View File

@ -1444,7 +1444,7 @@ void CStudio::SetFilenameField(CEdit* edit, const std::string& filename)
name = name.substr(0, name.length()-4);
if (name.length() > static_cast<unsigned int>(edit->GetMaxChar()))
{
CLogger::GetInstancePointer()->Warn("Tried to load too long filename!\n");
GetLogger()->Warn("Tried to load too long filename!\n");
name = name.substr(0, edit->GetMaxChar()); // truncates according to max length
}
}