Use new logging system for game itself

pull/540/head
Andrei Kortunov 6 years ago
parent c7a5548475
commit 5a4d0cec3a

@ -10,6 +10,8 @@
#include <SDL.h>
#include <components/debug/debuglog.hpp>
#include <components/misc/rng.hpp>
#include <components/vfs/manager.hpp>
@ -61,7 +63,7 @@ namespace
void checkSDLError(int ret)
{
if (ret != 0)
std::cerr << "SDL error: " << SDL_GetError() << std::endl;
Log(Debug::Error) << "SDL error: " << SDL_GetError();
}
}
@ -189,7 +191,7 @@ bool OMW::Engine::frame(float frametime)
}
catch (const std::exception& e)
{
std::cerr << "Error in frame: " << e.what() << std::endl;
Log(Debug::Error) << "Error in frame: " << e.what();
}
return true;
}
@ -364,7 +366,7 @@ void OMW::Engine::createWindow(Settings::Manager& settings)
// Try with a lower AA
if (antialiasing > 0)
{
std::cout << "Note: " << antialiasing << "x antialiasing not supported, trying " << antialiasing/2 << std::endl;
Log(Debug::Warning) << "Warning: " << antialiasing << "x antialiasing not supported, trying " << antialiasing/2;
antialiasing /= 2;
Settings::Manager::setInt("antialiasing", "Video", antialiasing);
checkSDLError(SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, antialiasing));
@ -373,7 +375,7 @@ void OMW::Engine::createWindow(Settings::Manager& settings)
else
{
std::stringstream error;
error << "Failed to create SDL window: " << SDL_GetError() << std::endl;
error << "Failed to create SDL window: " << SDL_GetError();
throw std::runtime_error(error.str());
}
}
@ -420,16 +422,16 @@ void OMW::Engine::setWindowIcon()
std::string windowIcon = (mResDir / "mygui" / "openmw.png").string();
windowIconStream.open(windowIcon, std::ios_base::in | std::ios_base::binary);
if (windowIconStream.fail())
std::cerr << "Error: Failed to open " << windowIcon << std::endl;
Log(Debug::Error) << "Error: Failed to open " << windowIcon;
osgDB::ReaderWriter* reader = osgDB::Registry::instance()->getReaderWriterForExtension("png");
if (!reader)
{
std::cerr << "Error: Failed to read window icon, no png readerwriter found" << std::endl;
Log(Debug::Error) << "Error: Failed to read window icon, no png readerwriter found";
return;
}
osgDB::ReaderWriter::ReadResult result = reader->readImage(windowIconStream);
if (!result.success())
std::cerr << "Error: Failed to read " << windowIcon << ": " << result.message() << " code " << result.status() << std::endl;
Log(Debug::Error) << "Error: Failed to read " << windowIcon << ": " << result.message() << " code " << result.status();
else
{
osg::ref_ptr<osg::Image> image = result.getImage();
@ -564,21 +566,19 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
{
std::pair<int, int> result = mEnvironment.getScriptManager()->compileAll();
if (result.first)
std::cout
Log(Debug::Info)
<< "compiled " << result.second << " of " << result.first << " scripts ("
<< 100*static_cast<double> (result.second)/result.first
<< "%)"
<< std::endl;
<< "%)";
}
if (mCompileAllDialogue)
{
std::pair<int, int> result = MWDialogue::ScriptTest::compileAll(&mExtensions, mWarningsMode);
if (result.first)
std::cout
Log(Debug::Info)
<< "compiled " << result.second << " of " << result.first << " dialogue script/actor combinations a("
<< 100*static_cast<double> (result.second)/result.first
<< "%)"
<< std::endl;
<< "%)";
}
}
@ -614,14 +614,14 @@ public:
osgDB::ReaderWriter* readerwriter = osgDB::Registry::instance()->getReaderWriterForExtension(mScreenshotFormat);
if (!readerwriter)
{
std::cerr << "Error: Can't write screenshot, no '" << mScreenshotFormat << "' readerwriter found" << std::endl;
Log(Debug::Error) << "Error: Can't write screenshot, no '" << mScreenshotFormat << "' readerwriter found";
return;
}
osgDB::ReaderWriter::WriteResult result = readerwriter->writeImage(image, outStream);
if (!result.success())
{
std::cerr << "Error: Can't write screenshot: " << result.message() << " code " << result.status() << std::endl;
Log(Debug::Error) << "Error: Can't write screenshot: " << result.message() << " code " << result.status();
}
}
@ -636,7 +636,7 @@ void OMW::Engine::go()
{
assert (!mContentFiles.empty());
std::cout << "OSG version: " << osgGetVersion() << std::endl;
Log(Debug::Info) << "OSG version: " << osgGetVersion();
// Load settings
Settings::Manager settings;
@ -738,7 +738,7 @@ void OMW::Engine::go()
// Save user settings
settings.saveUser(settingspath);
std::cout << "Quitting peacefully." << std::endl;
Log(Debug::Info) << "Quitting peacefully.";
}
void OMW::Engine::setCompileAll (bool all)

@ -1,5 +1,3 @@
#include <iostream>
#include <components/version/version.hpp>
#include <components/files/configurationmanager.hpp>
#include <components/files/escape.hpp>
@ -202,8 +200,8 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
StringsVector content = variables["content"].as<Files::EscapeStringVector>().toStdStringVector();
if (content.empty())
{
std::cout << "No content file given (esm/esp, nor omwgame/omwaddon). Aborting..." << std::endl;
return false;
Log(Debug::Error) << "No content file given (esm/esp, nor omwgame/omwaddon). Aborting...";
return false;
}
StringsVector::const_iterator it(content.begin());
@ -217,7 +215,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
engine.setCell(variables["start"].as<Files::EscapeHashString>().toStdString());
engine.setSkipMenu (variables["skip-menu"].as<bool>(), variables["new-game"].as<bool>());
if (!variables["skip-menu"].as<bool>() && variables["new-game"].as<bool>())
std::cerr << "Warning: new-game used without skip-menu -> ignoring it" << std::endl;
Log(Debug::Warning) << "Warning: new-game used without skip-menu -> ignoring it";
// scripts
engine.setCompileAll(variables["script-all"].as<bool>());

@ -1,7 +1,7 @@
#include "creature.hpp"
#include <components/misc/rng.hpp>
#include <components/debug/debuglog.hpp>
#include <components/esm/loadcrea.hpp>
#include <components/esm/creaturestate.hpp>
#include <components/settings/settings.hpp>
@ -146,7 +146,7 @@ namespace MWClass
if (const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(*iter))
data->mCreatureStats.getSpells().add (spell);
else /// \todo add option to make this a fatal error message pop-up, but default to warning for vanilla compatibility
std::cerr << "Warning: ignoring nonexistent spell '" << *iter << "' on creature '" << ref->mBase->mId << "'" << std::endl;
Log(Debug::Warning) << "Warning: ignoring nonexistent spell '" << *iter << "' on creature '" << ref->mBase->mId << "'";
}
// inventory

@ -4,6 +4,7 @@
#include <components/misc/rng.hpp>
#include <components/debug/debuglog.hpp>
#include <components/esm/loadmgef.hpp>
#include <components/esm/loadnpc.hpp>
#include <components/esm/npcstate.hpp>
@ -365,7 +366,7 @@ namespace MWClass
if (const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search(*iter))
data->mNpcStats.getSpells().add (spell);
else
std::cerr << "Warning: ignoring nonexistent race power '" << *iter << "' on NPC '" << ref->mBase->mId << "'" << std::endl;
Log(Debug::Warning) << "Warning: ignoring nonexistent race power '" << *iter << "' on NPC '" << ref->mBase->mId << "'";
}
if (!ref->mBase->mFaction.empty())
@ -395,7 +396,7 @@ namespace MWClass
else
{
/// \todo add option to make this a fatal error message pop-up, but default to warning for vanilla compatibility
std::cerr << "Warning: ignoring nonexistent spell '" << *iter << "' on NPC '" << ref->mBase->mId << "'" << std::endl;
Log(Debug::Warning) << "Warning: ignoring nonexistent spell '" << *iter << "' on NPC '" << ref->mBase->mId << "'";
}
}

@ -5,7 +5,8 @@
#include <algorithm>
#include <iterator>
#include <list>
#include <iostream>
#include <components/debug/debuglog.hpp>
#include <components/esm/loaddial.hpp>
#include <components/esm/loadinfo.hpp>
@ -203,16 +204,14 @@ namespace MWDialogue
}
catch (const std::exception& error)
{
std::cerr << std::string ("Dialogue error: An exception has been thrown: ") + error.what() << std::endl;
Log(Debug::Error) << std::string ("Dialogue error: An exception has been thrown: ") + error.what();
success = false;
}
if (!success)
{
std::cerr
<< "Warning: compiling failed (dialogue script)" << std::endl
<< cmd
<< std::endl << std::endl;
Log(Debug::Warning)
<< "Warning: compiling failed (dialogue script)\n" << cmd << "\n\n";
}
return success;
@ -232,7 +231,7 @@ namespace MWDialogue
}
catch (const std::exception& error)
{
std::cerr << std::string ("Dialogue error: An exception has been thrown: ") + error.what() << std::endl;
Log(Debug::Error) << std::string ("Dialogue error: An exception has been thrown: ") + error.what();
}
}
}

@ -1,7 +1,5 @@
#include "scripttest.hpp"
#include <iostream>
#include "../mwworld/manualref.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwworld/class.hpp"
@ -12,6 +10,7 @@
#include "../mwscript/compilercontext.hpp"
#include <components/debug/debuglog.hpp>
#include <components/compiler/exception.hpp>
#include <components/compiler/streamerrorhandler.hpp>
#include <components/compiler/scanner.hpp>
@ -80,16 +79,14 @@ void test(const MWWorld::Ptr& actor, int &compiled, int &total, const Compiler::
}
catch (const std::exception& error)
{
std::cerr << std::string ("Dialogue error: An exception has been thrown: ") + error.what() << std::endl;
Log(Debug::Error) << std::string ("Dialogue error: An exception has been thrown: ") + error.what();
success = false;
}
if (!success)
{
std::cerr
<< "compiling failed (dialogue script)" << std::endl
<< info->mResultScript
<< std::endl << std::endl;
Log(Debug::Warning)
<< "compiling failed (dialogue script)\n" << info->mResultScript << "\n\n";
}
}
}

@ -1,5 +1,6 @@
#include "charactercreation.hpp"
#include <components/debug/debuglog.hpp>
#include <components/fallback/fallback.hpp>
#include "../mwbase/environment.hpp"
@ -284,7 +285,7 @@ namespace MWGui
}
catch (std::exception& e)
{
std::cerr << "Error: Failed to create chargen window: " << e.what() << std::endl;
Log(Debug::Error) << "Error: Failed to create chargen window: " << e.what();
}
}
@ -602,7 +603,7 @@ namespace MWGui
mGenerateClass = "Mage";
else
{
std::cout << "Failed to deduce class from chosen answers in generate class dialog" << std::endl;
Log(Debug::Warning) << "Failed to deduce class from chosen answers in generate class dialog.";
mGenerateClass = "Thief";
}
}

