diff options
author | Filippos Karapetis | 2011-01-23 14:49:50 +0000 |
---|---|---|
committer | Filippos Karapetis | 2011-01-23 14:49:50 +0000 |
commit | 00a0f8d15df8f241741e4a9a68a71641715ae062 (patch) | |
tree | d40be8437f7ca54dab9c77145bf72550bc5a3150 | |
parent | 411d41d3d0a3e4d14187d4a980c25c0a2e41ad9c (diff) | |
download | scummvm-rg350-00a0f8d15df8f241741e4a9a68a71641715ae062.tar.gz scummvm-rg350-00a0f8d15df8f241741e4a9a68a71641715ae062.tar.bz2 scummvm-rg350-00a0f8d15df8f241741e4a9a68a71641715ae062.zip |
SWORD25: Removed the custom log class and replaced it with warning/error/debugC calls
svn-id: r55462
47 files changed, 158 insertions, 590 deletions
diff --git a/engines/sword25/fmv/movieplayer.cpp b/engines/sword25/fmv/movieplayer.cpp index 356c2d11ff..4a3beb8f6c 100644 --- a/engines/sword25/fmv/movieplayer.cpp +++ b/engines/sword25/fmv/movieplayer.cpp @@ -32,6 +32,7 @@ * */ +#include "sword25/sword25.h" // for kDebugScript #include "sword25/fmv/movieplayer.h" #include "sword25/gfx/graphicengine.h" #include "sword25/gfx/panel.h" @@ -43,16 +44,14 @@ namespace Sword25 { -#define BS_LOG_PREFIX "MOVIEPLAYER" - #define FLT_EPSILON 1.192092896e-07F /* smallest such that 1.0+FLT_EPSILON != 1.0 */ #ifdef USE_THEORADEC MoviePlayer::MoviePlayer(Kernel *pKernel) : Service(pKernel), _decoder(g_system->getMixer()) { if (!registerScriptBindings()) - BS_LOG_ERRORLN("Script bindings could not be registered."); + error("Script bindings could not be registered."); else - BS_LOGLN("Script bindings registered."); + debugC(kDebugScript, "Script bindings registered."); } MoviePlayer::~MoviePlayer() { @@ -70,7 +69,7 @@ bool MoviePlayer::loadMovie(const Common::String &filename, uint z) { #if INDIRECTRENDERING _outputBitmap = pGfx->getMainPanel()->addDynamicBitmap(_decoder.getWidth(), _decoder.getHeight()); if (!_outputBitmap.isValid()) { - BS_LOG_ERRORLN("Output bitmap for movie playback could not be created."); + error("Output bitmap for movie playback could not be created."); return false; } @@ -177,7 +176,7 @@ double MoviePlayer::getTime() { MoviePlayer::MoviePlayer(Kernel *pKernel) : Service(pKernel) { if (!registerScriptBindings()) - BS_LOG_ERRORLN("Script bindings could not be registered."); + error("Script bindings could not be registered."); else BS_LOGLN("Script bindings registered."); } diff --git a/engines/sword25/gfx/animation.cpp b/engines/sword25/gfx/animation.cpp index 0d3baae347..d2274e9c8e 100644 --- a/engines/sword25/gfx/animation.cpp +++ b/engines/sword25/gfx/animation.cpp @@ -48,8 +48,6 @@ namespace Sword25 { -#define BS_LOG_PREFIX "ANIMATION" - Animation::Animation(RenderObjectPtr<RenderObject> parentPtr, const Common::String &fileName) : TimedRenderObject(parentPtr, RenderObject::TYPE_ANIMATION) { // Das BS_RenderObject konnte nicht erzeugt werden, daher muss an dieser Stelle abgebrochen werden. @@ -102,7 +100,7 @@ void Animation::initializeAnimationResource(const Common::String &fileName) { if (resourcePtr && resourcePtr->getType() == Resource::TYPE_ANIMATION) _animationResourcePtr = static_cast<AnimationResource *>(resourcePtr); else { - BS_LOG_ERRORLN("The resource \"%s\" could not be requested. The Animation can't be created.", fileName.c_str()); + error("The resource \"%s\" could not be requested. The Animation can't be created.", fileName.c_str()); return; } @@ -164,7 +162,7 @@ void Animation::setFrame(uint nr) { BS_ASSERT(animationDescriptionPtr); if (nr >= animationDescriptionPtr->getFrameCount()) { - BS_LOG_ERRORLN("Tried to set animation to illegal frame (%d). Value must be between 0 and %d.", + error("Tried to set animation to illegal frame (%d). Value must be between 0 and %d.", nr, animationDescriptionPtr->getFrameCount()); return; } @@ -326,7 +324,7 @@ bool Animation::lockAllFrames() { BS_ASSERT(animationDescriptionPtr); for (uint i = 0; i < animationDescriptionPtr->getFrameCount(); ++i) { if (!Kernel::getInstance()->getResourceManager()->requestResource(animationDescriptionPtr->getFrame(i).fileName)) { - BS_LOG_ERRORLN("Could not lock all animation frames."); + error("Could not lock all animation frames."); return false; } } @@ -344,7 +342,7 @@ bool Animation::unlockAllFrames() { for (uint i = 0; i < animationDescriptionPtr->getFrameCount(); ++i) { Resource *pResource; if (!(pResource = Kernel::getInstance()->getResourceManager()->requestResource(animationDescriptionPtr->getFrame(i).fileName))) { - BS_LOG_ERRORLN("Could not unlock all animation frames."); + error("Could not unlock all animation frames."); return false; } @@ -419,7 +417,7 @@ void Animation::setAlpha(int alpha) { AnimationDescription *animationDescriptionPtr = getAnimationDescription(); BS_ASSERT(animationDescriptionPtr); if (!animationDescriptionPtr->isAlphaAllowed()) { - BS_LOG_WARNINGLN("Tried to set alpha value on an animation that does not support alpha. Call was ignored."); + warning("Tried to set alpha value on an animation that does not support alpha. Call was ignored."); return; } @@ -434,7 +432,7 @@ void Animation::setModulationColor(uint modulationColor) { AnimationDescription *animationDescriptionPtr = getAnimationDescription(); BS_ASSERT(animationDescriptionPtr); if (!animationDescriptionPtr->isColorModulationAllowed()) { - BS_LOG_WARNINGLN("Tried to set modulation color on an animation that does not support color modulation. Call was ignored"); + warning("Tried to set modulation color on an animation that does not support color modulation. Call was ignored"); return; } @@ -454,7 +452,7 @@ void Animation::setScaleFactorX(float scaleFactorX) { AnimationDescription *animationDescriptionPtr = getAnimationDescription(); BS_ASSERT(animationDescriptionPtr); if (!animationDescriptionPtr->isScalingAllowed()) { - BS_LOG_WARNINGLN("Tried to set x scale factor on an animation that does not support scaling. Call was ignored"); + warning("Tried to set x scale factor on an animation that does not support scaling. Call was ignored"); return; } @@ -471,7 +469,7 @@ void Animation::setScaleFactorY(float scaleFactorY) { AnimationDescription *animationDescriptionPtr = getAnimationDescription(); BS_ASSERT(animationDescriptionPtr); if (!animationDescriptionPtr->isScalingAllowed()) { - BS_LOG_WARNINGLN("Tried to set y scale factor on an animation that does not support scaling. Call was ignored"); + warning("Tried to set y scale factor on an animation that does not support scaling. Call was ignored"); return; } diff --git a/engines/sword25/gfx/animationresource.cpp b/engines/sword25/gfx/animationresource.cpp index 6e5f683a2e..43a42a8e84 100644 --- a/engines/sword25/gfx/animationresource.cpp +++ b/engines/sword25/gfx/animationresource.cpp @@ -40,8 +40,6 @@ namespace Sword25 { -#define BS_LOG_PREFIX "ANIMATIONRESOURCE" - namespace { const int DEFAULT_FPS = 10; const int MIN_FPS = 1; @@ -67,7 +65,7 @@ AnimationResource::AnimationResource(const Common::String &filename) : uint fileSize; char *xmlData = _pPackage->getXmlFile(getFileName(), &fileSize); if (!xmlData) { - BS_LOG_ERRORLN("Could not read \"%s\".", getFileName().c_str()); + error("Could not read \"%s\".", getFileName().c_str()); return; } @@ -84,19 +82,19 @@ AnimationResource::AnimationResource(const Common::String &filename) : // Give an error message if there weren't any frames specified if (_frames.empty()) { - BS_LOG_ERRORLN("\"%s\" does not have any frames.", getFileName().c_str()); + error("\"%s\" does not have any frames.", getFileName().c_str()); return; } // Pre-cache all the frames if (!precacheAllFrames()) { - BS_LOG_ERRORLN("Could not precache all frames of \"%s\".", getFileName().c_str()); + error("Could not precache all frames of \"%s\".", getFileName().c_str()); return; } // Post processing to compute animation features if (!computeFeatures()) { - BS_LOG_ERRORLN("Could not determine the features of \"%s\".", getFileName().c_str()); + error("Could not determine the features of \"%s\".", getFileName().c_str()); return; } @@ -130,7 +128,7 @@ bool AnimationResource::parserCallback_animation(ParserNode *node) { } else if (strcmp(loopTypeString, "jojo") == 0) { _animationType = Animation::AT_JOJO; } else { - BS_LOG_WARNINGLN("Illegal type value (\"%s\") in <animation> tag in \"%s\". Assuming default (\"loop\").", + warning("Illegal type value (\"%s\") in <animation> tag in \"%s\". Assuming default (\"loop\").", loopTypeString, getFileName().c_str()); _animationType = Animation::AT_LOOP; } @@ -147,12 +145,12 @@ bool AnimationResource::parserCallback_frame(ParserNode *node) { const char *fileString = node->values["file"].c_str(); if (!fileString) { - BS_LOG_ERRORLN("<frame> tag without file attribute occurred in \"%s\".", getFileName().c_str()); + error("<frame> tag without file attribute occurred in \"%s\".", getFileName().c_str()); return false; } frame.fileName = _pPackage->getAbsolutePath(fileString); if (frame.fileName.empty()) { - BS_LOG_ERRORLN("Could not create absolute path for file specified in <frame> tag in \"%s\": \"%s\".", + error("Could not create absolute path for file specified in <frame> tag in \"%s\": \"%s\".", getFileName().c_str(), fileString); return false; } @@ -165,25 +163,25 @@ bool AnimationResource::parserCallback_frame(ParserNode *node) { const char *hotspotyString = node->values["hotspoty"].c_str(); if ((!hotspotxString && hotspotyString) || (hotspotxString && !hotspotyString)) - BS_LOG_WARNINGLN("%s attribute occurred without %s attribute in <frame> tag in \"%s\". Assuming default (\"0\").", + warning("%s attribute occurred without %s attribute in <frame> tag in \"%s\". Assuming default (\"0\").", hotspotxString ? "hotspotx" : "hotspoty", !hotspotyString ? "hotspoty" : "hotspotx", getFileName().c_str()); frame.hotspotX = 0; if (hotspotxString && !parseIntegerKey(hotspotxString, 1, &frame.hotspotX)) - BS_LOG_WARNINGLN("Illegal hotspotx value (\"%s\") in frame tag in \"%s\". Assuming default (\"%s\").", + warning("Illegal hotspotx value (\"%s\") in frame tag in \"%s\". Assuming default (\"%s\").", hotspotxString, getFileName().c_str(), frame.hotspotX); frame.hotspotY = 0; if (hotspotyString && !parseIntegerKey(hotspotyString, 1, &frame.hotspotY)) - BS_LOG_WARNINGLN("Illegal hotspoty value (\"%s\") in frame tag in \"%s\". Assuming default (\"%s\").", + warning("Illegal hotspoty value (\"%s\") in frame tag in \"%s\". Assuming default (\"%s\").", hotspotyString, getFileName().c_str(), frame.hotspotY); Common::String flipVString = node->values["flipv"]; if (!flipVString.empty()) { if (!parseBooleanKey(flipVString, frame.flipV)) { - BS_LOG_WARNINGLN("Illegal flipv value (\"%s\") in <frame> tag in \"%s\". Assuming default (\"false\").", + warning("Illegal flipv value (\"%s\") in <frame> tag in \"%s\". Assuming default (\"false\").", flipVString.c_str(), getFileName().c_str()); frame.flipV = false; } @@ -193,7 +191,7 @@ bool AnimationResource::parserCallback_frame(ParserNode *node) { Common::String flipHString = node->values["fliph"]; if (!flipHString.empty()) { if (!parseBooleanKey(flipVString, frame.flipV)) { - BS_LOG_WARNINGLN("Illegal fliph value (\"%s\") in <frame> tag in \"%s\". Assuming default (\"false\").", + warning("Illegal fliph value (\"%s\") in <frame> tag in \"%s\". Assuming default (\"false\").", flipHString.c_str(), getFileName().c_str()); frame.flipH = false; } @@ -211,7 +209,7 @@ bool AnimationResource::precacheAllFrames() const { Common::Array<Frame>::const_iterator iter = _frames.begin(); for (; iter != _frames.end(); ++iter) { if (!Kernel::getInstance()->getResourceManager()->precacheResource((*iter).fileName)) { - BS_LOG_ERRORLN("Could not precache \"%s\".", (*iter).fileName.c_str()); + error("Could not precache \"%s\".", (*iter).fileName.c_str()); return false; } } @@ -232,7 +230,7 @@ bool AnimationResource::computeFeatures() { for (; iter != _frames.end(); ++iter) { BitmapResource *pBitmap; if (!(pBitmap = static_cast<BitmapResource *>(Kernel::getInstance()->getResourceManager()->requestResource((*iter).fileName)))) { - BS_LOG_ERRORLN("Could not request \"%s\".", (*iter).fileName.c_str()); + error("Could not request \"%s\".", (*iter).fileName.c_str()); return false; } diff --git a/engines/sword25/gfx/animationtemplate.cpp b/engines/sword25/gfx/animationtemplate.cpp index 4a060dbad9..835ae09fe8 100644 --- a/engines/sword25/gfx/animationtemplate.cpp +++ b/engines/sword25/gfx/animationtemplate.cpp @@ -32,8 +32,6 @@ * */ -#define BS_LOG_PREFIX "ANIMATIONTEMPLATE" - #include "sword25/kernel/kernel.h" #include "sword25/kernel/resource.h" #include "sword25/kernel/outputpersistenceblock.h" @@ -128,7 +126,7 @@ AnimationResource *AnimationTemplate::requestSourceAnimation(const Common::Strin ResourceManager *RMPtr = Kernel::getInstance()->getResourceManager(); Resource *resourcePtr; if (NULL == (resourcePtr = RMPtr->requestResource(sourceAnimation)) || resourcePtr->getType() != Resource::TYPE_ANIMATION) { - BS_LOG_ERRORLN("The resource \"%s\" could not be requested or is has an invalid type. The animation template can't be created.", sourceAnimation.c_str()); + error("The resource \"%s\" could not be requested or is has an invalid type. The animation template can't be created.", sourceAnimation.c_str()); return 0; } return static_cast<AnimationResource *>(resourcePtr); @@ -158,7 +156,7 @@ void AnimationTemplate::setFrame(int destIndex, int srcIndex) { bool AnimationTemplate::validateSourceIndex(uint index) const { if (index > _sourceAnimationPtr->getFrameCount()) { - BS_LOG_WARNINGLN("Tried to insert a frame (\"%d\") that does not exist in the source animation (\"%s\"). Ignoring call.", + warning("Tried to insert a frame (\"%d\") that does not exist in the source animation (\"%s\"). Ignoring call.", index, _sourceAnimationPtr->getFileName().c_str()); return false; } else @@ -167,7 +165,7 @@ bool AnimationTemplate::validateSourceIndex(uint index) const { bool AnimationTemplate::validateDestIndex(uint index) const { if (index > _frames.size()) { - BS_LOG_WARNINGLN("Tried to change a nonexistent frame (\"%d\") in a template animation. Ignoring call.", + warning("Tried to change a nonexistent frame (\"%d\") in a template animation. Ignoring call.", index); return false; } else diff --git a/engines/sword25/gfx/animationtemplateregistry.cpp b/engines/sword25/gfx/animationtemplateregistry.cpp index 2245090f8f..d942ac2ff7 100644 --- a/engines/sword25/gfx/animationtemplateregistry.cpp +++ b/engines/sword25/gfx/animationtemplateregistry.cpp @@ -32,8 +32,6 @@ * */ -#define BS_LOG_PREFIX "ANIMATIONTEMPLATEREGISTRY" - #include "sword25/kernel/outputpersistenceblock.h" #include "sword25/kernel/inputpersistenceblock.h" #include "sword25/gfx/animationtemplateregistry.h" @@ -44,11 +42,11 @@ DECLARE_SINGLETON(Sword25::AnimationTemplateRegistry); namespace Sword25 { void AnimationTemplateRegistry::logErrorLn(const char *message) const { - BS_LOG_ERRORLN(message); + error(message); } void AnimationTemplateRegistry::logWarningLn(const char *message) const { - BS_LOG_WARNINGLN(message); + warning(message); } bool AnimationTemplateRegistry::persist(OutputPersistenceBlock &writer) { diff --git a/engines/sword25/gfx/bitmap.cpp b/engines/sword25/gfx/bitmap.cpp index b5412c8276..9010a9c981 100644 --- a/engines/sword25/gfx/bitmap.cpp +++ b/engines/sword25/gfx/bitmap.cpp @@ -38,8 +38,6 @@ namespace Sword25 { -#define BS_LOG_PREFIX "BITMAP" - Bitmap::Bitmap(RenderObjectPtr<RenderObject> parentPtr, TYPES type, uint handle) : RenderObject(parentPtr, type, handle), _modulationColor(0xffffffff), @@ -54,7 +52,7 @@ Bitmap::~Bitmap() { void Bitmap::setAlpha(int alpha) { if (!isAlphaAllowed()) { - BS_LOG_WARNINGLN("Tried to set alpha value on a bitmap that does not support alpha blending. Call was ignored."); + warning("Tried to set alpha value on a bitmap that does not support alpha blending. Call was ignored."); return; } @@ -64,7 +62,7 @@ void Bitmap::setAlpha(int alpha) { alpha = 0; if (alpha > 255) alpha = 255; - BS_LOG_WARNINGLN("Tried to set an invalid alpha value (%d) on a bitmap. Value was changed to %d.", oldAlpha, alpha); + warning("Tried to set an invalid alpha value (%d) on a bitmap. Value was changed to %d.", oldAlpha, alpha); return; } @@ -78,7 +76,7 @@ void Bitmap::setAlpha(int alpha) { void Bitmap::setModulationColor(uint modulationColor) { if (!isColorModulationAllowed()) { - BS_LOG_WARNINGLN("Tried to set modulation color of a bitmap that does not support color modulation. Call was ignored."); + warning("Tried to set modulation color of a bitmap that does not support color modulation. Call was ignored."); return; } @@ -96,12 +94,12 @@ void Bitmap::setScaleFactor(float scaleFactor) { void Bitmap::setScaleFactorX(float scaleFactorX) { if (!isScalingAllowed()) { - BS_LOG_WARNINGLN("Tried to set scale factor of a bitmap that does not support scaling. Call was ignored."); + warning("Tried to set scale factor of a bitmap that does not support scaling. Call was ignored."); return; } if (scaleFactorX < 0) { - BS_LOG_WARNINGLN("Tried to set scale factor of a bitmap to a negative value. Call was ignored."); + warning("Tried to set scale factor of a bitmap to a negative value. Call was ignored."); return; } @@ -118,12 +116,12 @@ void Bitmap::setScaleFactorX(float scaleFactorX) { void Bitmap::setScaleFactorY(float scaleFactorY) { if (!isScalingAllowed()) { - BS_LOG_WARNINGLN("Tried to set scale factor of a bitmap that does not support scaling. Call was ignored."); + warning("Tried to set scale factor of a bitmap that does not support scaling. Call was ignored."); return; } if (scaleFactorY < 0) { - BS_LOG_WARNINGLN("Tried to set scale factor of a bitmap to a negative value. Call was ignored."); + warning("Tried to set scale factor of a bitmap to a negative value. Call was ignored."); return; } diff --git a/engines/sword25/gfx/bitmapresource.cpp b/engines/sword25/gfx/bitmapresource.cpp index cf3c85e3ac..ac36cd3223 100644 --- a/engines/sword25/gfx/bitmapresource.cpp +++ b/engines/sword25/gfx/bitmapresource.cpp @@ -39,8 +39,6 @@ namespace Sword25 { -#define BS_LOG_PREFIX "BITMAP" - BitmapResource::BitmapResource(const Common::String &filename, Image *pImage) : _valid(false), _pImage(pImage), diff --git a/engines/sword25/gfx/dynamicbitmap.cpp b/engines/sword25/gfx/dynamicbitmap.cpp index 612e370712..d4e39ed00b 100644 --- a/engines/sword25/gfx/dynamicbitmap.cpp +++ b/engines/sword25/gfx/dynamicbitmap.cpp @@ -39,8 +39,6 @@ namespace Sword25 { -#define BS_LOG_PREFIX "DYNAMICBITMAP" - DynamicBitmap::DynamicBitmap(RenderObjectPtr<RenderObject> parentPtr, uint width, uint height) : Bitmap(parentPtr, TYPE_DYNAMICBITMAP) { // Das BS_Bitmap konnte nicht erzeugt werden, daher muss an dieser Stelle abgebrochen werden. @@ -124,7 +122,7 @@ bool DynamicBitmap::persist(OutputPersistenceBlock &writer) { // Bilddaten werden nicht gespeichert. Dies ist auch nicht weiter von bedeutung, da BS_DynamicBitmap nur vom Videoplayer benutzt wird. // Während ein Video abläuft kann niemals gespeichert werden. BS_DynamicBitmap kann nur der Vollständigkeit halber persistiert werden. - BS_LOG_WARNINGLN("Persisting a BS_DynamicBitmap. Bitmap content is not persisted."); + warning("Persisting a BS_DynamicBitmap. Bitmap content is not persisted."); result &= RenderObject::persistChildren(writer); @@ -140,7 +138,7 @@ bool DynamicBitmap::unpersist(InputPersistenceBlock &reader) { result &= createRenderedImage(_width, _height); // Bilddaten werden nicht gespeichert (s.o.). - BS_LOG_WARNINGLN("Unpersisting a BS_DynamicBitmap. Bitmap contents are missing."); + warning("Unpersisting a BS_DynamicBitmap. Bitmap contents are missing."); // Bild mit durchsichtigen Bilddaten initialisieren. byte *transparentImageData = (byte *)calloc(_width * _height * 4, 1); diff --git a/engines/sword25/gfx/fontresource.cpp b/engines/sword25/gfx/fontresource.cpp index dbb9c67fe5..6f3e70c3fa 100644 --- a/engines/sword25/gfx/fontresource.cpp +++ b/engines/sword25/gfx/fontresource.cpp @@ -32,8 +32,6 @@ * */ -#define BS_LOG_PREFIX "FONTRESOURCE" - #include "sword25/kernel/kernel.h" #include "sword25/package/packagemanager.h" @@ -61,7 +59,7 @@ FontResource::FontResource(Kernel *pKernel, const Common::String &fileName) : uint fileSize; char *xmlData = pPackage->getXmlFile(getFileName(), &fileSize); if (!xmlData) { - BS_LOG_ERRORLN("Could not read \"%s\".", getFileName().c_str()); + error("Could not read \"%s\".", getFileName().c_str()); return; } @@ -79,13 +77,13 @@ bool FontResource::parserCallback_font(ParserNode *node) { Common::String bitmapFilename = node->values["bitmap"]; if (!parseIntegerKey(node->values["lineheight"], 1, &_lineHeight)) { - BS_LOG_WARNINGLN("Illegal or missing lineheight attribute in <font> tag in \"%s\". Assuming default (\"%d\").", + warning("Illegal or missing lineheight attribute in <font> tag in \"%s\". Assuming default (\"%d\").", getFileName().c_str(), DEFAULT_LINEHEIGHT); _lineHeight = DEFAULT_LINEHEIGHT; } if (!parseIntegerKey(node->values["gap"], 1, &_gapWidth)) { - BS_LOG_WARNINGLN("Illegal or missing gap attribute in <font> tag in \"%s\". Assuming default (\"%d\").", + warning("Illegal or missing gap attribute in <font> tag in \"%s\". Assuming default (\"%d\").", getFileName().c_str(), DEFAULT_GAPWIDTH); _gapWidth = DEFAULT_GAPWIDTH; } @@ -98,13 +96,13 @@ bool FontResource::parserCallback_font(ParserNode *node) { // Get the full path and filename for the bitmap resource _bitmapFileName = pPackage->getAbsolutePath(bitmapFilename); if (_bitmapFileName == "") { - BS_LOG_ERRORLN("Image file \"%s\" was specified in <font> tag of \"%s\" but could not be found.", + error("Image file \"%s\" was specified in <font> tag of \"%s\" but could not be found.", _bitmapFileName.c_str(), getFileName().c_str()); } // Pre-cache the resource if (!_pKernel->getResourceManager()->precacheResource(_bitmapFileName)) { - BS_LOG_ERRORLN("Could not precache \"%s\".", _bitmapFileName.c_str()); + error("Could not precache \"%s\".", _bitmapFileName.c_str()); } return true; diff --git a/engines/sword25/gfx/graphicengine.cpp b/engines/sword25/gfx/graphicengine.cpp index 44b9932de1..49cf1eb7bc 100644 --- a/engines/sword25/gfx/graphicengine.cpp +++ b/engines/sword25/gfx/graphicengine.cpp @@ -32,10 +32,9 @@ * */ -#define BS_LOG_PREFIX "GRAPHICENGINE" - #include "common/system.h" +#include "sword25/sword25.h" // for kDebugScript #include "sword25/gfx/bitmapresource.h" #include "sword25/gfx/animationresource.h" #include "sword25/gfx/fontresource.h" @@ -79,9 +78,9 @@ GraphicEngine::GraphicEngine(Kernel *pKernel) : _frameTimeSamples.resize(FRAMETIME_SAMPLE_COUNT); if (!registerScriptBindings()) - BS_LOG_ERRORLN("Script bindings could not be registered."); + error("Script bindings could not be registered."); else - BS_LOGLN("Script bindings registered."); + debugC(kDebugScript, "Script bindings registered."); } GraphicEngine::~GraphicEngine() { @@ -94,13 +93,13 @@ GraphicEngine::~GraphicEngine() { bool GraphicEngine::init(int width, int height, int bitDepth, int backbufferCount, bool isWindowed_) { // Warnung ausgeben, wenn eine nicht unterstützte Bittiefe gewählt wurde. if (bitDepth != BIT_DEPTH) { - BS_LOG_WARNINGLN("Can't use a bit depth of %d (not supported). Falling back to %d.", bitDepth, BIT_DEPTH); + warning("Can't use a bit depth of %d (not supported). Falling back to %d.", bitDepth, BIT_DEPTH); _bitDepth = BIT_DEPTH; } // Warnung ausgeben, wenn nicht genau ein Backbuffer gewählt wurde. if (backbufferCount != BACKBUFFER_COUNT) { - BS_LOG_WARNINGLN("Can't use %d backbuffers (not supported). Falling back to %d.", backbufferCount, BACKBUFFER_COUNT); + warning("Can't use %d backbuffers (not supported). Falling back to %d.", backbufferCount, BACKBUFFER_COUNT); backbufferCount = BACKBUFFER_COUNT; } @@ -311,7 +310,7 @@ Resource *GraphicEngine::loadResource(const Common::String &filename) { uint fileSize; pFileData = pPackage->getFile(filename, &fileSize); if (!pFileData) { - BS_LOG_ERRORLN("File \"%s\" could not be loaded.", filename.c_str()); + error("File \"%s\" could not be loaded.", filename.c_str()); return 0; } @@ -356,7 +355,7 @@ Resource *GraphicEngine::loadResource(const Common::String &filename) { } } - BS_LOG_ERRORLN("Service cannot load \"%s\".", filename.c_str()); + error("Service cannot load \"%s\".", filename.c_str()); return 0; } diff --git a/engines/sword25/gfx/graphicengine_script.cpp b/engines/sword25/gfx/graphicengine_script.cpp index 0814a23871..357787c9b8 100644 --- a/engines/sword25/gfx/graphicengine_script.cpp +++ b/engines/sword25/gfx/graphicengine_script.cpp @@ -50,8 +50,6 @@ namespace Sword25 { -#define BS_LOG_PREFIX "GRAPHICENGINE" - static bool animationDeleteCallback(uint Data); static bool animationActionCallback(uint Data); static bool animationLoopPointCallback(uint Data); diff --git a/engines/sword25/gfx/image/pngloader.cpp b/engines/sword25/gfx/image/pngloader.cpp index 581d5fd917..f104372f78 100644 --- a/engines/sword25/gfx/image/pngloader.cpp +++ b/engines/sword25/gfx/image/pngloader.cpp @@ -42,9 +42,6 @@ namespace Sword25 { -#define BS_LOG_PREFIX "PNGLOADER" - - /** * Load a NULL-terminated string from the given stream. */ diff --git a/engines/sword25/gfx/image/renderedimage.cpp b/engines/sword25/gfx/image/renderedimage.cpp index ce04d79aa3..c0eec6570c 100644 --- a/engines/sword25/gfx/image/renderedimage.cpp +++ b/engines/sword25/gfx/image/renderedimage.cpp @@ -44,8 +44,6 @@ namespace Sword25 { -#define BS_LOG_PREFIX "RENDEREDIMAGE" - // ----------------------------------------------------------------------------- // CONSTRUCTION / DESTRUCTION // ----------------------------------------------------------------------------- @@ -66,21 +64,21 @@ RenderedImage::RenderedImage(const Common::String &filename, bool &result) : uint fileSize; pFileData = pPackage->getFile(filename, &fileSize); if (!pFileData) { - BS_LOG_ERRORLN("File \"%s\" could not be loaded.", filename.c_str()); + error("File \"%s\" could not be loaded.", filename.c_str()); return; } // Bildeigenschaften bestimmen int pitch; if (!PNGLoader::imageProperties(pFileData, fileSize, _width, _height)) { - BS_LOG_ERRORLN("Could not read image properties."); + error("Could not read image properties."); delete[] pFileData; return; } // Das Bild dekomprimieren if (!PNGLoader::decodeImage(pFileData, fileSize, _data, _width, _height, pitch)) { - BS_LOG_ERRORLN("Could not decode image."); + error("Could not decode image."); delete[] pFileData; return; } @@ -129,7 +127,7 @@ RenderedImage::~RenderedImage() { // ----------------------------------------------------------------------------- bool RenderedImage::fill(const Common::Rect *pFillRect, uint color) { - BS_LOG_ERRORLN("Fill() is not supported."); + error("Fill() is not supported."); return false; } @@ -138,7 +136,7 @@ bool RenderedImage::fill(const Common::Rect *pFillRect, uint color) { bool RenderedImage::setContent(const byte *pixeldata, uint size, uint offset, uint stride) { // Überprüfen, ob PixelData ausreichend viele Pixel enthält um ein Bild der Größe Width * Height zu erzeugen if (size < static_cast<uint>(_width * _height * 4)) { - BS_LOG_ERRORLN("PixelData vector is too small to define a 32 bit %dx%d image.", _width, _height); + error("PixelData vector is too small to define a 32 bit %dx%d image.", _width, _height); return false; } @@ -162,7 +160,7 @@ void RenderedImage::replaceContent(byte *pixeldata, int width, int height) { // ----------------------------------------------------------------------------- uint RenderedImage::getPixel(int x, int y) { - BS_LOG_ERRORLN("GetPixel() is not supported. Returning black."); + error("GetPixel() is not supported. Returning black."); return 0; } diff --git a/engines/sword25/gfx/image/swimage.cpp b/engines/sword25/gfx/image/swimage.cpp index 84aa35b0f4..143754ce58 100644 --- a/engines/sword25/gfx/image/swimage.cpp +++ b/engines/sword25/gfx/image/swimage.cpp @@ -38,9 +38,6 @@ namespace Sword25 { -#define BS_LOG_PREFIX "SWIMAGE" - - SWImage::SWImage(const Common::String &filename, bool &result) : _imageDataPtr(0), _width(0), @@ -55,21 +52,21 @@ SWImage::SWImage(const Common::String &filename, bool &result) : uint fileSize; pFileData = pPackage->getFile(filename, &fileSize); if (!pFileData) { - BS_LOG_ERRORLN("File \"%s\" could not be loaded.", filename.c_str()); + error("File \"%s\" could not be loaded.", filename.c_str()); return; } // Bildeigenschaften bestimmen int pitch; if (!PNGLoader::imageProperties(pFileData, fileSize, _width, _height)) { - BS_LOG_ERRORLN("Could not read image properties."); + error("Could not read image properties."); return; } // Das Bild dekomprimieren byte *pUncompressedData; if (!PNGLoader::decodeImage(pFileData, fileSize, pUncompressedData, _width, _height, pitch)) { - BS_LOG_ERRORLN("Could not decode image."); + error("Could not decode image."); return; } @@ -92,17 +89,17 @@ bool SWImage::blit(int posX, int posY, Common::Rect *pPartRect, uint color, int width, int height) { - BS_LOG_ERRORLN("Blit() is not supported."); + error("Blit() is not supported."); return false; } bool SWImage::fill(const Common::Rect *pFillRect, uint color) { - BS_LOG_ERRORLN("Fill() is not supported."); + error("Fill() is not supported."); return false; } bool SWImage::setContent(const byte *pixeldata, uint size, uint offset, uint stride) { - BS_LOG_ERRORLN("SetContent() is not supported."); + error("SetContent() is not supported."); return false; } diff --git a/engines/sword25/gfx/image/vectorimage.cpp b/engines/sword25/gfx/image/vectorimage.cpp index 5c15c4771a..b2af06105d 100644 --- a/engines/sword25/gfx/image/vectorimage.cpp +++ b/engines/sword25/gfx/image/vectorimage.cpp @@ -44,8 +44,6 @@ namespace Sword25 { -#define BS_LOG_PREFIX "VECTORIMAGE" - #define BEZSMOOTHNESS 0.5 // ----------------------------------------------------------------------------- @@ -234,21 +232,21 @@ VectorImage::VectorImage(const byte *pFileData, uint fileSize, bool &success, co if (signature[0] != 'F' || signature[1] != 'W' || signature[2] != 'S') { - BS_LOG_ERRORLN("File is not a valid SWF-file"); + error("File is not a valid SWF-file"); return; } // Versionsangabe überprüfen uint32 version = bs.getByte(); if (version > MAX_ACCEPTED_FLASH_VERSION) { - BS_LOG_ERRORLN("File is of version %d. Highest accepted version is %d.", version, MAX_ACCEPTED_FLASH_VERSION); + error("File is of version %d. Highest accepted version is %d.", version, MAX_ACCEPTED_FLASH_VERSION); return; } // Dateigröße auslesen und mit der tatsächlichen Größe vergleichen uint32 storedFileSize = bs.getUInt32(); if (storedFileSize != fileSize) { - BS_LOG_ERRORLN("File is not a valid SWF-file"); + error("File is not a valid SWF-file"); return; } @@ -582,7 +580,7 @@ bool VectorImage::parseStyles(uint shapeType, SWFBitStream &bs, uint &numFillBit // ----------------------------------------------------------------------------- bool VectorImage::fill(const Common::Rect *pFillRect, uint color) { - BS_LOG_ERRORLN("Fill() is not supported."); + error("Fill() is not supported."); return false; } @@ -590,14 +588,14 @@ bool VectorImage::fill(const Common::Rect *pFillRect, uint color) { // ----------------------------------------------------------------------------- uint VectorImage::getPixel(int x, int y) { - BS_LOG_ERRORLN("GetPixel() is not supported. Returning black."); + error("GetPixel() is not supported. Returning black."); return 0; } // ----------------------------------------------------------------------------- bool VectorImage::setContent(const byte *pixeldata, uint size, uint offset, uint stride) { - BS_LOG_ERRORLN("SetContent() is not supported."); + error("SetContent() is not supported."); return 0; } diff --git a/engines/sword25/gfx/panel.cpp b/engines/sword25/gfx/panel.cpp index 2de1de133a..6bf31d2fc8 100644 --- a/engines/sword25/gfx/panel.cpp +++ b/engines/sword25/gfx/panel.cpp @@ -41,8 +41,6 @@ namespace Sword25 { -#define BS_LOG_PREFIX "PANEL" - Panel::Panel(RenderObjectPtr<RenderObject> parentPtr, int width, int height, uint color) : RenderObject(parentPtr, RenderObject::TYPE_PANEL), _color(color) { @@ -52,12 +50,12 @@ Panel::Panel(RenderObjectPtr<RenderObject> parentPtr, int width, int height, uin _height = height; if (_width < 0) { - BS_LOG_ERRORLN("Tried to initialise a panel with an invalid width (%d).", _width); + error("Tried to initialise a panel with an invalid width (%d).", _width); return; } if (_height < 0) { - BS_LOG_ERRORLN("Tried to initialise a panel with an invalid height (%d).", _height); + error("Tried to initialise a panel with an invalid height (%d).", _height); return; } diff --git a/engines/sword25/gfx/renderobject.cpp b/engines/sword25/gfx/renderobject.cpp index 77af0bee92..4b9555731d 100644 --- a/engines/sword25/gfx/renderobject.cpp +++ b/engines/sword25/gfx/renderobject.cpp @@ -51,8 +51,6 @@ namespace Sword25 { -#define BS_LOG_PREFIX "RENDEROBJECT" - RenderObject::RenderObject(RenderObjectPtr<RenderObject> parentPtr, TYPES type, uint handle) : _managerPtr(0), _parentPtr(parentPtr), @@ -90,7 +88,7 @@ RenderObject::RenderObject(RenderObjectPtr<RenderObject> parentPtr, TYPES type, _parentPtr->addObject(this->getHandle()); } else { if (getType() != TYPE_ROOT) { - BS_LOG_ERRORLN("Tried to create a non-root render object and has no parent. All non-root render objects have to have a parent."); + error("Tried to create a non-root render object and has no parent. All non-root render objects have to have a parent."); return; } } @@ -226,7 +224,7 @@ void RenderObject::deleteAllChildren() { bool RenderObject::addObject(RenderObjectPtr<RenderObject> pObject) { if (!pObject.isValid()) { - BS_LOG_ERRORLN("Tried to add a null object to a renderobject."); + error("Tried to add a null object to a renderobject."); return false; } @@ -249,7 +247,7 @@ bool RenderObject::detatchChildren(RenderObjectPtr<RenderObject> pObject) { return true; } - BS_LOG_ERRORLN("Tried to detach children from a render object that isn't its parent."); + error("Tried to detach children from a render object that isn't its parent."); return false; } @@ -289,7 +287,7 @@ void RenderObject::setY(int y) { void RenderObject::setZ(int z) { if (z < 0) - BS_LOG_ERRORLN("Tried to set a negative Z value (%d).", z); + error("Tried to set a negative Z value (%d).", z); else _z = z; } @@ -500,7 +498,7 @@ RenderObjectPtr<RenderObject> RenderObject::recreatePersistedRenderObject(InputP break; default: - BS_LOG_ERRORLN("Cannot recreate render object of unknown type %d.", type); + error("Cannot recreate render object of unknown type %d.", type); } return result; diff --git a/engines/sword25/gfx/renderobjectmanager.cpp b/engines/sword25/gfx/renderobjectmanager.cpp index 94f7a04b45..1f7938f41f 100644 --- a/engines/sword25/gfx/renderobjectmanager.cpp +++ b/engines/sword25/gfx/renderobjectmanager.cpp @@ -46,8 +46,6 @@ namespace Sword25 { -#define BS_LOG_PREFIX "RENDEROBJECTMANAGER" - RenderObjectManager::RenderObjectManager(int width, int height, int framebufferCount) : _frameStarted(false) { // Wurzel des BS_RenderObject-Baumes erzeugen. diff --git a/engines/sword25/gfx/renderobjectregistry.cpp b/engines/sword25/gfx/renderobjectregistry.cpp index 8f55cf65a9..f8c7c39789 100644 --- a/engines/sword25/gfx/renderobjectregistry.cpp +++ b/engines/sword25/gfx/renderobjectregistry.cpp @@ -38,14 +38,12 @@ DECLARE_SINGLETON(Sword25::RenderObjectRegistry); namespace Sword25 { -#define BS_LOG_PREFIX "RENDEROBJECTREGISTRY" - void RenderObjectRegistry::logErrorLn(const char *message) const { - BS_LOG_ERRORLN(message); + error(message); } void RenderObjectRegistry::logWarningLn(const char *message) const { - BS_LOG_WARNINGLN(message); + warning(message); } } // End of namespace Sword25 diff --git a/engines/sword25/gfx/screenshot.cpp b/engines/sword25/gfx/screenshot.cpp index b7bb31c8e4..35e94976eb 100644 --- a/engines/sword25/gfx/screenshot.cpp +++ b/engines/sword25/gfx/screenshot.cpp @@ -35,8 +35,6 @@ // Disable symbol overrides so that we can use png.h #define FORBIDDEN_SYMBOL_ALLOW_ALL -#define BS_LOG_PREFIX "SCREENSHOT" - #include "common/memstream.h" #include "sword25/gfx/screenshot.h" #include "sword25/kernel/filesystemutil.h" @@ -130,7 +128,7 @@ Common::SeekableReadStream *Screenshot::createThumbnail(Graphics::Surface *data) // The source image must be 800x600. if (data->w != 800 || data->h != 600 || data->bytesPerPixel != 4) { - BS_LOG_ERRORLN("The sreenshot dimensions have to be 800x600 in order to be saved as a thumbnail."); + error("The sreenshot dimensions have to be 800x600 in order to be saved as a thumbnail."); return false; } diff --git a/engines/sword25/gfx/staticbitmap.cpp b/engines/sword25/gfx/staticbitmap.cpp index 3019fe0ac1..c9f3758505 100644 --- a/engines/sword25/gfx/staticbitmap.cpp +++ b/engines/sword25/gfx/staticbitmap.cpp @@ -40,8 +40,6 @@ namespace Sword25 { -#define BS_LOG_PREFIX "STATICBITMAP" - StaticBitmap::StaticBitmap(RenderObjectPtr<RenderObject> parentPtr, const Common::String &filename) : Bitmap(parentPtr, TYPE_STATICBITMAP) { // Das BS_Bitmap konnte nicht erzeugt werden, daher muss an dieser Stelle abgebrochen werden. @@ -60,11 +58,11 @@ bool StaticBitmap::initBitmapResource(const Common::String &filename) { // Bild-Resource laden Resource *resourcePtr = Kernel::getInstance()->getResourceManager()->requestResource(filename); if (!resourcePtr) { - BS_LOG_ERRORLN("Could not request resource \"%s\".", filename.c_str()); + warning("Could not request resource \"%s\".", filename.c_str()); return false; } if (resourcePtr->getType() != Resource::TYPE_BITMAP) { - BS_LOG_ERRORLN("Requested resource \"%s\" is not a bitmap.", filename.c_str()); + error("Requested resource \"%s\" is not a bitmap.", filename.c_str()); return false; } @@ -130,7 +128,7 @@ uint StaticBitmap::getPixel(int x, int y) const { } bool StaticBitmap::setContent(const byte *pixeldata, uint size, uint offset, uint stride) { - BS_LOG_ERRORLN("SetContent() ist not supported with this object."); + error("SetContent() ist not supported with this object."); return false; } diff --git a/engines/sword25/gfx/text.cpp b/engines/sword25/gfx/text.cpp index b8e12ba570..9609ef810b 100644 --- a/engines/sword25/gfx/text.cpp +++ b/engines/sword25/gfx/text.cpp @@ -46,8 +46,6 @@ namespace Sword25 { -#define BS_LOG_PREFIX "TEXT" - namespace { const uint AUTO_WRAP_THRESHOLD_DEFAULT = 300; } @@ -79,7 +77,7 @@ bool Text::setFont(const Common::String &font) { forceRefresh(); return true; } else { - BS_LOG_ERRORLN("Could not precache font \"%s\". Font probably does not exist.", font.c_str()); + error("Could not precache font \"%s\". Font probably does not exist.", font.c_str()); return false; } @@ -136,11 +134,11 @@ bool Text::doRender() { { Resource *pResource = rmPtr->requestResource(fontPtr->getCharactermapFileName()); if (!pResource) { - BS_LOG_ERRORLN("Could not request resource \"%s\".", fontPtr->getCharactermapFileName().c_str()); + warning("Could not request resource \"%s\".", fontPtr->getCharactermapFileName().c_str()); return false; } if (pResource->getType() != Resource::TYPE_BITMAP) { - BS_LOG_ERRORLN("Requested resource \"%s\" is not a bitmap.", fontPtr->getCharactermapFileName().c_str()); + error("Requested resource \"%s\" is not a bitmap.", fontPtr->getCharactermapFileName().c_str()); return false; } @@ -198,11 +196,11 @@ FontResource *Text::lockFontResource() { { Resource *resourcePtr = rmPtr->requestResource(_font); if (!resourcePtr) { - BS_LOG_ERRORLN("Could not request resource \"%s\".", _font.c_str()); + warning("Could not request resource \"%s\".", _font.c_str()); return NULL; } if (resourcePtr->getType() != Resource::TYPE_FONT) { - BS_LOG_ERRORLN("Requested resource \"%s\" is not a font.", _font.c_str()); + error("Requested resource \"%s\" is not a font.", _font.c_str()); return NULL; } diff --git a/engines/sword25/input/inputengine.cpp b/engines/sword25/input/inputengine.cpp index 82d5cad588..58b40a940d 100644 --- a/engines/sword25/input/inputengine.cpp +++ b/engines/sword25/input/inputengine.cpp @@ -32,12 +32,12 @@ * */ -#define BS_LOG_PREFIX "INPUTENGINE" - #include "common/algorithm.h" #include "common/events.h" #include "common/system.h" #include "common/util.h" + +#include "sword25/sword25.h" #include "sword25/kernel/kernel.h" #include "sword25/kernel/inputpersistenceblock.h" #include "sword25/kernel/outputpersistenceblock.h" @@ -70,9 +70,9 @@ InputEngine::InputEngine(Kernel *pKernel) : _rightMouseState[1] = false; if (!registerScriptBindings()) - BS_LOG_ERRORLN("Script bindings could not be registered."); + error("Script bindings could not be registered."); else - BS_LOGLN("Script bindings registered."); + debugC(kDebugScript, "Script bindings registered."); } InputEngine::~InputEngine() { diff --git a/engines/sword25/input/inputengine_script.cpp b/engines/sword25/input/inputengine_script.cpp index 2f16a21377..5ce93bab82 100644 --- a/engines/sword25/input/inputengine_script.cpp +++ b/engines/sword25/input/inputengine_script.cpp @@ -42,8 +42,6 @@ #include "sword25/input/inputengine.h" -#define BS_LOG_PREFIX "INPUTENGINE" - namespace Sword25 { static void theCharacterCallback(int character); diff --git a/engines/sword25/kernel/common.h b/engines/sword25/kernel/common.h index 7b11fe901f..4372bf2dc5 100644 --- a/engines/sword25/kernel/common.h +++ b/engines/sword25/kernel/common.h @@ -48,11 +48,10 @@ // Global constants #define DEBUG -#define BS_ACTIVATE_LOGGING // When defined, logging is activated - -// Engine Includes -#include "sword25/kernel/log.h" - +// Includes +#include "common/array.h" +#include "common/file.h" +#include "sword25/kernel/common.h" #include "common/debug.h" #define BS_ASSERT(EXP) assert(EXP) diff --git a/engines/sword25/kernel/filesystemutil.cpp b/engines/sword25/kernel/filesystemutil.cpp index d05ac922e1..b4d4b25f8d 100644 --- a/engines/sword25/kernel/filesystemutil.cpp +++ b/engines/sword25/kernel/filesystemutil.cpp @@ -41,8 +41,6 @@ namespace Sword25 { -#define BS_LOG_PREFIX "FILESYSTEMUTIL" - Common::String FileSystemUtil::getUserdataDirectory() { // FIXME: This code is a hack which bypasses the savefile API, // and should eventually be removed. diff --git a/engines/sword25/kernel/inputpersistenceblock.cpp b/engines/sword25/kernel/inputpersistenceblock.cpp index 652c2f362f..f3aebef203 100644 --- a/engines/sword25/kernel/inputpersistenceblock.cpp +++ b/engines/sword25/kernel/inputpersistenceblock.cpp @@ -32,8 +32,6 @@ * */ -#define BS_LOG_PREFIX "INPUTPERSISTENCEBLOCK" - #include "sword25/kernel/inputpersistenceblock.h" namespace Sword25 { @@ -46,7 +44,7 @@ InputPersistenceBlock::InputPersistenceBlock(const void *data, uint dataLength) InputPersistenceBlock::~InputPersistenceBlock() { if (_iter != _data.end()) - BS_LOG_WARNINGLN("Persistence block was not read to the end."); + warning("Persistence block was not read to the end."); } void InputPersistenceBlock::read(int16 &value) { @@ -131,7 +129,7 @@ bool InputPersistenceBlock::checkBlockSize(int size) { return true; } else { _errorState = END_OF_DATA; - BS_LOG_ERRORLN("Unexpected end of persistence block."); + error("Unexpected end of persistence block."); return false; } } @@ -144,7 +142,7 @@ bool InputPersistenceBlock::checkMarker(byte marker) { return true; } else { _errorState = OUT_OF_SYNC; - BS_LOG_ERRORLN("Wrong type marker found in persistence block."); + error("Wrong type marker found in persistence block."); return false; } } diff --git a/engines/sword25/kernel/kernel.cpp b/engines/sword25/kernel/kernel.cpp index 9bd8ac5ff7..c328cfdc68 100644 --- a/engines/sword25/kernel/kernel.cpp +++ b/engines/sword25/kernel/kernel.cpp @@ -33,6 +33,8 @@ */ #include "common/system.h" + +#include "sword25/sword25.h" // for kDebugScript #include "sword25/gfx/graphicengine.h" #include "sword25/fmv/movieplayer.h" #include "sword25/input/inputengine.h" @@ -45,8 +47,6 @@ namespace Sword25 { -#define BS_LOG_PREFIX "KERNEL" - Kernel *Kernel::_instance = 0; Kernel::Kernel() : @@ -60,8 +60,6 @@ Kernel::Kernel() : _fmv(0) { - // Log that the kernel is beign created - BS_LOGLN("created."); _instance = this; // Create the resource manager @@ -76,11 +74,11 @@ Kernel::Kernel() : // Register kernel script bindings if (!registerScriptBindings()) { - BS_LOG_ERRORLN("Script bindings could not be registered."); + error("Script bindings could not be registered."); _initSuccess = false; return; } - BS_LOGLN("Script bindings registered."); + debugC(kDebugScript, "Script bindings registered."); _input = new InputEngine(this); assert(_input); @@ -133,8 +131,6 @@ Kernel::~Kernel() { // Resource-Manager freigeben delete _resourceManager; - - BS_LOGLN("destroyed."); } /** diff --git a/engines/sword25/kernel/log.cpp b/engines/sword25/kernel/log.cpp deleted file mode 100644 index 91b0c36ac1..0000000000 --- a/engines/sword25/kernel/log.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -/* - * This code is based on Broken Sword 2.5 engine - * - * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer - * - * Licensed under GNU GPL v2 - * - */ - -#include "sword25/kernel/log.h" -#include "base/version.h" -#include "common/config-manager.h" -#include "common/fs.h" - -namespace Sword25 { - -static const char *BF_LOG_FILENAME = "log.txt"; -static const size_t LOG_BUFFERSIZE = 1024 * 16; - -// Logging will take place only when it's activated -#ifdef BS_ACTIVATE_LOGGING - -Common::WriteStream *BS_Log::_logFile = NULL; -bool BS_Log::_lineBegin = true; -const char *BS_Log::_prefix = NULL; -const char *BS_Log::_file = NULL; -int BS_Log::_line = 0; -bool BS_Log::_autoNewline = false; - -bool BS_Log::createLog() { - // Open the log file - Common::FSNode dataDir(ConfMan.get("path")); - Common::FSNode file = dataDir.getChild(BF_LOG_FILENAME); - - // Open the file for saving - _logFile = file.createWriteStream(); - - if (_logFile) { - // Add a title into the log file - log("Broken Sword 2.5 Engine - Build: %s - %s - VersionID: %s\n", __DATE__, __TIME__, gScummVMFullVersion); - log("-----------------------------------------------------------------------------------------------------\n"); - - return true; - } - - // Log file could not be created - return false; -} - -void BS_Log::closeLog() { - delete _logFile; - _logFile = NULL; -} - -void BS_Log::log(const char *format, ...) { - char message[LOG_BUFFERSIZE]; - - // Create the message - va_list argList; - va_start(argList, format); - vsnprintf(message, sizeof(message), format, argList); - - // Log the message - writeLog(message); - - flushLog(); -} - -void BS_Log::logPrefix(const char *prefix, const char *format, ...) { - char message[LOG_BUFFERSIZE]; - char extFormat[LOG_BUFFERSIZE]; - - // If the issue has ceased at the beginning of a new line, the new issue to begin with the prefix - extFormat[0] = 0; - if (_lineBegin) { - snprintf(extFormat, sizeof(extFormat), "%s: ", prefix); - _lineBegin = false; - } - // Format String pass line by line and each line with the initial prefix - for (;;) { - const char *nextLine = strstr(format, "\n"); - if (!nextLine || *(nextLine + strlen("\n")) == 0) { - Common::strlcat(extFormat, format, sizeof(extFormat)); - if (nextLine) - _lineBegin = true; - break; - } else { - strncat(extFormat, format, (nextLine - format) + strlen("\n")); - Common::strlcat(extFormat, prefix, sizeof(extFormat)); - Common::strlcat(extFormat, ": ", sizeof(extFormat)); - } - - format = nextLine + strlen("\n"); - } - - // Create message - va_list argList; - va_start(argList, format); - vsnprintf(message, sizeof(message), extFormat, argList); - - // Log the message - writeLog(message); - - flushLog(); -} - -void BS_Log::logDecorated(const char *format, ...) { - // Nachricht erzeugen - char message[LOG_BUFFERSIZE]; - va_list argList; - va_start(argList, format); - vsnprintf(message, sizeof(message), format, argList); - - // Zweiten prefix erzeugen, falls gewünscht - char secondaryPrefix[1024]; - if (_file && _line) - snprintf(secondaryPrefix, sizeof(secondaryPrefix), "(file: %s, line: %d) - ", _file, _line); - - // Nachricht zeilenweise ausgeben und an jeden Zeilenanfang das Präfix setzen - char *messageWalker = message; - for (;;) { - char *nextLine = strstr(messageWalker, "\n"); - if (nextLine) { - *nextLine = 0; - if (_lineBegin) { - writeLog(_prefix); - if (_file && _line) - writeLog(secondaryPrefix); - } - writeLog(messageWalker); - writeLog("\n"); - messageWalker = nextLine + sizeof("\n") - 1; - _lineBegin = true; - } else { - if (_lineBegin) { - writeLog(_prefix); - if (_file && _line) - writeLog(secondaryPrefix); - } - writeLog(messageWalker); - _lineBegin = false; - break; - } - } - - // Falls gewünscht, wird ans Ende der Nachricht automatisch ein Newline angehängt. - if (_autoNewline) { - writeLog("\n"); - _lineBegin = true; - } - - // Pseudoparameter zurücksetzen - _prefix = NULL; - _file = 0; - _line = 0; - _autoNewline = false; - - flushLog(); -} - -int BS_Log::writeLog(const char *message) { - if (!_logFile && !createLog()) - return false; - - debugN(0, "%s", message); - - _logFile->writeString(message); - - return true; -} - -void BS_Log::flushLog() { - if (_logFile) - _logFile->flush(); -} - -void (*BS_LogPtr)(const char *, ...) = BS_Log::log; - -void BS_Log_C(const char *message) { - BS_LogPtr(message); -} - -#else - -void BS_Log_C(const char *message) {}; - -#endif - -} // End of namespace Sword25 diff --git a/engines/sword25/kernel/log.h b/engines/sword25/kernel/log.h deleted file mode 100644 index e7c5789a53..0000000000 --- a/engines/sword25/kernel/log.h +++ /dev/null @@ -1,134 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -/* - * This code is based on Broken Sword 2.5 engine - * - * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer - * - * Licensed under GNU GPL v2 - * - */ - -#ifndef SWORD25_LOG_H -#define SWORD25_LOG_H - -// Includes -#include "common/array.h" -#include "common/file.h" -#include "sword25/kernel/common.h" - -namespace Sword25 { - -// Logging soll nur stattfinden wenn es aktiviert ist -#ifdef BS_ACTIVATE_LOGGING - -// Logging-Makros -#define BS_LOG BS_Log::setPrefix(BS_LOG_PREFIX ": "), BS_Log::logDecorated -#define BS_LOGLN BS_Log::setPrefix(BS_LOG_PREFIX ": "), BS_Log::setAutoNewline(true), BS_Log::logDecorated -#define BS_LOG_WARNING BS_Log::setPrefix(BS_LOG_PREFIX ": WARNING - "), BS_Log::logDecorated -#define BS_LOG_WARNINGLN BS_Log::setPrefix(BS_LOG_PREFIX ": WARNING - "), BS_Log::setAutoNewline(true), BS_Log::logDecorated -#define BS_LOG_ERROR BS_Log::setPrefix(BS_LOG_PREFIX ": ERROR - "), BS_Log::logDecorated -#define BS_LOG_ERRORLN BS_Log::setPrefix(BS_LOG_PREFIX ": ERROR - "), BS_Log::setAutoNewline(true), BS_Log::logDecorated -#define BS_LOG_EXTERROR BS_Log::setPrefix(BS_LOG_PREFIX ": ERROR "), BS_Log::setFile(__FILE__), BS_Log::setLine(__LINE__), BS_Log::logDecorated -#define BS_LOG_EXTERRORLN BS_Log::setPrefix(BS_LOG_PREFIX ": ERROR "), BS_Log::setFile(__FILE__), BS_Log::setLine(__LINE__), BS_Log::setAutoNewline(true), BS_Log::logDecorated - -// Die Version der Logging-Klasse mit aktiviertem Logging -class BS_Log { -public: - static void clear(); - static void log(const char *format, ...); - static void logPrefix(const char *prefix, const char *format, ...); - static void logDecorated(const char *format, ...); - - static void setPrefix(const char *prefix) { - _prefix = prefix; - } - static void setFile(const char *file) { - _file = file; - } - static void setLine(int line) { - _line = line; - } - static void setAutoNewline(bool autoNewline) { - _autoNewline = autoNewline; - } - - static void closeLog(); - -private: - static Common::WriteStream *_logFile; - static bool _lineBegin; - static const char *_prefix; - static const char *_file; - static int _line; - static bool _autoNewline; - - static bool createLog(); - - static int writeLog(const char *message); - static void flushLog(); -}; - -// Auxiliary function that allows to log C functions (needed for Lua). -#define BS_Log_C error - - -#else - -// Logging-Macros -#define BS_LOG -#define BS_LOGLN -#define BS_LOG_WARNING -#define BS_LOG_WARNINGLN -#define BS_LOG_ERROR -#define BS_LOG_ERRORLN -#define BS_LOG_EXTERROR -#define BS_LOG_EXTERRORLN - -// The version of the logging class with logging disabled -class BS_Log { -public: - // This version implements all the various methods as empty stubs - static void log(const char *text, ...) {}; - static void logPrefix(const char *prefix, const char *format, ...) {}; - static void logDecorated(const char *format, ...) {}; - - static void setPrefix(const char *prefix) {}; - static void setFile(const char *file) {}; - static void setLine(int line) {}; - static void setAutoNewline(bool autoNewline) {}; - - typedef void (*LOG_LISTENER_CALLBACK)(const char *); - static void registerLogListener(LOG_LISTENER_CALLBACK callback) {}; -}; - -#define BS_Log_C error - -#endif - -} // End of namespace Sword25 - -#endif diff --git a/engines/sword25/kernel/outputpersistenceblock.cpp b/engines/sword25/kernel/outputpersistenceblock.cpp index b1c3233b59..a8a39cb822 100644 --- a/engines/sword25/kernel/outputpersistenceblock.cpp +++ b/engines/sword25/kernel/outputpersistenceblock.cpp @@ -32,8 +32,6 @@ * */ -#define BS_LOG_PREFIX "OUTPUTPERSISTENCEBLOCK" - #include "sword25/kernel/outputpersistenceblock.h" namespace { diff --git a/engines/sword25/kernel/persistenceservice.cpp b/engines/sword25/kernel/persistenceservice.cpp index 0508f2be8f..be66b6abf0 100644 --- a/engines/sword25/kernel/persistenceservice.cpp +++ b/engines/sword25/kernel/persistenceservice.cpp @@ -46,8 +46,6 @@ #include "sword25/script/script.h" #include <zlib.h> -#define BS_LOG_PREFIX "PERSISTENCESERVICE" - namespace Sword25 { //static const char *SAVEGAME_EXTENSION = ".b25s"; @@ -215,7 +213,7 @@ namespace { bool checkslotID(uint slotID) { // Überprüfen, ob die Slot-ID zulässig ist. if (slotID >= SLOT_COUNT) { - BS_LOG_ERRORLN("Tried to access an invalid slot (%d). Only slot ids from 0 to %d are allowed.", slotID, SLOT_COUNT - 1); + error("Tried to access an invalid slot (%d). Only slot ids from 0 to %d are allowed.", slotID, SLOT_COUNT - 1); return false; } else { return true; @@ -255,7 +253,7 @@ bool PersistenceService::saveGame(uint slotID, const Common::String &screenshotF // Überprüfen, ob die Slot-ID zulässig ist. if (slotID >= SLOT_COUNT) { - BS_LOG_ERRORLN("Tried to save to an invalid slot (%d). Only slot ids form 0 to %d are allowed.", slotID, SLOT_COUNT - 1); + error("Tried to save to an invalid slot (%d). Only slot ids form 0 to %d are allowed.", slotID, SLOT_COUNT - 1); return false; } @@ -327,7 +325,7 @@ bool PersistenceService::saveGame(uint slotID, const Common::String &screenshotF delete[] buffer; } else { - BS_LOG_WARNINGLN("The screenshot file \"%s\" does not exist. Savegame is written without a screenshot.", filename.c_str()); + warning("The screenshot file \"%s\" does not exist. Savegame is written without a screenshot.", filename.c_str()); } file->finalize(); @@ -347,7 +345,7 @@ bool PersistenceService::loadGame(uint slotID) { // Überprüfen, ob die Slot-ID zulässig ist. if (slotID >= SLOT_COUNT) { - BS_LOG_ERRORLN("Tried to load from an invalid slot (%d). Only slot ids form 0 to %d are allowed.", slotID, SLOT_COUNT - 1); + error("Tried to load from an invalid slot (%d). Only slot ids form 0 to %d are allowed.", slotID, SLOT_COUNT - 1); return false; } @@ -355,7 +353,7 @@ bool PersistenceService::loadGame(uint slotID) { // Überprüfen, ob der Slot belegt ist. if (!curSavegameInfo.isOccupied) { - BS_LOG_ERRORLN("Tried to load from an empty slot (%d).", slotID); + error("Tried to load from an empty slot (%d).", slotID); return false; } @@ -364,7 +362,7 @@ bool PersistenceService::loadGame(uint slotID) { // da sich die Versions-ID bei jeder Codeänderung mitändert. #ifndef DEBUG if (!curSavegameInfo.isCompatible) { - BS_LOG_ERRORLN("Tried to load a savegame (%d) that is not compatible with this engine version.", slotID); + error("Tried to load a savegame (%d) that is not compatible with this engine version.", slotID); return false; } #endif @@ -377,7 +375,7 @@ bool PersistenceService::loadGame(uint slotID) { file->seek(curSavegameInfo.gamedataOffset); file->read(reinterpret_cast<char *>(&compressedDataBuffer[0]), curSavegameInfo.gamedataLength); if (file->err()) { - BS_LOG_ERRORLN("Unable to load the gamedata from the savegame file \"%s\".", curSavegameInfo.filename.c_str()); + error("Unable to load the gamedata from the savegame file \"%s\".", curSavegameInfo.filename.c_str()); delete[] compressedDataBuffer; delete[] uncompressedDataBuffer; return false; @@ -387,7 +385,7 @@ bool PersistenceService::loadGame(uint slotID) { uLongf uncompressedBufferSize = curSavegameInfo.gamedataUncompressedLength; if (uncompress(reinterpret_cast<Bytef *>(&uncompressedDataBuffer[0]), &uncompressedBufferSize, reinterpret_cast<Bytef *>(&compressedDataBuffer[0]), curSavegameInfo.gamedataLength) != Z_OK) { - BS_LOG_ERRORLN("Unable to decompress the gamedata from savegame file \"%s\".", curSavegameInfo.filename.c_str()); + error("Unable to decompress the gamedata from savegame file \"%s\".", curSavegameInfo.filename.c_str()); delete[] uncompressedDataBuffer; delete[] compressedDataBuffer; delete file; @@ -410,7 +408,7 @@ bool PersistenceService::loadGame(uint slotID) { delete file; if (!success) { - BS_LOG_ERRORLN("Unable to unpersist the gamedata from savegame file \"%s\".", curSavegameInfo.filename.c_str()); + error("Unable to unpersist the gamedata from savegame file \"%s\".", curSavegameInfo.filename.c_str()); return false; } diff --git a/engines/sword25/kernel/resmanager.cpp b/engines/sword25/kernel/resmanager.cpp index 1979e6e6c6..df975bcca6 100644 --- a/engines/sword25/kernel/resmanager.cpp +++ b/engines/sword25/kernel/resmanager.cpp @@ -32,16 +32,14 @@ * */ +#include "sword25/sword25.h" // for kDebugResource #include "sword25/kernel/resmanager.h" - #include "sword25/kernel/resource.h" #include "sword25/kernel/resservice.h" #include "sword25/package/packagemanager.h" namespace Sword25 { -#define BS_LOG_PREFIX "RESOURCEMANAGER" - ResourceManager::~ResourceManager() { // Clear all unlocked resources emptyCache(); @@ -49,7 +47,7 @@ ResourceManager::~ResourceManager() { // All remaining resources are not released, so print warnings and release Common::List<Resource *>::iterator iter = _resources.begin(); for (; iter != _resources.end(); ++iter) { - BS_LOG_WARNINGLN("Resource \"%s\" was not released.", (*iter)->getFileName().c_str()); + warning("Resource \"%s\" was not released.", (*iter)->getFileName().c_str()); // Set the lock count to zero while ((*iter)->getLockCount() > 0) { @@ -68,7 +66,7 @@ ResourceManager::~ResourceManager() { */ bool ResourceManager::registerResourceService(ResourceService *pService) { if (!pService) { - BS_LOG_ERRORLN("Can't register NULL resource service."); + error("Can't register NULL resource service."); return false; } @@ -136,7 +134,7 @@ Resource *ResourceManager::requestResource(const Common::String &fileName) { // The resource was not found, therefore, must not be loaded yet if (_logCacheMiss) - BS_LOG_WARNINGLN("\"%s\" was not precached.", uniqueFileName.c_str()); + warning("\"%s\" was not precached.", uniqueFileName.c_str()); Resource *pResource = loadResource(uniqueFileName); if (pResource) { @@ -163,7 +161,7 @@ bool ResourceManager::precacheResource(const Common::String &fileName, bool forc if (forceReload && resourcePtr) { if (resourcePtr->getLockCount()) { - BS_LOG_ERRORLN("Could not force precaching of \"%s\". The resource is locked.", fileName.c_str()); + error("Could not force precaching of \"%s\". The resource is locked.", fileName.c_str()); return false; } else { deleteResource(resourcePtr); @@ -172,7 +170,8 @@ bool ResourceManager::precacheResource(const Common::String &fileName, bool forc } if (!resourcePtr && loadResource(uniqueFileName) == NULL) { - BS_LOG_ERRORLN("Could not precache \"%s\",", fileName.c_str()); + // This isn't fatal - e.g. it can happen when loading saved games + debugC(kDebugResource, "Could not precache \"%s\",", fileName.c_str()); return false; } @@ -208,7 +207,7 @@ Resource *ResourceManager::loadResource(const Common::String &fileName) { // Load the resource Resource *pResource = _resourceServices[i]->loadResource(fileName); if (!pResource) { - BS_LOG_ERRORLN("Responsible service could not load resource \"%s\".", fileName.c_str()); + error("Responsible service could not load resource \"%s\".", fileName.c_str()); return NULL; } @@ -223,7 +222,8 @@ Resource *ResourceManager::loadResource(const Common::String &fileName) { } } - BS_LOG_ERRORLN("Could not find a service that can load \"%s\".", fileName.c_str()); + // This isn't fatal - e.g. it can happen when loading saved games + debugC(kDebugResource, "Could not find a service that can load \"%s\".", fileName.c_str()); return NULL; } @@ -235,14 +235,14 @@ Common::String ResourceManager::getUniqueFileName(const Common::String &fileName // Get a pointer to the package manager PackageManager *pPackage = (PackageManager *)_kernelPtr->getPackage(); if (!pPackage) { - BS_LOG_ERRORLN("Could not get package manager."); + error("Could not get package manager."); return Common::String(); } // Absoluten Pfad der Datei bekommen und somit die Eindeutigkeit des Dateinamens sicherstellen Common::String uniquefileName = pPackage->getAbsolutePath(fileName); if (uniquefileName.empty()) - BS_LOG_ERRORLN("Could not create absolute file name for \"%s\".", fileName.c_str()); + error("Could not create absolute file name for \"%s\".", fileName.c_str()); return uniquefileName; } @@ -284,7 +284,7 @@ Resource *ResourceManager::getResource(const Common::String &uniquefileName) con void ResourceManager::dumpLockedResources() { for (Common::List<Resource *>::iterator iter = _resources.begin(); iter != _resources.end(); ++iter) { if ((*iter)->getLockCount() > 0) { - BS_LOGLN("%s", (*iter)->getFileName().c_str()); + debugC(kDebugResource, "%s", (*iter)->getFileName().c_str()); } } } diff --git a/engines/sword25/kernel/resource.cpp b/engines/sword25/kernel/resource.cpp index 40eea2138c..2ec7c6736a 100644 --- a/engines/sword25/kernel/resource.cpp +++ b/engines/sword25/kernel/resource.cpp @@ -38,8 +38,6 @@ namespace Sword25 { -#define BS_LOG_PREFIX "RESOURCE" - Resource::Resource(const Common::String &fileName, RESOURCE_TYPES type) : _type(type), _refCount(0) { @@ -53,7 +51,7 @@ void Resource::release() { if (_refCount) { --_refCount; } else - BS_LOG_WARNINGLN("Released unlocked resource \"%s\".", _fileName.c_str()); + warning("Released unlocked resource \"%s\".", _fileName.c_str()); } } // End of namespace Sword25 diff --git a/engines/sword25/math/geometry.cpp b/engines/sword25/math/geometry.cpp index bad6fcdb06..cf3adae60a 100644 --- a/engines/sword25/math/geometry.cpp +++ b/engines/sword25/math/geometry.cpp @@ -32,17 +32,16 @@ * */ +#include "sword25/sword25.h" // for kDebugScript #include "sword25/math/geometry.h" namespace Sword25 { -#define BS_LOG_PREFIX "GEOMETRY" - Geometry::Geometry(Kernel *pKernel) : Service(pKernel) { if (!registerScriptBindings()) - BS_LOG_ERRORLN("Script bindings could not be registered."); + error("Script bindings could not be registered."); else - BS_LOGLN("Script bindings registered."); + debugC(kDebugScript, "Script bindings registered."); } diff --git a/engines/sword25/math/region.cpp b/engines/sword25/math/region.cpp index ae9b76d077..ae729c4de3 100644 --- a/engines/sword25/math/region.cpp +++ b/engines/sword25/math/region.cpp @@ -39,8 +39,6 @@ #include "sword25/math/walkregion.h" #include "sword25/math/regionregistry.h" -#define BS_LOG_PREFIX "REGION" - namespace Sword25 { Region::Region() : _valid(false), _type(RT_REGION) { @@ -261,7 +259,7 @@ Vertex Region::findClosestRegionPoint(const Vertex &point) const { } } - BS_LOG_WARNINGLN("Clostest vertex forced because edgepoint was outside region."); + warning("Clostest vertex forced because edgepoint was outside region."); return closestVertex; } } diff --git a/engines/sword25/math/regionregistry.cpp b/engines/sword25/math/regionregistry.cpp index c1fd6e98a8..f11f45540f 100644 --- a/engines/sword25/math/regionregistry.cpp +++ b/engines/sword25/math/regionregistry.cpp @@ -32,8 +32,6 @@ * */ -#define BS_LOG_PREFIX "REGIONREGISTRY" - #include "sword25/kernel/outputpersistenceblock.h" #include "sword25/kernel/inputpersistenceblock.h" #include "sword25/math/regionregistry.h" @@ -44,11 +42,11 @@ DECLARE_SINGLETON(Sword25::RegionRegistry); namespace Sword25 { void RegionRegistry::logErrorLn(const char *message) const { - BS_LOG_ERRORLN(message); + error(message); } void RegionRegistry::logWarningLn(const char *message) const { - BS_LOG_WARNINGLN(message); + warning(message); } bool RegionRegistry::persist(OutputPersistenceBlock &writer) { diff --git a/engines/sword25/math/walkregion.cpp b/engines/sword25/math/walkregion.cpp index da24883466..23f0e4e2ca 100644 --- a/engines/sword25/math/walkregion.cpp +++ b/engines/sword25/math/walkregion.cpp @@ -38,8 +38,6 @@ #include "sword25/math/walkregion.h" #include "sword25/math/line.h" -#define BS_LOG_PREFIX "WALKREGION" - namespace Sword25 { static const int Infinity = 0x7fffffff; @@ -285,7 +283,7 @@ bool WalkRegion::checkAndPrepareStartAndEnd(Vertex &start, Vertex &end) const { // Check to make sure the point is really in the region. If not, stop with an error if (!isPointInRegion(newStart)) { - BS_LOG_ERRORLN("Constructed startpoint ((%d,%d) from (%d,%d)) is not inside the region.", + error("Constructed startpoint ((%d,%d) from (%d,%d)) is not inside the region.", newStart.x, newStart.y, start.x, start.y); return false; @@ -301,7 +299,7 @@ bool WalkRegion::checkAndPrepareStartAndEnd(Vertex &start, Vertex &end) const { // Make sure that the determined point is really within the region if (!isPointInRegion(newEnd)) { - BS_LOG_ERRORLN("Constructed endpoint ((%d,%d) from (%d,%d)) is not inside the region.", + error("Constructed endpoint ((%d,%d) from (%d,%d)) is not inside the region.", newEnd.x, newEnd.y, end.x, end.y); return false; diff --git a/engines/sword25/module.mk b/engines/sword25/module.mk index 944e2c49c3..7fe76628b2 100644 --- a/engines/sword25/module.mk +++ b/engines/sword25/module.mk @@ -38,7 +38,6 @@ MODULE_OBJS := \ kernel/inputpersistenceblock.o \ kernel/kernel.o \ kernel/kernel_script.o \ - kernel/log.o \ kernel/outputpersistenceblock.o \ kernel/persistenceservice.o \ kernel/resmanager.o \ diff --git a/engines/sword25/package/packagemanager.cpp b/engines/sword25/package/packagemanager.cpp index 4765d26ed4..91bd6eb855 100644 --- a/engines/sword25/package/packagemanager.cpp +++ b/engines/sword25/package/packagemanager.cpp @@ -32,14 +32,13 @@ * */ -#define BS_LOG_PREFIX "PACKAGEMANAGER" - #include "common/archive.h" #include "common/config-manager.h" #include "common/savefile.h" #include "common/str-array.h" #include "common/system.h" #include "common/unzip.h" +#include "sword25/sword25.h" // for kDebugScript #include "sword25/kernel/filesystemutil.h" #include "sword25/package/packagemanager.h" @@ -62,9 +61,9 @@ PackageManager::PackageManager(Kernel *pKernel) : Service(pKernel), _currentDirectory(PATH_SEPARATOR), _rootFolder(ConfMan.get("path")) { if (!registerScriptBindings()) - BS_LOG_ERRORLN("Script bindings could not be registered."); + error("Script bindings could not be registered."); else - BS_LOGLN("Script bindings registered."); + debugC(kDebugScript, "Script bindings registered."); } PackageManager::~PackageManager() { @@ -106,10 +105,10 @@ bool PackageManager::loadPackage(const Common::String &fileName, const Common::S Common::Archive *zipFile = Common::makeZipArchive(fileName); if (zipFile == NULL) { - BS_LOG_ERRORLN("Unable to mount file \"%s\" to \"%s\"", fileName.c_str(), mountPosition.c_str()); + error("Unable to mount file \"%s\" to \"%s\"", fileName.c_str(), mountPosition.c_str()); return false; } else { - BS_LOGLN("Package '%s' mounted as '%s'.", fileName.c_str(), mountPosition.c_str()); + debugC(kDebugResource, "Package '%s' mounted as '%s'.", fileName.c_str(), mountPosition.c_str()); Common::ArchiveMemberList files; zipFile->listMembers(files); debug(3, "Capacity %d", files.size()); @@ -127,10 +126,10 @@ bool PackageManager::loadDirectoryAsPackage(const Common::String &directoryName, Common::FSNode directory(directoryName); Common::Archive *folderArchive = new Common::FSDirectory(directory, 6); if (!directory.exists() || (folderArchive == NULL)) { - BS_LOG_ERRORLN("Unable to mount directory \"%s\" to \"%s\".", directoryName.c_str(), mountPosition.c_str()); + error("Unable to mount directory \"%s\" to \"%s\".", directoryName.c_str(), mountPosition.c_str()); return false; } else { - BS_LOGLN("Directory '%s' mounted as '%s'.", directoryName.c_str(), mountPosition.c_str()); + debugC(kDebugResource, "Directory '%s' mounted as '%s'.", directoryName.c_str(), mountPosition.c_str()); Common::ArchiveMemberList files; folderArchive->listMembers(files); @@ -152,7 +151,7 @@ byte *PackageManager::getFile(const Common::String &fileName, uint *fileSizePtr) Common::InSaveFile *file = sfm->openForLoading( FileSystemUtil::getPathFilename(fileName)); if (!file) { - BS_LOG_ERRORLN("Could not load savegame \"%s\".", fileName.c_str()); + error("Could not load savegame \"%s\".", fileName.c_str()); return 0; } diff --git a/engines/sword25/script/lua_extensions.cpp b/engines/sword25/script/lua_extensions.cpp index 25a43e17d2..50d7acc52e 100644 --- a/engines/sword25/script/lua_extensions.cpp +++ b/engines/sword25/script/lua_extensions.cpp @@ -47,7 +47,6 @@ static int warning(lua_State *L) { lua_pushstring(L, "WARNING - "); lua_pushvalue(L, 1); lua_concat(L, 3); - BS_Log::log("%s\n", luaL_checkstring(L, -1)); lua_pop(L, 1); #ifdef DEBUG diff --git a/engines/sword25/script/luabindhelper.cpp b/engines/sword25/script/luabindhelper.cpp index 5367854218..b227754489 100644 --- a/engines/sword25/script/luabindhelper.cpp +++ b/engines/sword25/script/luabindhelper.cpp @@ -36,8 +36,6 @@ #include "sword25/script/luabindhelper.h" #include "sword25/script/luascript.h" -#define BS_LOG_PREFIX "LUABINDHELPER" - namespace { const char *METATABLES_TABLE_NAME = "__METATABLES"; const char *PERMANENTS_TABLE_NAME = "Permanents"; diff --git a/engines/sword25/script/luacallback.cpp b/engines/sword25/script/luacallback.cpp index bb2c821aa8..39ce29ea77 100644 --- a/engines/sword25/script/luacallback.cpp +++ b/engines/sword25/script/luacallback.cpp @@ -42,8 +42,6 @@ const char *CALLBACKTABLE_NAME = "__CALLBACKS"; namespace Sword25 { -#define BS_LOG_PREFIX "LUA" - LuaCallback::LuaCallback(lua_State *L) { // Create callback table lua_newtable(L); @@ -122,7 +120,7 @@ void LuaCallback::invokeCallbackFunctions(lua_State *L, uint objectHandle) { // Lua_pcall the function and the parameters pop themselves from the stack if (lua_pcall(L, argumentCount, 0, 0) != 0) { // An error has occurred - BS_LOG_ERRORLN("An error occured executing a callback function: %s", lua_tostring(L, -1)); + error("An error occured executing a callback function: %s", lua_tostring(L, -1)); // Pop error message from the stack lua_pop(L, 1); diff --git a/engines/sword25/script/luascript.cpp b/engines/sword25/script/luascript.cpp index aa2bdb9e06..140c09041b 100644 --- a/engines/sword25/script/luascript.cpp +++ b/engines/sword25/script/luascript.cpp @@ -32,8 +32,6 @@ * */ -#define BS_LOG_PREFIX "LUA" - #include "common/array.h" #include "common/debug-channels.h" @@ -66,7 +64,7 @@ LuaScriptEngine::~LuaScriptEngine() { namespace { int panicCB(lua_State *L) { - BS_LOG_ERRORLN("Lua panic. Error message: %s", lua_isnil(L, -1) ? "" : lua_tostring(L, -1)); + error("Lua panic. Error message: %s", lua_isnil(L, -1) ? "" : lua_tostring(L, -1)); return 0; } @@ -82,7 +80,7 @@ bool LuaScriptEngine::init() { // Lua-State initialisation, as well as standard libaries initialisation _state = luaL_newstate(); if (!_state || ! registerStandardLibs() || !registerStandardLibExtensions()) { - BS_LOG_ERRORLN("Lua could not be initialized."); + error("Lua could not be initialized."); return false; } @@ -100,7 +98,7 @@ bool LuaScriptEngine::init() { // Compile the code if (luaL_loadbuffer(_state, errorHandlerCode, strlen(errorHandlerCode), "PCALL ERRORHANDLER") != 0) { // An error occurred, so dislay the reason and exit - BS_LOG_ERRORLN("Couldn't compile luaL_pcall errorhandler:\n%s", lua_tostring(_state, -1)); + error("Couldn't compile luaL_pcall errorhandler:\n%s", lua_tostring(_state, -1)); lua_pop(_state, 1); return false; @@ -108,7 +106,7 @@ bool LuaScriptEngine::init() { // Running the code, the error handler function sets the top of the stack if (lua_pcall(_state, 0, 1, 0) != 0) { // An error occurred, so dislay the reason and exit - BS_LOG_ERRORLN("Couldn't prepare luaL_pcall errorhandler:\n%s", lua_tostring(_state, -1)); + error("Couldn't prepare luaL_pcall errorhandler:\n%s", lua_tostring(_state, -1)); lua_pop(_state, 1); return false; @@ -135,7 +133,7 @@ bool LuaScriptEngine::init() { lua_sethook(_state, debugHook, mask, 0); } - BS_LOGLN("Lua initialized."); + debugC(kDebugScript, "Lua initialized."); return true; } @@ -154,7 +152,7 @@ bool LuaScriptEngine::executeFile(const Common::String &fileName) { uint fileSize; byte *fileData = pPackage->getFile(fileName, &fileSize); if (!fileData) { - BS_LOG_ERRORLN("Couldn't read \"%s\".", fileName.c_str()); + error("Couldn't read \"%s\".", fileName.c_str()); #ifdef DEBUG BS_ASSERT(__startStackDepth == lua_gettop(_state)); #endif @@ -211,7 +209,7 @@ bool LuaScriptEngine::registerStandardLibs() { bool LuaScriptEngine::executeBuffer(const byte *data, uint size, const Common::String &name) const { // Compile buffer if (luaL_loadbuffer(_state, (const char *)data, size, name.c_str()) != 0) { - BS_LOG_ERRORLN("Couldn't compile \"%s\":\n%s", name.c_str(), lua_tostring(_state, -1)); + error("Couldn't compile \"%s\":\n%s", name.c_str(), lua_tostring(_state, -1)); lua_pop(_state, 1); return false; @@ -223,7 +221,7 @@ bool LuaScriptEngine::executeBuffer(const byte *data, uint size, const Common::S // Run buffer contents if (lua_pcall(_state, 0, 0, -2) != 0) { - BS_LOG_ERRORLN("An error occured while executing \"%s\":\n%s.", + error("An error occured while executing \"%s\":\n%s.", name.c_str(), lua_tostring(_state, -1)); lua_pop(_state, 2); diff --git a/engines/sword25/sfx/soundengine.cpp b/engines/sword25/sfx/soundengine.cpp index 3d8dc029cc..f28ad26fe7 100644 --- a/engines/sword25/sfx/soundengine.cpp +++ b/engines/sword25/sfx/soundengine.cpp @@ -32,8 +32,6 @@ * */ -#define BS_LOG_PREFIX "SOUNDENGINE" - #include "sword25/sword25.h" #include "sword25/sfx/soundengine.h" #include "sword25/package/packagemanager.h" @@ -57,9 +55,9 @@ private: SoundEngine::SoundEngine(Kernel *pKernel) : ResourceService(pKernel) { if (!registerScriptBindings()) - BS_LOG_ERRORLN("Script bindings could not be registered."); + error("Script bindings could not be registered."); else - BS_LOGLN("Script bindings registered."); + debugC(kDebugSound, "Script bindings registered."); _mixer = g_system->getMixer(); diff --git a/engines/sword25/sword25.cpp b/engines/sword25/sword25.cpp index 4c188fe7ea..b76de784b9 100644 --- a/engines/sword25/sword25.cpp +++ b/engines/sword25/sword25.cpp @@ -49,8 +49,6 @@ namespace Sword25 { -#define BS_LOG_PREFIX "MAIN" - const char *const PACKAGE_MANAGER = "archiveFS"; const char *const DEFAULT_SCRIPT_FILE = "/system/boot.lua"; @@ -96,7 +94,7 @@ Common::Error Sword25Engine::appStart() { // Kernel initialization if (!Kernel::getInstance()->getInitSuccess()) { - BS_LOG_ERRORLN("Kernel initialization failed."); + error("Kernel initialization failed."); return Common::kUnknownError; } @@ -113,7 +111,7 @@ Common::Error Sword25Engine::appStart() { // Pass the command line to the script engine. ScriptEngine *scriptPtr = Kernel::getInstance()->getScript(); if (!scriptPtr) { - BS_LOG_ERRORLN("Script intialization failed."); + error("Script intialization failed."); return Common::kUnknownError; } @@ -143,9 +141,6 @@ bool Sword25Engine::appEnd() { RenderObjectRegistry::destroy(); RegionRegistry::destroy(); - // Free the log file if it was used - BS_Log::closeLog(); - return true; } diff --git a/engines/sword25/sword25.h b/engines/sword25/sword25.h index 91b62cba09..9e9679526b 100644 --- a/engines/sword25/sword25.h +++ b/engines/sword25/sword25.h @@ -31,7 +31,6 @@ #include "common/util.h" #include "engines/engine.h" -#include "sword25/kernel/log.h" #include "sword25/console.h" struct ADGameDescription; @@ -52,7 +51,8 @@ enum { enum { kDebugScript = 1 << 0, - kDebugSound = 1 << 1 + kDebugSound = 1 << 1, + kDebugResource = 1 << 2 }; enum GameFlags { |