aboutsummaryrefslogtreecommitdiff
path: root/engines/sword25/kernel
diff options
context:
space:
mode:
authorFilippos Karapetis2011-01-23 14:49:50 +0000
committerFilippos Karapetis2011-01-23 14:49:50 +0000
commit00a0f8d15df8f241741e4a9a68a71641715ae062 (patch)
treed40be8437f7ca54dab9c77145bf72550bc5a3150 /engines/sword25/kernel
parent411d41d3d0a3e4d14187d4a980c25c0a2e41ad9c (diff)
downloadscummvm-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
Diffstat (limited to 'engines/sword25/kernel')
-rw-r--r--engines/sword25/kernel/common.h9
-rw-r--r--engines/sword25/kernel/filesystemutil.cpp2
-rw-r--r--engines/sword25/kernel/inputpersistenceblock.cpp8
-rw-r--r--engines/sword25/kernel/kernel.cpp12
-rw-r--r--engines/sword25/kernel/log.cpp214
-rw-r--r--engines/sword25/kernel/log.h134
-rw-r--r--engines/sword25/kernel/outputpersistenceblock.cpp2
-rw-r--r--engines/sword25/kernel/persistenceservice.cpp20
-rw-r--r--engines/sword25/kernel/resmanager.cpp26
-rw-r--r--engines/sword25/kernel/resource.cpp4
10 files changed, 34 insertions, 397 deletions
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