@ -12,6 +12,8 @@
#include "../mwworld/esmstore.hpp"
#include <components/debug/debuglog.hpp>
#include "tooltips.hpp"
namespace
@ -924,7 +926,7 @@ namespace MWGui
std::string classImage = std::string("textures\\levelup\\") + classId + ".dds";
if (!MWBase::Environment::get().getWindowManager()->textureExists(classImage))
{
std::cout << "No class image for " << classId << ", falling back to default" << std::endl;
Log(Debug::Warning) << "No class image for " << classId << ", falling back to default";
classImage = "textures\\levelup\\warrior.dds";
}
imageBox->setImageTexture(classImage);

@ -6,6 +6,7 @@
#include <MyGUI_ScrollBar.h>
#include <MyGUI_Button.h>
#include <components/debug/debuglog.hpp>
#include <components/widgets/list.hpp>
#include <components/translation/translation.hpp>
@ -411,7 +412,7 @@ namespace MWGui
{
if (!actor.getClass().isActor())
{
std::cerr << "Warning: can not talk with non-actor object." << std::endl;
Log(Debug::Warning) << "Warning: can not talk with non-actor object.";
return;
}

@ -13,6 +13,7 @@
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <components/debug/debuglog.hpp>
#include <components/interpreter/defines.hpp>
#include <components/misc/stringops.hpp>
@ -300,7 +301,7 @@ namespace MWGui
if (!exists)
{
std::cerr << "Warning: Could not find \"" << src << "\" referenced by an <img> tag." << std::endl;
Log(Debug::Warning) << "Warning: Could not find \"" << src << "\" referenced by an <img> tag.";
break;
}

@ -10,9 +10,8 @@
#include <MyGUI_TextBox.h>
#include <components/misc/rng.hpp>
#include <components/debug/debuglog.hpp>
#include <components/myguiplatform/myguitexture.hpp>
#include <components/settings/settings.hpp>
#include <components/vfs/manager.hpp>
@ -94,7 +93,7 @@ namespace MWGui
++found;
}
if (mSplashScreens.empty())
std::cerr << "No splash screens found!" << std::endl;
Log(Debug::Warning) << "Warning: no splash screens found!";
}
void LoadingScreen::setLabel(const std::string &label, bool important)

@ -5,6 +5,7 @@
#include <MyGUI_RenderManager.h>
#include <MyGUI_Button.h>
#include <components/debug/debuglog.hpp>
#include <components/misc/stringops.hpp>
#include "../mwbase/environment.hpp"
@ -125,7 +126,7 @@ namespace MWGui
{
if (mInterMessageBoxe != NULL)
{
std::cerr << "Warning: replacing an interactive message box that was not answered yet" << std::endl;
Log(Debug::Warning) << "Warning: replacing an interactive message box that was not answered yet";
mInterMessageBoxe->setVisible(false);
delete mInterMessageBoxe;
mInterMessageBoxe = NULL;

@ -6,6 +6,7 @@
#include <osg/Texture2D>
#include <components/debug/debuglog.hpp>
#include <components/myguiplatform/myguitexture.hpp>
#include "../mwworld/esmstore.hpp"
@ -340,7 +341,7 @@ namespace MWGui
}
catch (std::exception& e)
{
std::cerr << "Error creating preview: " << e.what() << std::endl;
Log(Debug::Error) << "Error creating preview: " << e.what();
}
}

@ -12,6 +12,8 @@
#include <osgDB/ReadFile>
#include <osg/Texture2D>
#include <components/debug/debuglog.hpp>
#include <components/myguiplatform/myguitexture.hpp>
#include <components/misc/stringops.hpp>
@ -438,14 +440,14 @@ namespace MWGui
osgDB::ReaderWriter* readerwriter = osgDB::Registry::instance()->getReaderWriterForExtension("jpg");
if (!readerwriter)
{
std::cerr << "Error: Can't open savegame screenshot, no jpg readerwriter found" << std::endl;
Log(Debug::Error) << "Error: Can't open savegame screenshot, no jpg readerwriter found";
return;
}
osgDB::ReaderWriter::ReadResult result = readerwriter->readImage(instream);
if (!result.success())
{
std::cerr << "Error: Failed to read savegame screenshot: " << result.message() << " code " << result.status() << std::endl;
Log(Debug::Error) << "Error: Failed to read savegame screenshot: " << result.message() << " code " << result.status();
return;
}

@ -12,6 +12,7 @@
#include <SDL_video.h>
#include <components/debug/debuglog.hpp>
#include <components/widgets/sharedstatebutton.hpp>
#include <components/settings/settings.hpp>
@ -31,7 +32,8 @@ namespace
if (val == "linear") return "Trilinear";
if (val == "nearest") return "Bilinear";
if (val != "none")
std::cerr<< "Warning: Invalid texture mipmap option: "<<val <<std::endl;
Log(Debug::Warning) << "Warning: Invalid texture mipmap option: "<< val;
return "Other";
}
@ -398,7 +400,7 @@ namespace MWGui
else if(pos == 1)
Settings::Manager::setString("texture mipmap", "General", "linear");
else
std::cerr<< "Unexpected option pos "<<pos <<std::endl;
Log(Debug::Warning) << "Unexpected option pos " << pos;
apply();
}

@ -1,9 +1,7 @@
#include "sortfilteritemmodel.hpp"
#include <iostream>
#include <components/misc/stringops.hpp>
#include <components/debug/debuglog.hpp>
#include <components/esm/loadalch.hpp>
#include <components/esm/loadappa.hpp>
#include <components/esm/loadarmo.hpp>
@ -245,7 +243,7 @@ namespace MWGui
const ESM::Enchantment* ench = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().search(enchId);
if (!ench)
{
std::cerr << "Warning: Can't find enchantment '" << enchId << "' on item " << base.getCellRef().getRefId() << std::endl;
Log(Debug::Warning) << "Warning: Can't find enchantment '" << enchId << "' on item " << base.getCellRef().getRefId();
return false;
}

@ -1,6 +1,6 @@
#include "spellmodel.hpp"
#include <iostream>
#include <components/debug/debuglog.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
@ -94,7 +94,7 @@ namespace MWGui
const ESM::Enchantment* enchant = esmStore.get<ESM::Enchantment>().search(enchantId);
if (!enchant)
{
std::cerr << "Warning: Can't find enchantment '" << enchantId << "' on item " << item.getCellRef().getRefId() << std::endl;
Log(Debug::Warning) << "Warning: Can't find enchantment '" << enchantId << "' on item " << item.getCellRef().getRefId();
continue;
}

@ -6,6 +6,7 @@
#include <osg/Texture2D>
#include <components/debug/debuglog.hpp>
#include <components/vfs/manager.hpp>
#include <components/myguiplatform/myguitexture.hpp>
@ -37,7 +38,7 @@ void VideoWidget::playVideo(const std::string &video)
}
catch (std::exception& e)
{
std::cerr << "Failed to open video: " << e.what() << std::endl;
Log(Debug::Error) << "Failed to open video: " << e.what();
return;
}

@ -21,6 +21,8 @@
#include <SDL_keyboard.h>
#include <SDL_clipboard.h>
#include <components/debug/debuglog.hpp>
#include <components/sdlutil/sdlcursormanager.hpp>
#include <components/esm/esmreader.hpp>
@ -1082,7 +1084,7 @@ namespace MWGui
{
if (!mStore)
{
std::cerr << "Error: WindowManager::onRetrieveTag: no Store set up yet, can not replace '" << tag << "'" << std::endl;
Log(Debug::Error) << "Error: WindowManager::onRetrieveTag: no Store set up yet, can not replace '" << tag << "'";
return;
}
const ESM::GameSetting *setting = mStore->get<ESM::GameSetting>().find(tag);
@ -1788,7 +1790,7 @@ namespace MWGui
if (found != mCurrentModals.end())
mCurrentModals.erase(found);
else
std::cerr << " warning: can't find modal window " << input << std::endl;
Log(Debug::Warning) << "Warning: can't find modal window " << input;
}
}
if (mCurrentModals.empty())

@ -10,6 +10,7 @@
#include <SDL_version.h>
#include <components/debug/debuglog.hpp>
#include <components/sdlutil/sdlinputwrapper.hpp>
#include <components/sdlutil/sdlvideowrapper.hpp>
#include <components/esm/esmwriter.hpp>
@ -120,11 +121,11 @@ namespace MWInput
SDL_ControllerDeviceEvent evt;
evt.which = i;
controllerAdded(mFakeDeviceID, evt);
std::cout << "Detected game controller: " << SDL_GameControllerNameForIndex(i) << std::endl;
Log(Debug::Info) << "Detected game controller: " << SDL_GameControllerNameForIndex(i);
}
else
{
std::cout << "Detected unusable controller: " << SDL_JoystickNameForIndex(i) << std::endl;
Log(Debug::Info) << "Detected unusable controller: " << SDL_JoystickNameForIndex(i);
}
}

@ -8,7 +8,7 @@
#include <components/esm/loadnpc.hpp>
#include <components/sceneutil/positionattitudetransform.hpp>
#include <components/debug/debuglog.hpp>
#include <components/settings/settings.hpp>
#include "../mwworld/esmstore.hpp"
@ -1720,7 +1720,7 @@ namespace MWMechanics
}
else
{
std::cerr<< "Warning: Actors::playAnimationGroup: Unable to find " << ptr.getCellRef().getRefId() << std::endl;
Log(Debug::Warning) << "Warning: Actors::playAnimationGroup: Unable to find " << ptr.getCellRef().getRefId();
return false;
}
}

@ -1,8 +1,8 @@
#include "aisequence.hpp"
#include <limits>
#include <iostream>
#include <components/debug/debuglog.hpp>
#include <components/esm/aisequence.hpp>
#include "../mwbase/environment.hpp"
@ -282,7 +282,7 @@ void AiSequence::execute (const MWWorld::Ptr& actor, CharacterController& charac
}
catch (std::exception& e)
{
std::cerr << "Error during AiSequence::execute: " << e.what() << std::endl;
Log(Debug::Error) << "Error during AiSequence::execute: " << e.what();
}
}
}

@ -1,10 +1,9 @@
#include "aiwander.hpp"
#include <cfloat>
#include <iostream>
#include <components/debug/debuglog.hpp>
#include <components/misc/rng.hpp>
#include <components/esm/aisequence.hpp>
#include "../mwbase/world.hpp"
@ -24,8 +23,6 @@
#include "coordinateconverter.hpp"
#include "actorutil.hpp"
namespace MWMechanics
{
static const int COUNT_BEFORE_RESET = 10;
@ -677,7 +674,7 @@ namespace MWMechanics
}
else
{
std::cerr<< "Error: Attempted to play out of range idle animation \""<<idleSelect<<"\" for " << actor.getCellRef().getRefId() << std::endl;
Log(Debug::Verbose) << "Attempted to play out of range idle animation \"" << idleSelect << "\" for " << actor.getCellRef().getRefId();
return false;
}
}

@ -1,8 +1,7 @@
#ifndef OPENMW_MECHANICS_LEVELLEDLIST_H
#define OPENMW_MECHANICS_LEVELLEDLIST_H
#include <iostream>
#include <components/debug/debuglog.hpp>
#include <components/misc/rng.hpp>
#include "../mwworld/ptr.hpp"
@ -63,7 +62,7 @@ namespace MWMechanics
// Vanilla doesn't fail on nonexistent items in levelled lists
if (!MWBase::Environment::get().getWorld()->getStore().find(Misc::StringUtils::lowerCase(item)))
{
std::cerr << "Warning: ignoring nonexistent item '" << item << "' in levelled list '" << levItem->mId << "'" << std::endl;
Log(Debug::Warning) << "Warning: ignoring nonexistent item '" << item << "' in levelled list '" << levItem->mId << "'";
return std::string();
}

@ -1,6 +1,6 @@
#include "objects.hpp"
#include <iostream>
#include <components/debug/debuglog.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
@ -88,7 +88,7 @@ bool Objects::playAnimationGroup(const MWWorld::Ptr& ptr, const std::string& gro
}
else
{
std::cerr<< "Warning: Objects::playAnimationGroup: Unable to find " << ptr.getCellRef().getRefId() << std::endl;
Log(Debug::Warning) << "Warning: Objects::playAnimationGroup: Unable to find " << ptr.getCellRef().getRefId();
return false;
}
}

@ -1,6 +1,6 @@
#include "summoning.hpp"
#include <iostream>
#include <components/debug/debuglog.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
@ -76,7 +76,7 @@ namespace MWMechanics
}
catch (std::exception& e)
{
std::cerr << "Failed to spawn summoned creature: " << e.what() << std::endl;
Log(Debug::Error) << "Failed to spawn summoned creature: " << e.what();
// still insert into creatureMap so we don't try to spawn again every frame, that would spam the warning log
}

@ -1,6 +1,5 @@
#include "physicssystem.hpp"
#include <iostream>
#include <stdexcept>
#include <osg/Group>
@ -20,7 +19,7 @@
#include <components/nifbullet/bulletnifloader.hpp>
#include <components/resource/resourcesystem.hpp>
#include <components/resource/bulletshapemanager.hpp>
#include <components/debug/debuglog.hpp>
#include <components/esm/loadgmst.hpp>
#include <components/sceneutil/positionattitudetransform.hpp>
#include <components/sceneutil/unrefqueue.hpp>
@ -638,7 +637,7 @@ namespace MWPhysics
mPtr.getRefData().getBaseNode()->accept(visitor);
if (!visitor.mFound)
{
std::cerr << "Error: animateCollisionShapes can't find node " << recIndex << " for " << mPtr.getCellRef().getRefId() << std::endl;
Log(Debug::Warning) << "Warning: animateCollisionShapes can't find node " << recIndex << " for " << mPtr.getCellRef().getRefId();
// Remove nonexistent nodes from animated shapes map and early out
mShapeInstance->mAnimatedShapes.erase(recIndex);
@ -708,7 +707,7 @@ namespace MWPhysics
if (physFramerate > 0)
{
mPhysicsDt = 1.f / physFramerate;
std::cerr << "Warning: physics framerate was overridden (a new value is " << physFramerate << ")." << std::endl;
Log(Debug::Warning) << "Warning: using custom physics framerate (" << physFramerate << " FPS).";
}
}
}

@ -12,6 +12,8 @@
#include <osgParticle/ParticleSystem>
#include <osgParticle/ParticleProcessor>
#include <components/debug/debuglog.hpp>
#include <components/nifosg/nifloader.hpp>
#include <components/resource/resourcesystem.hpp>
@ -192,7 +194,7 @@ namespace
for (RemoveVec::iterator it = mToRemove.begin(); it != mToRemove.end(); ++it)
{
if (!it->second->removeChild(it->first))
std::cerr << "error removing " << it->first->getName() << std::endl;
Log(Debug::Error) << "Error removing " << it->first->getName();
}
}
@ -612,7 +614,7 @@ namespace MWRender
NodeMap::const_iterator found = nodeMap.find(bonename);
if (found == nodeMap.end())
{
std::cerr << "Warning: addAnimSource: can't find bone '" + bonename << "' in " << baseModel << " (referenced by " << kfname << ")" << std::endl;
Log(Debug::Warning) << "Warning: addAnimSource: can't find bone '" + bonename << "' in " << baseModel << " (referenced by " << kfname << ")";
continue;
}
@ -724,7 +726,7 @@ namespace MWRender
}
catch (std::exception& e)
{
std::cerr << "Error handling text key " << evt << ": " << e.what() << std::endl;
Log(Debug::Error) << "Error handling text key " << evt << ": " << e.what();
}
}
}
@ -1767,12 +1769,12 @@ namespace MWRender
PartHolder::~PartHolder()
{
if (mNode.get() && !mNode->getNumParents())
std::cerr << "Error: part has no parents " << std::endl;
Log(Debug::Verbose) << "Part has no parents" ;
if (mNode.get() && mNode->getNumParents())
{
if (mNode->getNumParents() > 1)
std::cerr << "Error: part has multiple parents " << mNode->getNumParents() << " " << mNode.get() << std::endl;
Log(Debug::Verbose) << "Part has multiple (" << mNode->getNumParents() << ") parents";
mNode->getParent(0)->removeChild(mNode);
}
}

@ -1,12 +1,12 @@
#include "bulletdebugdraw.hpp"
#include <iostream>
#include <BulletCollision/CollisionDispatch/btCollisionWorld.h>
#include <osg/Geometry>
#include <osg/Group>
#include <components/debug/debuglog.hpp>
#include "vismask.hpp"
namespace
@ -91,7 +91,7 @@ void DebugDrawer::drawContactPoint(const btVector3 &PointOnB, const btVector3 &n
void DebugDrawer::reportErrorWarning(const char *warningString)
{
std::cerr << warningString << std::endl;
Log(Debug::Warning) << warningString;
}
void DebugDrawer::setDebugMode(int isOn)

@ -1,7 +1,6 @@
#include "characterpreview.hpp"
#include <cmath>
#include <iostream>
#include <osg/Material>
#include <osg/Fog>
@ -14,6 +13,7 @@
#include <osgUtil/IntersectionVisitor>
#include <osgUtil/LineSegmentIntersector>
#include <components/debug/debuglog.hpp>
#include <components/fallback/fallback.hpp>
#include <components/sceneutil/lightmanager.hpp>
@ -474,7 +474,7 @@ namespace MWRender
mCamera->addUpdateCallback(mUpdateCameraCallback);
}
else
std::cerr << "Error: Bip01 Head node not found" << std::endl;
Log(Debug::Error) << "Error: Bip01 Head node not found";
}
}

@ -1,11 +1,9 @@
#include "creatureanimation.hpp"
#include <iostream>
#include <osg/MatrixTransform>
#include <components/esm/loadcrea.hpp>
#include <components/debug/debuglog.hpp>
#include <components/resource/resourcesystem.hpp>
#include <components/resource/scenemanager.hpp>
#include <components/sceneutil/attach.hpp>
@ -155,7 +153,7 @@ void CreatureWeaponAnimation::updatePart(PartHolderPtr& scene, int slot)
}
catch (std::exception& e)
{
std::cerr << "Can not add creature part: " << e.what() << std::endl;
Log(Debug::Error) << "Can not add creature part: " << e.what();
}
}

@ -15,6 +15,8 @@
#include <components/settings/settings.hpp>
#include <components/files/memorystream.hpp>
#include <components/debug/debuglog.hpp>
#include <components/sceneutil/workqueue.hpp>
#include <components/esm/globalmap.hpp>
@ -411,14 +413,14 @@ namespace MWRender
osgDB::ReaderWriter* readerwriter = osgDB::Registry::instance()->getReaderWriterForExtension("png");
if (!readerwriter)
{
std::cerr << "Error: Can't write map overlay: no png readerwriter found" << std::endl;
Log(Debug::Error) << "Error: Can't write map overlay: no png readerwriter found";
return;
}
osgDB::ReaderWriter::WriteResult result = readerwriter->writeImage(*mOverlayImage, ostream);
if (!result.success())
{
std::cerr << "Error: Can't write map overlay: " << result.message() << " code " << result.status() << std::endl;
Log(Debug::Warning) << "Error: Can't write map overlay: " << result.message() << " code " << result.status();
return;
}
@ -463,14 +465,14 @@ namespace MWRender
osgDB::ReaderWriter* readerwriter = osgDB::Registry::instance()->getReaderWriterForExtension("png");
if (!readerwriter)
{
std::cerr << "Error: Can't read map overlay: no png readerwriter found" << std::endl;
Log(Debug::Error) << "Error: Can't read map overlay: no png readerwriter found";
return;
}
osgDB::ReaderWriter::ReadResult result = readerwriter->readImage(istream);
if (!result.success())
{
std::cerr << "Error: Can't read map overlay: " << result.message() << " code " << result.status() << std::endl;
Log(Debug::Error) << "Error: Can't read map overlay: " << result.message() << " code " << result.status();
return;
}
@ -572,7 +574,7 @@ namespace MWRender
CameraVector::iterator found = std::find(mActiveCameras.begin(), mActiveCameras.end(), camera);
if (found == mActiveCameras.end())
{
std::cerr << "Error: GlobalMap trying to remove an inactive camera" << std::endl;
Log(Debug::Error) << "Error: GlobalMap trying to remove an inactive camera";
return;
}
mActiveCameras.erase(found);

@ -1,6 +1,5 @@
#include "localmap.hpp"
#include <iostream>
#include <stdint.h>
#include <osg/Fog>
@ -12,6 +11,7 @@
#include <osgDB/ReadFile>
#include <components/debug/debuglog.hpp>
#include <components/esm/fogstate.hpp>
#include <components/esm/loadcell.hpp>
#include <components/settings/settings.hpp>
@ -320,7 +320,7 @@ void LocalMap::markForRemoval(osg::Camera *cam)
CameraVector::iterator found = std::find(mActiveCameras.begin(), mActiveCameras.end(), cam);
if (found == mActiveCameras.end())
{
std::cerr << "Error: trying to remove an inactive camera" << std::endl;
Log(Debug::Error) << "Error: trying to remove an inactive camera";
return;
}
mActiveCameras.erase(found);
@ -492,7 +492,7 @@ void LocalMap::requestInteriorMap(const MWWorld::CellStore* cell)
// We are using the same bounds and angle as we were using when the textures were originally made. Segments should come out the same.
if (i >= int(fog->mFogTextures.size()))
{
std::cout << "Error: fog texture count mismatch" << std::endl;
Log(Debug::Warning) << "Warning: fog texture count mismatch";
break;
}
@ -684,7 +684,7 @@ void LocalMap::MapSegment::loadFogOfWar(const ESM::FogTexture &esm)
osgDB::ReaderWriter* readerwriter = osgDB::Registry::instance()->getReaderWriterForExtension("tga");
if (!readerwriter)
{
std::cerr << "Error: Unable to load fog, can't find a tga ReaderWriter" << std::endl;
Log(Debug::Error) << "Error: Unable to load fog, can't find a tga ReaderWriter" ;
return;
}
@ -693,7 +693,7 @@ void LocalMap::MapSegment::loadFogOfWar(const ESM::FogTexture &esm)
osgDB::ReaderWriter::ReadResult result = readerwriter->readImage(in);
if (!result.success())
{
std::cerr << "Error: Failed to read fog: " << result.message() << " code " << result.status() << std::endl;
Log(Debug::Error) << "Error: Failed to read fog: " << result.message() << " code " << result.status();
return;
}
@ -716,7 +716,7 @@ void LocalMap::MapSegment::saveFogOfWar(ESM::FogTexture &fog) const
osgDB::ReaderWriter* readerwriter = osgDB::Registry::instance()->getReaderWriterForExtension("tga");
if (!readerwriter)
{
std::cerr << "Error: Unable to write fog, can't find a tga ReaderWriter" << std::endl;
Log(Debug::Error) << "Error: Unable to write fog, can't find a tga ReaderWriter";
return;
}
@ -725,7 +725,7 @@ void LocalMap::MapSegment::saveFogOfWar(ESM::FogTexture &fog) const
osgDB::ReaderWriter::WriteResult result = readerwriter->writeImage(*mFogOfWarImage, ostream);
if (!result.success())
{
std::cerr << "Error: Unable to write fog: " << result.message() << " code " << result.status() << std::endl;
Log(Debug::Error) << "Error: Unable to write fog: " << result.message() << " code " << result.status();
return;
}
mFogOfWarImage->flipVertical();

@ -7,6 +7,8 @@
#include <osgUtil/RenderBin>
#include <osgUtil/CullVisitor>
#include <components/debug/debuglog.hpp>
#include <components/misc/rng.hpp>
#include <components/misc/resourcehelpers.hpp>
@ -435,7 +437,7 @@ void NpcAnimation::updateNpcBase()
if (bp)
mHeadModel = "meshes\\" + bp->mModel;
else
std::cerr << "Warning: Failed to load body part '" << mNpc->mHead << "'" << std::endl;
Log(Debug::Warning) << "Warning: Failed to load body part '" << mNpc->mHead << "'";
}
mHairModel = "";
@ -445,7 +447,7 @@ void NpcAnimation::updateNpcBase()
if (bp)
mHairModel = "meshes\\" + bp->mModel;
else
std::cerr << "Warning: Failed to load body part '" << mNpc->mHair << "'" << std::endl;
Log(Debug::Warning) << "Warning: Failed to load body part '" << mNpc->mHair << "'";
}
}
@ -758,7 +760,7 @@ bool NpcAnimation::addOrReplaceIndividualPart(ESM::PartReferenceType type, int g
}
catch (std::exception& e)
{
std::cerr << "Error adding NPC part: " << e.what() << std::endl;
Log(Debug::Error) << "Error adding NPC part: " << e.what();
return false;
}
@ -845,7 +847,7 @@ void NpcAnimation::addPartGroup(int group, int priority, const std::vector<ESM::
bodypart = NULL;
}
else if (!bodypart)
std::cerr << "Warning: Failed to find body part '" << part->mFemale << "'" << std::endl;
Log(Debug::Warning) << "Warning: Failed to find body part '" << part->mFemale << "'";
}
if(!bodypart && !part->mMale.empty())
{
@ -860,7 +862,7 @@ void NpcAnimation::addPartGroup(int group, int priority, const std::vector<ESM::
bodypart = NULL;
}
else if (!bodypart)
std::cerr << "Warning: Failed to find body part '" << part->mMale << "'" << std::endl;
Log(Debug::Warning) << "Warning: Failed to find body part '" << part->mMale << "'";
}
if(bodypart)

@ -22,6 +22,8 @@
#include <osgViewer/Viewer>
#include <components/debug/debuglog.hpp>
#include <components/resource/resourcesystem.hpp>
#include <components/resource/imagemanager.hpp>
#include <components/resource/scenemanager.hpp>
@ -709,7 +711,7 @@ namespace MWRender
if (!found)
{
std::cerr << "Wrong screenshot type: " << settingArgs[0] << "." << std::endl;
Log(Debug::Warning) << "Wrong screenshot type: " << settingArgs[0] << ".";
return false;
}
}
@ -728,7 +730,7 @@ namespace MWRender
if (mCamera->isVanityOrPreviewModeEnabled())
{
std::cerr << "Spherical screenshots are not allowed in preview mode." << std::endl;
Log(Debug::Warning) << "Spherical screenshots are not allowed in preview mode.";
return false;
}

@ -19,6 +19,8 @@
#include <osgUtil/IncrementalCompileOperation>
#include <osgUtil/CullVisitor>
#include <components/debug/debuglog.hpp>
#include <components/resource/resourcesystem.hpp>
#include <components/resource/imagemanager.hpp>
#include <components/resource/scenemanager.hpp>
@ -29,7 +31,6 @@
#include <components/shader/shadermanager.hpp>
#include <components/esm/loadcell.hpp>
#include <components/fallback/fallback.hpp>
@ -193,16 +194,16 @@ osg::ref_ptr<osg::Image> readPngImage (const std::string& file)
boost::filesystem::ifstream inStream;
inStream.open(file, std::ios_base::in | std::ios_base::binary);
if (inStream.fail())
std::cerr << "Error: Failed to open " << file << std::endl;
Log(Debug::Error) << "Error: Failed to open " << file;
osgDB::ReaderWriter* reader = osgDB::Registry::instance()->getReaderWriterForExtension("png");
if (!reader)
{
std::cerr << "Error: Failed to read " << file << ", no png readerwriter found" << std::endl;
Log(Debug::Error) << "Error: Failed to read " << file << ", no png readerwriter found";
return osg::ref_ptr<osg::Image>();
}
osgDB::ReaderWriter::ReadResult result = reader->readImage(inStream);
if (!result.success())
std::cerr << "Error: Failed to read " << file << ": " << result.message() << " code " << result.status() << std::endl;
Log(Debug::Error) << "Error: Failed to read " << file << ": " << result.message() << " code " << result.status();
return result.getImage();
}

@ -1,7 +1,8 @@
#include "aiextensions.hpp"
#include <stdexcept>
#include <iostream>
#include <components/debug/debuglog.hpp>
#include <components/compiler/extensions.hpp>
#include <components/compiler/opcodes.hpp>
@ -50,7 +51,7 @@ namespace MWScript
MWMechanics::AiActivate activatePackage(objectID);
ptr.getClass().getCreatureStats (ptr).getAiSequence().stack(activatePackage, ptr);
std::cout << "AiActivate" << std::endl;
Log(Debug::Info) << "AiActivate";
}
};
@ -78,7 +79,7 @@ namespace MWScript
MWMechanics::AiTravel travelPackage(x, y, z);
ptr.getClass().getCreatureStats (ptr).getAiSequence().stack(travelPackage, ptr);
std::cout << "AiTravel: " << x << ", " << y << ", " << z << std::endl;
Log(Debug::Info) << "AiTravel: " << x << ", " << y << ", " << z;
}
};
@ -112,8 +113,7 @@ namespace MWScript
MWMechanics::AiEscort escortPackage(actorID, static_cast<int>(duration), x, y, z);
ptr.getClass().getCreatureStats (ptr).getAiSequence().stack(escortPackage, ptr);
std::cout << "AiEscort: " << x << ", " << y << ", " << z << ", " << duration
<< std::endl;
Log(Debug::Info) << "AiEscort: " << x << ", " << y << ", " << z << ", " << duration;
}
};
@ -155,8 +155,7 @@ namespace MWScript
MWMechanics::AiEscort escortPackage(actorID, cellID, static_cast<int>(duration), x, y, z);
ptr.getClass().getCreatureStats (ptr).getAiSequence().stack(escortPackage, ptr);
std::cout << "AiEscort: " << x << ", " << y << ", " << z << ", " << duration
<< std::endl;
Log(Debug::Info) << "AiEscort: " << x << ", " << y << ", " << z << ", " << duration;
}
};
@ -316,8 +315,7 @@ namespace MWScript
MWMechanics::AiFollow followPackage(actorID, duration, x, y ,z);
ptr.getClass().getCreatureStats (ptr).getAiSequence().stack(followPackage, ptr);
std::cout << "AiFollow: " << actorID << ", " << x << ", " << y << ", " << z << ", " << duration
<< std::endl;
Log(Debug::Info) << "AiFollow: " << actorID << ", " << x << ", " << y << ", " << z << ", " << duration;
}
};
@ -353,8 +351,7 @@ namespace MWScript
MWMechanics::AiFollow followPackage(actorID, cellID, duration, x, y ,z);
ptr.getClass().getCreatureStats (ptr).getAiSequence().stack(followPackage, ptr);
std::cout << "AiFollow: " << actorID << ", " << x << ", " << y << ", " << z << ", " << duration
<< std::endl;
Log(Debug::Info) << "AiFollow: " << actorID << ", " << x << ", " << y << ", " << z << ", " << duration;
}
};

@ -6,6 +6,8 @@
#include <MyGUI_LanguageManager.h>
#include <components/debug/debuglog.hpp>
#include <components/compiler/extensions.hpp>
#include <components/compiler/opcodes.hpp>
@ -190,8 +192,8 @@ namespace MWScript
if (it == invStore.end())
{
it = ptr.getClass().getContainerStore (ptr).add (item, 1, ptr);
std::cerr << "Implicitly adding one " << item << " to container "
"to fulfil requirements of Equip instruction" << std::endl;
Log(Debug::Warning) << "Implicitly adding one " << item << " to container "
"to fulfil requirements of Equip instruction";
}
if (ptr == MWMechanics::getPlayer())

@ -1,10 +1,8 @@
#include <iostream>
#include "dialogueextensions.hpp"
#include <components/compiler/extensions.hpp>
#include <components/compiler/opcodes.hpp>
#include <components/debug/debuglog.hpp>
#include <components/interpreter/interpreter.hpp>
#include <components/interpreter/runtime.hpp>
#include <components/interpreter/opcodes.hpp>
@ -139,8 +137,8 @@ namespace MWScript
if (!ptr.getClass().isActor())
{
const std::string error = "Warning: \"forcegreeting\" command works only for actors.";
runtime.getContext().report (error);
std::cerr << error << std::endl;
runtime.getContext().report(error);
Log(Debug::Warning) << error;
return;
}

@ -1,8 +1,8 @@
#include "globalscripts.hpp"
#include <cassert>
#include <iostream>
#include <components/debug/debuglog.hpp>
#include <components/misc/stringops.hpp>
#include <components/esm/esmwriter.hpp>
#include <components/esm/globalscript.hpp>
@ -113,9 +113,9 @@ namespace MWScript
}
catch (const std::exception& exception)
{
std::cerr
Log(Debug::Error)
<< "Failed to add start script " << *iter << " because an exception has "
<< "been thrown: " << exception.what() << std::endl;
<< "been thrown: " << exception.what();
}
}
}
@ -169,10 +169,9 @@ namespace MWScript
}
catch (const std::exception& exception)
{
std::cerr
Log(Debug::Error)
<< "Failed to add start script " << script.mId
<< " because an exception has been thrown: " << exception.what()
<< std::endl;
<< " because an exception has been thrown: " << exception.what();
return true;
}

@ -3,7 +3,7 @@
#include <components/esm/loadscpt.hpp>
#include <components/esm/variant.hpp>
#include <components/esm/locals.hpp>
#include <components/debug/debuglog.hpp>
#include <components/compiler/locals.hpp>
#include <components/compiler/exception.hpp>
@ -229,10 +229,10 @@ namespace MWScript
}
catch (std::exception& e)
{
std::cerr << "Failed to read local variable state for script '"
<< script << "' (legacy format): " << e.what()
<< "\nNum shorts: " << numshorts << " / " << mShorts.size()
<< " Num longs: " << numlongs << " / " << mLongs.size() << std::endl;
Log(Debug::Error) << "Failed to read local variable state for script '"
<< script << "' (legacy format): " << e.what()
<< "\nNum shorts: " << numshorts << " / " << mShorts.size()
<< " Num longs: " << numlongs << " / " << mLongs.size();
}
}
else

@ -1,11 +1,12 @@
#include "scriptmanagerimp.hpp"
#include <cassert>
#include <iostream>
#include <sstream>
#include <exception>
#include <algorithm>
#include <components/debug/debuglog.hpp>
#include <components/esm/loadscpt.hpp>
#include <components/misc/stringops.hpp>
@ -65,14 +66,14 @@ namespace MWScript
}
catch (const std::exception& error)
{
std::cerr << "Error: An exception has been thrown: " << error.what() << std::endl;
Log(Debug::Error) << "Error: An exception has been thrown: " << error.what();
Success = false;
}
if (!Success)
{
std::cerr
<< "Warning: compiling failed: " << name << std::endl;
Log(Debug::Warning)
<< "Warning: compiling failed: " << name;
}
if (Success)
@ -121,8 +122,8 @@ namespace MWScript
}
catch (const std::exception& e)
{
std::cerr << "Execution of script " << name << " failed:" << std::endl;
std::cerr << e.what() << std::endl;
Log(Debug::Error) << "Execution of script " << name << " failed:";
Log(Debug::Error) << e.what();
iter->second.first.clear(); // don't execute again.
}

@ -1,6 +1,5 @@
#include "statsextensions.hpp"
#include <iostream>
#include <cmath>
#include <components/esm/loadnpc.hpp>
@ -9,7 +8,7 @@
#include <components/compiler/extensions.hpp>
#include <components/compiler/opcodes.hpp>
#include <components/debug/debuglog.hpp>
#include <components/interpreter/interpreter.hpp>
#include <components/interpreter/runtime.hpp>
#include <components/interpreter/opcodes.hpp>
@ -246,9 +245,10 @@ namespace MWScript
if (R()(runtime, false, true).isEmpty())
{
std::cerr
Log(Debug::Warning)
<< "Warning: Compensating for broken script in Morrowind.esm by "
<< "ignoring remote access to dagoth_ur_1" << std::endl;
<< "ignoring remote access to dagoth_ur_1";
return;
}
}

@ -1,4 +1,4 @@
#include <iostream>
#include <components/debug/debuglog.hpp>
#include <components/sceneutil/positionattitudetransform.hpp>
@ -317,7 +317,7 @@ namespace MWScript
{
std::string error = "Warning: PositionCell: unknown interior cell (" + cellID + "), moving to exterior instead";
runtime.getContext().report (error);
std::cerr << error << std::endl;
Log(Debug::Warning) << error;
}
}
if(store)
@ -429,7 +429,7 @@ namespace MWScript
if(!cell)
{
runtime.getContext().report ("unknown cell (" + cellID + ")");
std::cerr << "unknown cell (" << cellID << ")\n";
Log(Debug::Error) << "Error: unknown cell (" << cellID << ")";
}
}
if(store)

@ -3,9 +3,9 @@
#include <memory>
#include <stdexcept>
#include <iostream>
#include <algorithm>
#include <components/debug/debuglog.hpp>
#include <components/vfs/manager.hpp>
namespace MWSound
@ -28,7 +28,7 @@ int FFmpeg_Decoder::readPacket(void *user_data, uint8_t *buf, int buf_size)
int FFmpeg_Decoder::writePacket(void *, uint8_t *, int)
{
std::cerr<< "can't write to read-only stream" <<std::endl;
Log(Debug::Error) << "can't write to read-only stream";
return -1;
}
@ -343,7 +343,7 @@ void FFmpeg_Decoder::getInfo(int *samplerate, ChannelConfig *chans, SampleType *
char str[1024];
av_get_channel_layout_string(str, sizeof(str), (*mStream)->codec->channels,
(*mStream)->codec->channel_layout);
std::cerr<< "Unsupported channel layout: "<<str <<std::endl;
Log(Debug::Error) << "Unsupported channel layout: "<< str;
if((*mStream)->codec->channels == 1)
{
@ -385,7 +385,7 @@ size_t FFmpeg_Decoder::read(char *buffer, size_t bytes)
{
if(!mStream)
{
std::cerr<< "No audio stream" <<std::endl;
Log(Debug::Error) << "No audio stream";
return 0;
}
return readAVAudioData(buffer, bytes);
@ -395,7 +395,7 @@ void FFmpeg_Decoder::readAll(std::vector<char> &output)
{
if(!mStream)
{
std::cerr<< "No audio stream" <<std::endl;
Log(Debug::Error) << "No audio stream";
return;
}

@ -1,6 +1,5 @@
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <cstring>
#include <vector>
#include <memory>
@ -8,6 +7,7 @@
#include <stdint.h>
#include <components/debug/debuglog.hpp>
#include <components/vfs/manager.hpp>
#include <OpenThreads/Thread>
@ -44,8 +44,7 @@ ALCenum checkALCError(ALCdevice *device, const char *func, int line)
{
ALCenum err = alcGetError(device);
if(err != ALC_NO_ERROR)
std::cerr<< ">>>>>>>>> ALC error "<<alcGetString(device, err)<<" ("<<err<<") @ "<<
func<<":"<<line <<std::endl;
Log(Debug::Error) << "ALC error "<< alcGetString(device, err) << " (" << err << ") @ " << func << ":" << line;
return err;
}
#define getALCError(d) checkALCError((d), __FUNCTION__, __LINE__)
@ -54,8 +53,7 @@ ALenum checkALError(const char *func, int line)
{
ALenum err = alGetError();
if(err != AL_NO_ERROR)
std::cerr<< ">>>>>>>>> AL error "<<alGetString(err)<<" ("<<err<<") @ "<<
func<<":"<<line <<std::endl;
Log(Debug::Error) << "AL error " << alGetString(err) << " (" << err << ") @ " << func << ":" << line;
return err;
}
#define getALError() checkALError(__FUNCTION__, __LINE__)
@ -256,8 +254,7 @@ static ALenum getALFormat(ChannelConfig chans, SampleType type)
}
}
std::cerr<< "Unsupported sound format ("<<getChannelConfigName(chans)<<", "<<
getSampleTypeName(type)<<")" <<std::endl;
Log(Debug::Warning) << "Unsupported sound format (" << getChannelConfigName(chans) << ", " << getSampleTypeName(type) << ")";
return AL_NONE;
}
@ -415,8 +412,9 @@ bool OpenAL_SoundStream::init(bool getLoudnessData)
mDecoder->getInfo(&mSampleRate, &chans, &type);
mFormat = getALFormat(chans, type);
}
catch(std::exception &e) {
std::cerr<< "Failed to get stream info: "<<e.what() <<std::endl;
catch(std::exception &e)
{
Log(Debug::Error) << "Failed to get stream info: " << e.what();
return false;
}
@ -522,7 +520,7 @@ bool OpenAL_SoundStream::process()
}
}
catch(std::exception&) {
std::cout<< "Error updating stream \""<<mDecoder->getName()<<"\"" <<std::endl;
Log(Debug::Error) << "Error updating stream \"" << mDecoder->getName() << "\"";
mIsFinished = true;
}
return !mIsFinished;
@ -593,17 +591,18 @@ bool OpenAL_Output::init(const std::string &devname, const std::string &hrtfname
{
deinit();
std::cout<< "Initializing OpenAL..." <<std::endl;
Log(Debug::Info) << "Initializing OpenAL...";
mDevice = alcOpenDevice(devname.c_str());
if(!mDevice && !devname.empty())
{
std::cerr<< "Failed to open \""<<devname<<"\", trying default" <<std::endl;
Log(Debug::Warning) << "Failed to open \"" << devname << "\", trying default";
mDevice = alcOpenDevice(nullptr);
}
if(!mDevice)
{
std::cerr<< "Failed to open default audio device" <<std::endl;
Log(Debug::Error) << "Failed to open default audio device";
return false;
}
@ -612,13 +611,13 @@ bool OpenAL_Output::init(const std::string &devname, const std::string &hrtfname
name = alcGetString(mDevice, ALC_ALL_DEVICES_SPECIFIER);
if(alcGetError(mDevice) != AL_NO_ERROR || !name)
name = alcGetString(mDevice, ALC_DEVICE_SPECIFIER);
std::cout<< "Opened \""<<name<<"\"" <<std::endl;
Log(Debug::Info) << "Opened \"" << name << "\"";
ALCint major=0, minor=0;
alcGetIntegerv(mDevice, ALC_MAJOR_VERSION, 1, &major);
alcGetIntegerv(mDevice, ALC_MINOR_VERSION, 1, &minor);
std::cout<< " ALC Version: "<<major<<"."<<minor<<"\n"<<
" ALC Extensions: "<<alcGetString(mDevice, ALC_EXTENSIONS) <<std::endl;
Log(Debug::Info) << " ALC Version: " << major << "." << minor <<"\n" <<
" ALC Extensions: " << alcGetString(mDevice, ALC_EXTENSIONS);
ALC.EXT_EFX = alcIsExtensionPresent(mDevice, "ALC_EXT_EFX");
ALC.SOFT_HRTF = alcIsExtensionPresent(mDevice, "ALC_SOFT_HRTF");
@ -650,7 +649,7 @@ bool OpenAL_Output::init(const std::string &devname, const std::string &hrtfname
}
if(index < 0)
std::cerr<< "Failed to find HRTF \""<<hrtfname<<"\", using default" <<std::endl;
Log(Debug::Warning) << "Failed to find HRTF \"" << hrtfname << "\", using default";
else
{
attrs.push_back(ALC_HRTF_ID_SOFT);
@ -663,7 +662,7 @@ bool OpenAL_Output::init(const std::string &devname, const std::string &hrtfname
mContext = alcCreateContext(mDevice, attrs.data());
if(!mContext || alcMakeContextCurrent(mContext) == ALC_FALSE)
{
std::cerr<< "Failed to setup audio context: "<<alcGetString(mDevice, alcGetError(mDevice)) <<std::endl;
Log(Debug::Error) << "Failed to setup audio context: "<<alcGetString(mDevice, alcGetError(mDevice));
if(mContext)
alcDestroyContext(mContext);
mContext = nullptr;
@ -672,23 +671,23 @@ bool OpenAL_Output::init(const std::string &devname, const std::string &hrtfname
return false;
}
std::cout<< " Vendor: "<<alGetString(AL_VENDOR)<<"\n"<<
" Renderer: "<<alGetString(AL_RENDERER)<<"\n"<<
" Version: "<<alGetString(AL_VERSION)<<"\n"<<
" Extensions: "<<alGetString(AL_EXTENSIONS)<<std::endl;
Log(Debug::Info) << " Vendor: "<<alGetString(AL_VENDOR)<<"\n"<<
" Renderer: "<<alGetString(AL_RENDERER)<<"\n"<<
" Version: "<<alGetString(AL_VERSION)<<"\n"<<
" Extensions: "<<alGetString(AL_EXTENSIONS);
if(!ALC.SOFT_HRTF)
std::cout<< "HRTF status unavailable" <<std::endl;
Log(Debug::Warning) << "HRTF status unavailable";
else
{
ALCint hrtf_state;
alcGetIntegerv(mDevice, ALC_HRTF_SOFT, 1, &hrtf_state);
if(!hrtf_state)
std::cout<< "HRTF disabled" <<std::endl;
Log(Debug::Info) << "HRTF disabled";
else
{
const ALCchar *hrtf = alcGetString(mDevice, ALC_HRTF_SPECIFIER_SOFT);
std::cout<< "Enabled HRTF "<<hrtf <<std::endl;
Log(Debug::Info) << "Enabled HRTF " << hrtf;
}
}
@ -716,7 +715,7 @@ bool OpenAL_Output::init(const std::string &devname, const std::string &hrtfname
}
if(mFreeSources.empty())
{
std::cerr<< "Could not allocate any sound sources" <<std::endl;
Log(Debug::Warning) << "Could not allocate any sound sourcess";
alcMakeContextCurrent(nullptr);
alcDestroyContext(mContext);
mContext = nullptr;
@ -724,7 +723,7 @@ bool OpenAL_Output::init(const std::string &devname, const std::string &hrtfname
mDevice = nullptr;
return false;
}
std::cout<< "Allocated "<<mFreeSources.size()<<" sound sources" <<std::endl;
Log(Debug::Info) << "Allocated " << mFreeSources.size() << " sound sources";
if(ALC.EXT_EFX)
{
@ -775,7 +774,7 @@ bool OpenAL_Output::init(const std::string &devname, const std::string &hrtfname
alFilteri(mWaterFilter, AL_FILTER_TYPE, AL_FILTER_LOWPASS);
if(alGetError() == AL_NO_ERROR)
{
std::cout<< "Low-pass filter supported" <<std::endl;
Log(Debug::Info) << "Low-pass filter supported";
alFilterf(mWaterFilter, AL_LOWPASS_GAIN, 0.9f);
alFilterf(mWaterFilter, AL_LOWPASS_GAINHF, 0.125f);
}
@ -795,12 +794,12 @@ bool OpenAL_Output::init(const std::string &devname, const std::string &hrtfname
{
alEffecti(mDefaultEffect, AL_EFFECT_TYPE, AL_EFFECT_EAXREVERB);
if(alGetError() == AL_NO_ERROR)
std::cout<< "EAX Reverb supported" <<std::endl;
Log(Debug::Info) << "EAX Reverb supported";
else
{
alEffecti(mDefaultEffect, AL_EFFECT_TYPE, AL_EFFECT_REVERB);
if(alGetError() == AL_NO_ERROR)
std::cout<< "Standard Reverb supported" <<std::endl;
Log(Debug::Info) << "Standard Reverb supported";
}
EFXEAXREVERBPROPERTIES props = EFX_REVERB_PRESET_GENERIC;
props.flGain = 0.0f;
@ -891,7 +890,7 @@ void OpenAL_Output::setHrtf(const std::string &hrtfname, HrtfMode hrtfmode)
{
if(!mDevice || !ALC.SOFT_HRTF)
{
std::cerr<< "HRTF extension not present" <<std::endl;
Log(Debug::Info) << "HRTF extension not present";
return;
}
@ -924,7 +923,7 @@ void OpenAL_Output::setHrtf(const std::string &hrtfname, HrtfMode hrtfmode)
}
if(index < 0)
std::cerr<< "Failed to find HRTF name \""<<hrtfname<<"\", using default" <<std::endl;
Log(Debug::Warning) << "Failed to find HRTF name \"" << hrtfname << "\", using default";
else
{
attrs.push_back(ALC_HRTF_ID_SOFT);
@ -937,11 +936,11 @@ void OpenAL_Output::setHrtf(const std::string &hrtfname, HrtfMode hrtfmode)
ALCint hrtf_state;
alcGetIntegerv(mDevice, ALC_HRTF_SOFT, 1, &hrtf_state);
if(!hrtf_state)
std::cout<< "HRTF disabled" <<std::endl;
Log(Debug::Info) << "HRTF disabled";
else
{
const ALCchar *hrtf = alcGetString(mDevice, ALC_HRTF_SPECIFIER_SOFT);
std::cout<< "Enabled HRTF "<<hrtf <<std::endl;
Log(Debug::Info) << "Enabled HRTF " << hrtf;
}
}
@ -977,7 +976,7 @@ std::pair<Sound_Handle,size_t> OpenAL_Output::loadSound(const std::string &fname
}
catch(std::exception &e)
{
std::cerr<< "Failed to load audio from "<<fname<<": "<<e.what() <<std::endl;
Log(Debug::Error) << "Failed to load audio from " << fname << ": " << e.what();
}
if(data.empty())
@ -1139,7 +1138,7 @@ bool OpenAL_Output::playSound(Sound *sound, Sound_Handle data, float offset)
if(mFreeSources.empty())
{
std::cerr<< "No free sources!" <<std::endl;
Log(Debug::Warning) << "No free sources!";
return false;
}
source = mFreeSources.front();
@ -1168,7 +1167,7 @@ bool OpenAL_Output::playSound3D(Sound *sound, Sound_Handle data, float offset)
if(mFreeSources.empty())
{
std::cerr<< "No free sources!" <<std::endl;
Log(Debug::Warning) << "No free sources!";
return false;
}
source = mFreeSources.front();
@ -1236,13 +1235,14 @@ bool OpenAL_Output::streamSound(DecoderPtr decoder, Stream *sound)
{
if(mFreeSources.empty())
{
std::cerr<< "No free sources!" <<std::endl;
Log(Debug::Warning) << "No free sources!";
return false;
}
ALuint source = mFreeSources.front();
if(sound->getIsLooping())
std::cout <<"Warning: cannot loop stream \""<<decoder->getName()<<"\""<< std::endl;
Log(Debug::Warning) << "Warning: cannot loop stream \"" << decoder->getName() << "\"";
initCommon2D(source, sound->getPosition(), sound->getRealVolume(), sound->getPitch(),
false, sound->getUseEnv());
if(getALError() != AL_NO_ERROR)
@ -1266,13 +1266,14 @@ bool OpenAL_Output::streamSound3D(DecoderPtr decoder, Stream *sound, bool getLou
{
if(mFreeSources.empty())
{
std::cerr<< "No free sources!" <<std::endl;
Log(Debug::Warning) << "No free sources!";
return false;
}
ALuint source = mFreeSources.front();
if(sound->getIsLooping())
std::cout <<"Warning: cannot loop stream \""<<decoder->getName()<<"\""<< std::endl;
Log(Debug::Warning) << "Warning: cannot loop stream \"" << decoder->getName() << "\"";
initCommon3D(source, sound->getPosition(), sound->getMinDistance(), sound->getMaxDistance(),
sound->getRealVolume(), sound->getPitch(), false, sound->getUseEnv());
if(getALError() != AL_NO_ERROR)

@ -1,6 +1,5 @@
#include "soundmanagerimp.hpp"
#include <iostream>
#include <algorithm>
#include <map>
#include <numeric>
@ -8,7 +7,7 @@
#include <osg/Matrixf>
#include <components/misc/rng.hpp>
#include <components/debug/debuglog.hpp>
#include <components/vfs/manager.hpp>
#include "../mwbase/environment.hpp"
@ -81,7 +80,7 @@ namespace MWSound
if(!useSound)
{
std::cout<< "Sound disabled." <<std::endl;
Log(Debug::Info) << "Sound disabled.";
return;
}
@ -93,23 +92,28 @@ namespace MWSound
std::string devname = Settings::Manager::getString("device", "Sound");
if(!mOutput->init(devname, hrtfname, hrtfmode))
{
std::cerr<< "Failed to initialize audio output, sound disabled" <<std::endl;
Log(Debug::Error) << "Failed to initialize audio output, sound disabled";
return;
}
std::vector<std::string> names = mOutput->enumerate();
std::cout <<"Enumerated output devices:\n";
std::stringstream stream;
stream << "Enumerated output devices:\n";
for(const std::string &name : names)
std::cout <<" "<<name<<"\n";
std::cout.flush();
stream << " " << name;
Log(Debug::Info) << stream.str();
stream.str("");
names = mOutput->enumerateHrtf();
if(!names.empty())
{
std::cout<< "Enumerated HRTF names:\n";
stream << "Enumerated HRTF names:\n";
for(const std::string &name : names)
std::cout <<" "<<name<<"\n";
std::cout.flush();
stream << " " << name;
Log(Debug::Info) << stream.str();
}
}
@ -221,7 +225,7 @@ namespace MWSound
do {
if(mUnusedBuffers.empty())
{
std::cerr<< "No unused sound buffers to free, using "<<mBufferCacheSize<<" bytes!" <<std::endl;
Log(Debug::Warning) << "No unused sound buffers to free, using " << mBufferCacheSize << " bytes!";
break;
}
Sound_Buffer *unused = mUnusedBuffers.back();
@ -360,7 +364,7 @@ namespace MWSound
{
if(!mOutput->isInitialized())
return;
std::cout <<"Playing "<<filename<< std::endl;
Log(Debug::Info) << "Playing " << filename;
mLastPlayedMusic = filename;
stopMusic();

@ -1,5 +1,7 @@
#include "statemanagerimp.hpp"
#include <components/debug/debuglog.hpp>
#include <components/esm/esmwriter.hpp>
#include <components/esm/esmreader.hpp>
#include <components/esm/cellid.hpp>
@ -157,7 +159,7 @@ void MWState::StateManager::newGame (bool bypass)
std::stringstream error;
error << "Failed to start new game: " << e.what();
std::cerr << error.str() << std::endl;
Log(Debug::Error) << error.str();
cleanup (true);
MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu);
@ -283,7 +285,7 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
// Ensure we have written the number of records that was estimated
if (writer.getRecordCount() != recordCount+1) // 1 extra for TES3 record
std::cerr << "Warning: number of written savegame records does not match. Estimated: " << recordCount+1 << ", written: " << writer.getRecordCount() << std::endl;
Log(Debug::Warning) << "Warning: number of written savegame records does not match. Estimated: " << recordCount+1 << ", written: " << writer.getRecordCount();
writer.close();
@ -305,7 +307,7 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
std::stringstream error;
error << "Failed to save game: " << e.what();
std::cerr << error.str() << std::endl;
Log(Debug::Error) << error.str();
std::vector<std::string> buttons;
buttons.push_back("#{sOk}");
@ -483,7 +485,7 @@ void MWState::StateManager::loadGame (const Character *character, const std::str
default:
// ignore invalid records
std::cerr << "Warning: Ignoring unknown record: " << n.toString() << std::endl;
Log(Debug::Warning) << "Warning: Ignoring unknown record: " << n.toString();
reader.skipRecord();
}
int progressPercent = static_cast<int>(float(reader.getFileOffset())/total*100);
@ -549,7 +551,7 @@ void MWState::StateManager::loadGame (const Character *character, const std::str
std::stringstream error;
error << "Failed to load saved game: " << e.what();
std::cerr << error.str() << std::endl;
Log(Debug::Error) << error.str();
cleanup (true);
MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu);
@ -625,7 +627,7 @@ bool MWState::StateManager::verifyProfile(const ESM::SavedGame& profile) const
if (std::find(selectedContentFiles.begin(), selectedContentFiles.end(), *it)
== selectedContentFiles.end())
{
std::cerr << "Warning: Savegame dependency " << *it << " is missing." << std::endl;
Log(Debug::Warning) << "Warning: Savegame dependency " << *it << " is missing.";
notFound = true;
}
}
@ -653,7 +655,7 @@ void MWState::StateManager::writeScreenshot(std::vector<char> &imageData) const
osgDB::ReaderWriter* readerwriter = osgDB::Registry::instance()->getReaderWriterForExtension("jpg");
if (!readerwriter)
{
std::cerr << "Error: Unable to write screenshot, can't find a jpg ReaderWriter" << std::endl;
Log(Debug::Error) << "Error: Unable to write screenshot, can't find a jpg ReaderWriter";
return;
}
@ -661,7 +663,7 @@ void MWState::StateManager::writeScreenshot(std::vector<char> &imageData) const
osgDB::ReaderWriter::WriteResult result = readerwriter->writeImage(*screenshot, ostream);
if (!result.success())
{
std::cerr << "Error: Unable to write screenshot: " << result.message() << " code " << result.status() << std::endl;
Log(Debug::Error) << "Error: Unable to write screenshot: " << result.message() << " code " << result.status();
return;
}

@ -1,7 +1,6 @@
#include "cellpreloader.hpp"
#include <iostream>
#include <components/debug/debuglog.hpp>
#include <components/resource/scenemanager.hpp>
#include <components/resource/resourcesystem.hpp>
#include <components/resource/bulletshapemanager.hpp>
@ -229,12 +228,12 @@ namespace MWWorld
{
if (!mWorkQueue)
{
std::cerr << "Error: can't preload, no work queue set " << std::endl;
Log(Debug::Error) << "Error: can't preload, no work queue set";
return;
}
if (cell->getState() == CellStore::State_Unloaded)
{
std::cerr << "Error: can't preload objects for unloaded cell" << std::endl;
Log(Debug::Error) << "Error: can't preload objects for unloaded cell";
return;
}

@ -1,7 +1,6 @@
#include "cells.hpp"
#include <iostream>
#include <components/debug/debuglog.hpp>
#include <components/esm/esmreader.hpp>
#include <components/esm/esmwriter.hpp>
#include <components/esm/defs.hpp>
@ -350,7 +349,7 @@ bool MWWorld::Cells::readRecord (ESM::ESMReader& reader, uint32_t type,
catch (...)
{
// silently drop cells that don't exist anymore
std::cerr << "Warning: Dropping state for cell " << state.mId.mWorldspace << " (cell no longer exists)" << std::endl;
Log(Debug::Warning) << "Warning: Dropping state for cell " << state.mId.mWorldspace << " (cell no longer exists)";
reader.skipRecord();
return true;
}

@ -1,8 +1,9 @@
#include "cellstore.hpp"
#include <iostream>
#include <algorithm>
#include <components/debug/debuglog.hpp>
#include <components/esm/cellstate.hpp>
#include <components/esm/cellid.hpp>
#include <components/esm/esmreader.hpp>
@ -138,7 +139,7 @@ namespace
return;
}
std::cerr << "Warning: Dropping reference to " << state.mRef.mRefID << " (invalid content file link)" << std::endl;
Log(Debug::Warning) << "Warning: Dropping reference to " << state.mRef.mRefID << " (invalid content file link)";
return;
}
@ -196,9 +197,9 @@ namespace MWWorld
}
else
{
std::cerr
Log(Debug::Warning)
<< "Warning: could not resolve cell reference '" << ref.mRefID << "'"
<< " (dropping reference)" << std::endl;
<< " (dropping reference)";
}
}
@ -497,7 +498,7 @@ namespace MWWorld
}
catch (std::exception& e)
{
std::cerr << "An error occurred listing references for cell " << getCell()->getDescription() << ": " << e.what() << std::endl;
Log(Debug::Error) << "An error occurred listing references for cell " << getCell()->getDescription() << ": " << e.what();
}
}
@ -553,7 +554,7 @@ namespace MWWorld
}
catch (std::exception& e)
{
std::cerr << "An error occurred loading references for cell " << getCell()->getDescription() << ": " << e.what() << std::endl;
Log(Debug::Error) << "An error occurred loading references for cell " << getCell()->getDescription() << ": " << e.what();
}
}
@ -659,11 +660,10 @@ namespace MWWorld
case ESM::REC_WEAP: mWeapons.load(ref, deleted, store); break;
case ESM::REC_BODY: mBodyParts.load(ref, deleted, store); break;
case 0: std::cerr << "Cell reference '" + ref.mRefID + "' not found!\n"; return;
case 0: Log(Debug::Error) << "Cell reference '" + ref.mRefID + "' not found!"; return;
default:
std::cerr
<< "Error: Ignoring reference '" << ref.mRefID << "' of unhandled type\n";
Log(Debug::Error) << "Error: Ignoring reference '" << ref.mRefID << "' of unhandled type";
return;
}
@ -756,7 +756,7 @@ namespace MWWorld
int type = MWBase::Environment::get().getWorld()->getStore().find(cref.mRefID);
if (type == 0)
{
std::cerr << "Dropping reference to '" << cref.mRefID << "' (object no longer exists)" << std::endl;
Log(Debug::Warning) << "Dropping reference to '" << cref.mRefID << "' (object no longer exists)";
reader.skipHSubUntil("OBJE");
continue;
}
@ -892,7 +892,7 @@ namespace MWWorld
if (!visitor.mFound)
{
std::cerr << "Warning: Dropping moved ref tag for " << refnum.mIndex << " (moved object no longer exists)" << std::endl;
Log(Debug::Warning) << "Warning: Dropping moved ref tag for " << refnum.mIndex << " (moved object no longer exists)";
continue;
}
@ -902,8 +902,8 @@ namespace MWWorld
if (otherCell == NULL)
{
std::cerr << "Warning: Dropping moved ref tag for " << movedRef->mRef.getRefId()
<< " (target cell " << movedTo.mWorldspace << " no longer exists). Reference moved back to its original location." << std::endl;
Log(Debug::Warning) << "Warning: Dropping moved ref tag for " << movedRef->mRef.getRefId()
<< " (target cell " << movedTo.mWorldspace << " no longer exists). Reference moved back to its original location.";
// Note by dropping tag the object will automatically re-appear in its original cell, though potentially at inapproriate coordinates.
// Restore original coordinates:
movedRef->mData.setPosition(movedRef->mRef.getPosition());
@ -913,7 +913,7 @@ namespace MWWorld
if (otherCell == this)
{
// Should never happen unless someone's tampering with files.
std::cerr << "Found invalid moved ref, ignoring" << std::endl;
Log(Debug::Warning) << "Found invalid moved ref, ignoring";
continue;
}

@ -4,6 +4,7 @@
#include <typeinfo>
#include <stdexcept>
#include <components/debug/debuglog.hpp>
#include <components/esm/inventorystate.hpp>
#include "../mwbase/environment.hpp"
@ -502,7 +503,7 @@ void MWWorld::ContainerStore::addInitialItem (const std::string& id, const std::
}
catch (const std::exception& e)
{
std::cerr << "Warning: MWWorld::ContainerStore::addInitialItem: " << e.what() << std::endl;
Log(Debug::Warning) << "Warning: MWWorld::ContainerStore::addInitialItem: " << e.what();
}
}
@ -826,10 +827,10 @@ void MWWorld::ContainerStore::readState (const ESM::InventoryState& inventory)
case ESM::REC_WEAP: readEquipmentState (getState (weapons, state), thisIndex, inventory); break;
case ESM::REC_LIGH: readEquipmentState (getState (lights, state), thisIndex, inventory); break;
case 0:
std::cerr << "Dropping inventory reference to '" << state.mRef.mRefID << "' (object no longer exists)" << std::endl;
Log(Debug::Warning) << "Dropping inventory reference to '" << state.mRef.mRefID << "' (object no longer exists)";
break;
default:
std::cerr << "Warning: Invalid item type in inventory state, refid " << state.mRef.mRefID << std::endl;
Log(Debug::Warning) << "Warning: Invalid item type in inventory state, refid " << state.mRef.mRefID;
break;
}
}

@ -2,10 +2,10 @@
#define CONTENTLOADER_HPP
#include <iosfwd>
#include <iostream>
#include <boost/filesystem/path.hpp>
#include <MyGUI_TextIterator.h>
#include <components/debug/debuglog.hpp>
#include "components/loadinglistener/loadinglistener.hpp"
namespace MWWorld
@ -24,8 +24,8 @@ struct ContentLoader
virtual void load(const boost::filesystem::path& filepath, int& index)
{
std::cout << "Loading content file " << filepath.string() << std::endl;
mListener.setLabel(MyGUI::TextIterator::toTagsString(filepath.string()));
Log(Debug::Info) << "Loading content file " << filepath.string();
mListener.setLabel(MyGUI::TextIterator::toTagsString(filepath.string()));
}
protected:

@ -1,12 +1,11 @@
#include "esmstore.hpp"
#include <set>
#include <iostream>
#include <boost/filesystem/operations.hpp>
#include <components/debug/debuglog.hpp>
#include <components/loadinglistener/loadinglistener.hpp>
#include <components/esm/esmreader.hpp>
#include <components/esm/esmwriter.hpp>
@ -84,7 +83,7 @@ void ESMStore::load(ESM::ESMReader &esm, Loading::Listener* listener)
}
else
{
std::cerr << "error: info record without dialog" << std::endl;
Log(Debug::Error) << "Error: info record without dialog";
esm.skipRecord();
}
} else if (n.intval == ESM::REC_MGEF) {
@ -170,7 +169,7 @@ void ESMStore::validate()
const ESM::Faction *fact = mFactions.search(npcFaction);
if (!fact)
{
std::cerr << "NPC '" << npc.mId << "' (" << npc.mName << ") has nonexistent faction '" << npc.mFaction << "', ignoring it." << std::endl;
Log(Debug::Verbose) << "NPC '" << npc.mId << "' (" << npc.mName << ") has nonexistent faction '" << npc.mFaction << "', ignoring it.";
npc.mFaction = "";
npc.mNpdt.mRank = -1;
changed = true;
@ -183,7 +182,7 @@ void ESMStore::validate()
const ESM::Class *cls = mClasses.search(npcClass);
if (!cls)
{
std::cerr << "NPC '" << npc.mId << "' (" << npc.mName << ") has nonexistent class '" << npc.mClass << "', using '" << defaultCls << "' class as replacement." << std::endl;
Log(Debug::Verbose) << "NPC '" << npc.mId << "' (" << npc.mName << ") has nonexistent class '" << npc.mClass << "', using '" << defaultCls << "' class as replacement.";
npc.mClass = defaultCls;
changed = true;
}

@ -3,6 +3,7 @@
#include <iterator>
#include <algorithm>
#include <components/debug/debuglog.hpp>
#include <components/esm/loadench.hpp>
#include <components/esm/inventorystate.hpp>
#include <components/misc/rng.hpp>
@ -895,7 +896,7 @@ void MWWorld::InventoryStore::updateRechargingItems()
enchantmentId);
if (!enchantment)
{
std::cerr << "Warning: Can't find enchantment '" << enchantmentId << "' on item " << it->getCellRef().getRefId() << std::endl;
Log(Debug::Warning) << "Warning: Can't find enchantment '" << enchantmentId << "' on item " << it->getCellRef().getRefId();
continue;
}

@ -1,7 +1,6 @@
#include "livecellref.hpp"
#include <iostream>
#include <components/debug/debuglog.hpp>
#include <components/esm/objectstate.hpp>
#include "../mwbase/environment.hpp"
@ -38,10 +37,9 @@ void MWWorld::LiveCellRefBase::loadImp (const ESM::ObjectState& state)
}
catch (const std::exception& exception)
{
std::cerr
Log(Debug::Error)
<< "Error: failed to load state for local script " << scriptId
<< " because an exception has been thrown: " << exception.what()
<< std::endl;
<< " because an exception has been thrown: " << exception.what();
}
}
}
@ -51,7 +49,7 @@ void MWWorld::LiveCellRefBase::loadImp (const ESM::ObjectState& state)
if (!mRef.getSoul().empty() && !MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().search(mRef.getSoul()))
{
std::cerr << "Soul '" << mRef.getSoul() << "' not found, removing the soul from soul gem" << std::endl;
Log(Debug::Warning) << "Soul '" << mRef.getSoul() << "' not found, removing the soul from soul gem";
mRef.setSoul(std::string());
}
}

@ -1,14 +1,12 @@
#include "localscripts.hpp"
#include <iostream>
#include <components/debug/debuglog.hpp>
#include "esmstore.hpp"
#include "cellstore.hpp"
#include "class.hpp"
#include "containerstore.hpp"
namespace
{
@ -93,7 +91,7 @@ void MWWorld::LocalScripts::add (const std::string& scriptName, const Ptr& ptr)
for (std::list<std::pair<std::string, Ptr> >::iterator iter = mScripts.begin(); iter!=mScripts.end(); ++iter)
if (iter->second==ptr)
{
std::cerr << "Error: tried to add local script twice for " << ptr.getCellRef().getRefId() << std::endl;
Log(Debug::Warning) << "Error: tried to add local script twice for " << ptr.getCellRef().getRefId();
remove(ptr);
break;
}
@ -102,15 +100,15 @@ void MWWorld::LocalScripts::add (const std::string& scriptName, const Ptr& ptr)
}
catch (const std::exception& exception)
{
std::cerr
Log(Debug::Error)
<< "failed to add local script " << scriptName
<< " because an exception has been thrown: " << exception.what() << std::endl;
<< " because an exception has been thrown: " << exception.what();
}
}
else
std::cerr
Log(Debug::Warning)
<< "failed to add local script " << scriptName
<< " because the script does not exist." << std::endl;
<< " because the script does not exist.";
}
void MWWorld::LocalScripts::addCell (CellStore *cell)

@ -1,7 +1,8 @@
#include "player.hpp"
#include <stdexcept>
#include <iostream>
#include <components/debug/debuglog.hpp>
#include <components/esm/esmreader.hpp>
#include <components/esm/esmwriter.hpp>
@ -364,7 +365,7 @@ namespace MWWorld
if (!player.mObject.mEnabled)
{
std::cerr << "Warning: Savegame attempted to disable the player." << std::endl;
Log(Debug::Warning) << "Warning: Savegame attempted to disable the player.";
player.mObject.mEnabled = true;
}
@ -391,7 +392,7 @@ namespace MWWorld
}
catch (...)
{
std::cerr << "Warning: Player cell '" << player.mCellId.mWorldspace << "' no longer exists" << std::endl;
Log(Debug::Warning) << "Warning: Player cell '" << player.mCellId.mWorldspace << "' no longer exists";
// Cell no longer exists. The loader will have to choose a default cell.
mCellStore = NULL;
}

@ -1,11 +1,12 @@
#include "projectilemanager.hpp"
#include <iomanip>
#include <iostream>
#include <osg/PositionAttitudeTransform>
#include <osg/ComputeBoundsVisitor>
#include <components/debug/debuglog.hpp>
#include <components/esm/esmwriter.hpp>
#include <components/esm/projectilestate.hpp>
@ -647,7 +648,7 @@ namespace MWWorld
}
catch(...)
{
std::cerr << "Warning: Failed to recreate magic projectile from saved data (id \"" << state.mSpellId << "\" no longer exists?)" << std::endl;
Log(Debug::Warning) << "Warning: Failed to recreate magic projectile from saved data (id \"" << state.mSpellId << "\" no longer exists?)";
return true;
}

@ -1,8 +1,8 @@
#include "scene.hpp"
#include <limits>
#include <iostream>
#include <components/debug/debuglog.hpp>
#include <components/loadinglistener/loadinglistener.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/settings/settings.hpp>
@ -56,7 +56,7 @@ namespace
{
if (ptr.getRefData().getBaseNode() || physics.getActor(ptr))
{
std::cerr << "Warning: Tried to add " << ptr.getCellRef().getRefId() << " to the scene twice" << std::endl;
Log(Debug::Warning) << "Warning: Tried to add " << ptr.getCellRef().getRefId() << " to the scene twice";
return;
}
@ -160,7 +160,7 @@ namespace
catch (const std::exception& e)
{
std::string error ("failed to render '" + ptr.getCellRef().getRefId() + "': ");
std::cerr << error + e.what() << std::endl;
Log(Debug::Error) << error + e.what();
}
}
@ -232,7 +232,7 @@ namespace MWWorld
void Scene::unloadCell (CellStoreCollection::iterator iter)
{
std::cout << "Unloading cell\n";
Log(Debug::Info) << "Unloading cell " << (*iter)->getCell()->getDescription();
ListAndResetObjectsVisitor visitor;
(*iter)->forEach<ListAndResetObjectsVisitor>(visitor);
@ -270,7 +270,7 @@ namespace MWWorld
if(result.second)
{
std::cout << "Loading cell " << cell->getCell()->getDescription() << std::endl;
Log(Debug::Info) << "Loading cell " << cell->getCell()->getDescription();
float verts = ESM::Land::LAND_SIZE;
float worldsize = ESM::Land::REAL_SIZE;
@ -546,7 +546,7 @@ namespace MWWorld
return;
}
std::cout << "Changing to interior\n";
Log(Debug::Info) << "Changing to interior";
// unload
CellStoreCollection::iterator active = mActiveCells.begin();
@ -624,7 +624,7 @@ namespace MWWorld
}
catch (std::exception& e)
{
std::cerr << "failed to render '" << ptr.getCellRef().getRefId() << "': " << e.what() << std::endl;
Log(Debug::Error) << "failed to render '" << ptr.getCellRef().getRefId() << "': " << e.what();
}
}

@ -1,5 +1,7 @@
#include "store.hpp"
#include <components/debug/debuglog.hpp>
#include <components/esm/esmreader.hpp>
#include <components/esm/esmwriter.hpp>
@ -8,7 +10,6 @@
#include <stdexcept>
#include <sstream>
#include <iostream>
namespace
{
@ -692,7 +693,7 @@ namespace MWWorld
if (it_lease != wipecell->mLeasedRefs.end())
wipecell->mLeasedRefs.erase(it_lease);
else
std::cerr << "Error: can't find " << it->mRefNum.mIndex << " " << it->mRefNum.mContentFile << " in leasedRefs " << std::endl;
Log(Debug::Error) << "Error: can't find " << it->mRefNum.mIndex << " " << it->mRefNum.mContentFile << " in leasedRefs";
}
*itold = *it;
}

@ -3,6 +3,8 @@
#include <osg/Group>
#include <osg/ComputeBoundsVisitor>
#include <components/debug/debuglog.hpp>
#include <components/esm/esmreader.hpp>
#include <components/esm/esmwriter.hpp>
#include <components/esm/cellid.hpp>
@ -1794,7 +1796,7 @@ namespace MWWorld
}
catch (std::exception& e)
{
std::cerr << "Error updating window manager: " << e.what() << std::endl;
Log(Debug::Error) << "Error updating window manager: " << e.what();
}
}
@ -3075,7 +3077,7 @@ namespace MWWorld
if ( closestMarker.isEmpty() )
{
std::cerr << "Failed to teleport: no closest marker found" << std::endl;
Log(Debug::Warning) << "Failed to teleport: no closest marker found";
return;
}
@ -3250,19 +3252,19 @@ namespace MWWorld
MWWorld::ConstPtr prisonMarker = getClosestMarker( ptr, "prisonmarker" );
if ( prisonMarker.isEmpty() )
{
std::cerr << "Failed to confiscate items: no closest prison marker found." << std::endl;
Log(Debug::Warning) << "Failed to confiscate items: no closest prison marker found.";
return;
}
std::string prisonName = prisonMarker.getCellRef().getDestCell();
if ( prisonName.empty() )
{
std::cerr << "Failed to confiscate items: prison marker not linked to prison interior" << std::endl;
Log(Debug::Warning) << "Failed to confiscate items: prison marker not linked to prison interior";
return;
}
MWWorld::CellStore *prison = getInterior( prisonName );
if ( !prison )
{
std::cerr << "Failed to confiscate items: failed to load cell " << prisonName << std::endl;
Log(Debug::Warning) << "Failed to confiscate items: failed to load cell " << prisonName;
return;
}
@ -3272,7 +3274,7 @@ namespace MWWorld
MWBase::Environment::get().getMechanicsManager()->confiscateStolenItems(ptr, closestChest);
}
else
std::cerr << "Failed to confiscate items: no stolen_goods container found" << std::endl;
Log(Debug::Warning) << "Failed to confiscate items: no stolen_goods container found";
}
void World::goToJail()

Loading…
Cancel
Save