aboutsummaryrefslogtreecommitdiff
path: root/engines/sword25/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sword25/kernel')
-rw-r--r--engines/sword25/kernel/callbackregistry.cpp20
-rw-r--r--engines/sword25/kernel/callbackregistry.h20
-rw-r--r--engines/sword25/kernel/filesystemutil.cpp56
-rw-r--r--engines/sword25/kernel/filesystemutil.h16
-rw-r--r--engines/sword25/kernel/inputpersistenceblock.cpp144
-rw-r--r--engines/sword25/kernel/inputpersistenceblock.h42
-rw-r--r--engines/sword25/kernel/kernel.cpp236
-rw-r--r--engines/sword25/kernel/kernel.h131
-rw-r--r--engines/sword25/kernel/kernel_script.cpp575
-rw-r--r--engines/sword25/kernel/log.cpp176
-rw-r--r--engines/sword25/kernel/log.h76
-rw-r--r--engines/sword25/kernel/outputpersistenceblock.cpp96
-rw-r--r--engines/sword25/kernel/outputpersistenceblock.h34
-rw-r--r--engines/sword25/kernel/persistenceblock.h62
-rw-r--r--engines/sword25/kernel/persistenceservice.cpp387
-rw-r--r--engines/sword25/kernel/persistenceservice.h30
-rw-r--r--engines/sword25/kernel/resmanager.cpp172
-rw-r--r--engines/sword25/kernel/resmanager.h62
-rw-r--r--engines/sword25/kernel/resource.cpp4
-rw-r--r--engines/sword25/kernel/resource.h16
-rw-r--r--engines/sword25/kernel/resservice.h5
-rw-r--r--engines/sword25/kernel/scummvmwindow.cpp64
-rw-r--r--engines/sword25/kernel/scummvmwindow.h50
-rw-r--r--engines/sword25/kernel/service_ids.h1
-rw-r--r--engines/sword25/kernel/string.h74
-rw-r--r--engines/sword25/kernel/window.cpp16
-rw-r--r--engines/sword25/kernel/window.h51
27 files changed, 1124 insertions, 1492 deletions
diff --git a/engines/sword25/kernel/callbackregistry.cpp b/engines/sword25/kernel/callbackregistry.cpp
index 32b2597334..673da0679c 100644
--- a/engines/sword25/kernel/callbackregistry.cpp
+++ b/engines/sword25/kernel/callbackregistry.cpp
@@ -44,22 +44,12 @@
// Pointer gespeichert war, stürtzt das Programm beim Äufrufen dieser Callbackfunktion ab. Durch das Auflösungverfahren wird beim Laden der
// Callbackbezeichner in den neuen Funktionspointer umgewandelt und der Aufruf kann erfolgen.
-// -----------------------------------------------------------------------------
-// Logging
-// -----------------------------------------------------------------------------
-
#define BS_LOG_PREFIX "CALLBACKREGISTRY"
-// -----------------------------------------------------------------------------
-// Includes
-// -----------------------------------------------------------------------------
-
#include "sword25/kernel/callbackregistry.h"
namespace Sword25 {
-// -----------------------------------------------------------------------------
-
bool CallbackRegistry::registerCallbackFunction(const Common::String &name, CallbackPtr ptr) {
if (name == "") {
BS_LOG_ERRORLN("The empty string is not allowed as a callback function name.");
@@ -80,8 +70,6 @@ bool CallbackRegistry::registerCallbackFunction(const Common::String &name, Call
return true;
}
-// -----------------------------------------------------------------------------
-
CallbackPtr CallbackRegistry::resolveCallbackFunction(const Common::String &name) const {
CallbackPtr result = findPtrByName(name);
@@ -92,8 +80,6 @@ CallbackPtr CallbackRegistry::resolveCallbackFunction(const Common::String &name
return result;
}
-// -----------------------------------------------------------------------------
-
Common::String CallbackRegistry::resolveCallbackPointer(CallbackPtr ptr) const {
const Common::String &result = findNameByPtr(ptr);
@@ -104,24 +90,18 @@ Common::String CallbackRegistry::resolveCallbackPointer(CallbackPtr ptr) const {
return result;
}
-// -----------------------------------------------------------------------------
-
CallbackPtr CallbackRegistry::findPtrByName(const Common::String &name) const {
// Eintrag in der Map finden und den Pointer zurückgeben.
NameToPtrMap::const_iterator it = _nameToPtrMap.find(name);
return it == _nameToPtrMap.end() ? 0 : it->_value;
}
-// -----------------------------------------------------------------------------
-
Common::String CallbackRegistry::findNameByPtr(CallbackPtr ptr) const {
// Eintrag in der Map finden und den Namen zurückgeben.
PtrToNameMap::const_iterator it = _ptrToNameMap.find(ptr);
return it == _ptrToNameMap.end() ? "" : it->_value;
}
-// -----------------------------------------------------------------------------
-
void CallbackRegistry::storeCallbackFunction(const Common::String &name, CallbackPtr ptr) {
// Callback-Funktion in beide Maps eintragen.
_nameToPtrMap[name] = ptr;
diff --git a/engines/sword25/kernel/callbackregistry.h b/engines/sword25/kernel/callbackregistry.h
index a309dcee6f..f73a1341f7 100644
--- a/engines/sword25/kernel/callbackregistry.h
+++ b/engines/sword25/kernel/callbackregistry.h
@@ -35,10 +35,6 @@
#ifndef SWORD25_CALLBACK_REGISTRY_H
#define SWORD25_CALLBACK_REGISTRY_H
-// -----------------------------------------------------------------------------
-// Includes
-// -----------------------------------------------------------------------------
-
#include "common/scummsys.h"
#include "common/str.h"
#include "common/hash-str.h"
@@ -47,10 +43,6 @@
namespace Sword25 {
-// -----------------------------------------------------------------------------
-// Klassendeklaration
-// -----------------------------------------------------------------------------
-
typedef void (*CallbackPtr)(int command);
class CallbackRegistry {
@@ -60,9 +52,9 @@ public:
return _instance;
}
- bool registerCallbackFunction(const Common::String &name, CallbackPtr ptr);
- CallbackPtr resolveCallbackFunction(const Common::String &name) const;
- Common::String resolveCallbackPointer(CallbackPtr ptr) const;
+ bool registerCallbackFunction(const Common::String &name, CallbackPtr ptr);
+ CallbackPtr resolveCallbackFunction(const Common::String &name) const;
+ Common::String resolveCallbackPointer(CallbackPtr ptr) const;
private:
typedef Common::HashMap<Common::String, CallbackPtr, Common::CaseSensitiveString_Hash, Common::CaseSensitiveString_EqualTo> NameToPtrMap;
@@ -82,9 +74,9 @@ private:
typedef Common::HashMap<CallbackPtr, Common::String, CallbackPtr_Hash, CallbackPtr_EqualTo> PtrToNameMap;
PtrToNameMap _ptrToNameMap;
- CallbackPtr findPtrByName(const Common::String &name) const;
- Common::String findNameByPtr(CallbackPtr ptr) const;
- void storeCallbackFunction(const Common::String &name, CallbackPtr ptr);
+ CallbackPtr findPtrByName(const Common::String &name) const;
+ Common::String findNameByPtr(CallbackPtr ptr) const;
+ void storeCallbackFunction(const Common::String &name, CallbackPtr ptr);
};
} // End of namespace Sword25
diff --git a/engines/sword25/kernel/filesystemutil.cpp b/engines/sword25/kernel/filesystemutil.cpp
index 764e275c0a..945ba0d2c2 100644
--- a/engines/sword25/kernel/filesystemutil.cpp
+++ b/engines/sword25/kernel/filesystemutil.cpp
@@ -32,10 +32,6 @@
*
*/
-// -----------------------------------------------------------------------------
-// Includes
-// -----------------------------------------------------------------------------
-
#include "common/config-manager.h"
#include "common/fs.h"
#include "common/savefile.h"
@@ -47,12 +43,8 @@ namespace Sword25 {
#define BS_LOG_PREFIX "FILESYSTEMUTIL"
-// -----------------------------------------------------------------------------
-// Constants and utility functions
-// -----------------------------------------------------------------------------
-
-Common::String GetAbsolutePath(const Common::String &Path) {
- Common::FSNode node(Path);
+Common::String getAbsolutePath(const Common::String &path) {
+ Common::FSNode node(path);
if (!node.exists()) {
// An error has occurred finding the node
@@ -65,13 +57,9 @@ Common::String GetAbsolutePath(const Common::String &Path) {
return node.getPath();
}
-// -----------------------------------------------------------------------------
-// Class definitions
-// -----------------------------------------------------------------------------
-
class BS_FileSystemUtilScummVM : public FileSystemUtil {
public:
- virtual Common::String GetUserdataDirectory() {
+ virtual Common::String getUserdataDirectory() {
Common::String path = ConfMan.get("savepath");
if (path.empty()) {
@@ -83,12 +71,12 @@ public:
return path;
}
- virtual Common::String GetPathSeparator() {
+ virtual Common::String getPathSeparator() {
return Common::String("/");
}
- virtual int32 GetFileSize(const Common::String &Filename) {
- Common::FSNode node(Filename);
+ virtual int32 getFileSize(const Common::String &filename) {
+ Common::FSNode node(filename);
// If the file does not exist, return -1 as a result
if (!node.exists())
@@ -103,7 +91,7 @@ public:
return size;
}
- virtual TimeDate GetFileTime(const Common::String &Filename) {
+ virtual TimeDate getFileTime(const Common::String &filename) {
// TODO: There isn't any way in ScummVM to get a file's modified date/time. We will need to check
// what code makes use of it. If it's only the save game code, for example, we may be able to
// encode the date/time inside the savegame files themselves.
@@ -112,41 +100,37 @@ public:
return result;
}
- virtual bool FileExists(const Common::String &Filename) {
+ virtual bool fileExists(const Common::String &filename) {
Common::File f;
- if (f.exists(Filename))
+ if (f.exists(filename))
return true;
// Check if the file exists in the save folder
- Common::FSNode folder(PersistenceService::GetSavegameDirectory());
- Common::FSNode fileNode = folder.getChild(FileSystemUtil::GetInstance().GetPathFilename(Filename));
+ Common::FSNode folder(PersistenceService::getSavegameDirectory());
+ Common::FSNode fileNode = folder.getChild(FileSystemUtil::getInstance().getPathFilename(filename));
return fileNode.exists();
}
- virtual bool CreateDirectory(const Common::String &DirectoryName) {
+ virtual bool createDirectory(const Common::String &sirectoryName) {
// ScummVM doesn't support creating folders, so this is only a stub
BS_LOG_ERRORLN("CreateDirectory method called");
return false;
}
- virtual Common::String GetPathFilename(const Common::String &Path) {
- for (int i = Path.size() - 1; i >= 0; --i) {
- if ((Path[i] == '/') || (Path[i] == '\\')) {
- return Common::String(&Path.c_str()[i + 1]);
+ virtual Common::String getPathFilename(const Common::String &path) {
+ for (int i = path.size() - 1; i >= 0; --i) {
+ if ((path[i] == '/') || (path[i] == '\\')) {
+ return Common::String(&path.c_str()[i + 1]);
}
}
- return Path;
+ return path;
}
};
-// -----------------------------------------------------------------------------
-// Singleton method of parent class
-// -----------------------------------------------------------------------------
-
-FileSystemUtil &FileSystemUtil::GetInstance() {
- static BS_FileSystemUtilScummVM Instance;
- return Instance;
+FileSystemUtil &FileSystemUtil::getInstance() {
+ static BS_FileSystemUtilScummVM instance;
+ return instance;
}
} // End of namespace Sword25
diff --git a/engines/sword25/kernel/filesystemutil.h b/engines/sword25/kernel/filesystemutil.h
index ef66585ff8..904b9d4e04 100644
--- a/engines/sword25/kernel/filesystemutil.h
+++ b/engines/sword25/kernel/filesystemutil.h
@@ -61,7 +61,7 @@ namespace Sword25 {
class FileSystemUtil {
public:
- static FileSystemUtil &GetInstance();
+ static FileSystemUtil &getInstance();
virtual ~FileSystemUtil() {}
/**
@@ -70,27 +70,27 @@ public:
* These are for example Screenshots, game saves, configuration files, log files, ...
* @return Returns the name of the directory for user data.
*/
- virtual Common::String GetUserdataDirectory() = 0;
+ virtual Common::String getUserdataDirectory() = 0;
/**
* @return Returns the path seperator
*/
- virtual Common::String GetPathSeparator() = 0;
+ virtual Common::String getPathSeparator() = 0;
/**
* @param Filename The path to a file.
* @return Returns the size of the specified file. If the size could not be
* determined, or the file does not exist, returns -1
*/
- virtual int32 GetFileSize(const Common::String &Filename) = 0;
+ virtual int32 getFileSize(const Common::String &filename) = 0;
/**
* @param Filename The path to a file.
* @return Returns the timestamp of the specified file.
*/
- virtual TimeDate GetFileTime(const Common::String &Filename) = 0;
+ virtual TimeDate getFileTime(const Common::String &filename) = 0;
/**
* @param Filename The path to a file.
* @return Returns true if the file exists.
*/
- virtual bool FileExists(const Common::String &Filename) = 0;
+ virtual bool fileExists(const Common::String &filename) = 0;
/**
* This function creates a directory
*
@@ -99,13 +99,13 @@ public:
* @param DirectoryName The name of the directory to be created
* @return Returns true if the folder(s) could be created, otherwise false.
*/
- virtual bool CreateDirectory(const Common::String &DirectoryName) = 0;
+ virtual bool createDirectory(const Common::String &directoryName) = 0;
/**
* Gets the filename from a path and filename
* @param Filename The full path and filename
* @return Returns just the filename
*/
- virtual Common::String GetPathFilename(const Common::String &Path) = 0;
+ virtual Common::String getPathFilename(const Common::String &path) = 0;
};
} // End of namespace Sword25
diff --git a/engines/sword25/kernel/inputpersistenceblock.cpp b/engines/sword25/kernel/inputpersistenceblock.cpp
index b51b1037a7..132e08918d 100644
--- a/engines/sword25/kernel/inputpersistenceblock.cpp
+++ b/engines/sword25/kernel/inputpersistenceblock.cpp
@@ -34,146 +34,116 @@
#define BS_LOG_PREFIX "INPUTPERSISTENCEBLOCK"
-// -----------------------------------------------------------------------------
-// Includes
-// -----------------------------------------------------------------------------
-
#include "sword25/kernel/inputpersistenceblock.h"
namespace Sword25 {
-// -----------------------------------------------------------------------------
-// Constructor / Destructor
-// -----------------------------------------------------------------------------
-
-InputPersistenceBlock::InputPersistenceBlock(const void *Data, uint DataLength) :
- m_Data(static_cast<const byte *>(Data), DataLength),
- m_ErrorState(NONE) {
- m_Iter = m_Data.begin();
+InputPersistenceBlock::InputPersistenceBlock(const void *data, uint dataLength) :
+ _data(static_cast<const byte *>(data), dataLength),
+ _errorState(NONE) {
+ _iter = _data.begin();
}
-// -----------------------------------------------------------------------------
-
InputPersistenceBlock::~InputPersistenceBlock() {
- if (m_Iter != m_Data.end()) BS_LOG_WARNINGLN("Persistence block was not read to the end.");
+ if (_iter != _data.end())
+ BS_LOG_WARNINGLN("Persistence block was not read to the end.");
}
-// -----------------------------------------------------------------------------
-// Reading
-// -----------------------------------------------------------------------------
-
-void InputPersistenceBlock::read(int16 &Value) {
+void InputPersistenceBlock::read(int16 &value) {
signed int v;
read(v);
- Value = static_cast<int16>(v);
+ value = static_cast<int16>(v);
}
-// -----------------------------------------------------------------------------
-
-void InputPersistenceBlock::read(signed int &Value) {
- if (CheckMarker(SINT_MARKER)) {
- RawRead(&Value, sizeof(signed int));
- Value = ConvertEndianessFromStorageToSystem(Value);
+void InputPersistenceBlock::read(signed int &value) {
+ if (checkMarker(SINT_MARKER)) {
+ rawRead(&value, sizeof(signed int));
+ value = convertEndianessFromStorageToSystem(value);
} else {
- Value = 0;
+ value = 0;
}
}
-// -----------------------------------------------------------------------------
-
-void InputPersistenceBlock::read(uint &Value) {
- if (CheckMarker(UINT_MARKER)) {
- RawRead(&Value, sizeof(uint));
- Value = ConvertEndianessFromStorageToSystem(Value);
+void InputPersistenceBlock::read(uint &value) {
+ if (checkMarker(UINT_MARKER)) {
+ rawRead(&value, sizeof(uint));
+ value = convertEndianessFromStorageToSystem(value);
} else {
- Value = 0;
+ value = 0;
}
}
-// -----------------------------------------------------------------------------
-
-void InputPersistenceBlock::read(float &Value) {
- if (CheckMarker(FLOAT_MARKER)) {
- RawRead(&Value, sizeof(float));
- Value = ConvertEndianessFromStorageToSystem(Value);
+void InputPersistenceBlock::read(float &value) {
+ if (checkMarker(FLOAT_MARKER)) {
+ rawRead(&value, sizeof(float));
+ value = convertEndianessFromStorageToSystem(value);
} else {
- Value = 0.0f;
+ value = 0.0f;
}
}
-// -----------------------------------------------------------------------------
-
-void InputPersistenceBlock::read(bool &Value) {
- if (CheckMarker(BOOL_MARKER)) {
- uint UIntBool;
- RawRead(&UIntBool, sizeof(float));
- UIntBool = ConvertEndianessFromStorageToSystem(UIntBool);
- Value = UIntBool == 0 ? false : true;
+void InputPersistenceBlock::read(bool &value) {
+ if (checkMarker(BOOL_MARKER)) {
+ uint uintBool;
+ rawRead(&uintBool, sizeof(float));
+ uintBool = convertEndianessFromStorageToSystem(uintBool);
+ value = uintBool == 0 ? false : true;
} else {
- Value = 0.0f;
+ value = 0.0f;
}
}
-// -----------------------------------------------------------------------------
-
-void InputPersistenceBlock::read(Common::String &Value) {
- Value = "";
+void InputPersistenceBlock::read(Common::String &value) {
+ value = "";
- if (CheckMarker(STRING_MARKER)) {
- uint Size;
- read(Size);
+ if (checkMarker(STRING_MARKER)) {
+ uint size;
+ read(size);
- if (CheckBlockSize(Size)) {
- Value = Common::String(reinterpret_cast<const char *>(&*m_Iter), Size);
- m_Iter += Size;
+ if (checkBlockSize(size)) {
+ value = Common::String(reinterpret_cast<const char *>(&*_iter), size);
+ _iter += size;
}
}
}
-// -----------------------------------------------------------------------------
+void InputPersistenceBlock::read(Common::Array<byte> &value) {
+ if (checkMarker(BLOCK_MARKER)) {
+ uint size;
+ read(size);
-void InputPersistenceBlock::read(Common::Array<byte> &Value) {
- if (CheckMarker(BLOCK_MARKER)) {
- uint Size;
- read(Size);
-
- if (CheckBlockSize(Size)) {
- Value = Common::Array<byte>(m_Iter, Size);
- m_Iter += Size;
+ if (checkBlockSize(size)) {
+ value = Common::Array<byte>(_iter, size);
+ _iter += size;
}
}
}
-// -----------------------------------------------------------------------------
-
-void InputPersistenceBlock::RawRead(void *DestPtr, size_t Size) {
- if (CheckBlockSize(Size)) {
- memcpy(DestPtr, &*m_Iter, Size);
- m_Iter += Size;
+void InputPersistenceBlock::rawRead(void *destPtr, size_t size) {
+ if (checkBlockSize(size)) {
+ memcpy(destPtr, &*_iter, size);
+ _iter += size;
}
}
-// -----------------------------------------------------------------------------
-
-bool InputPersistenceBlock::CheckBlockSize(int Size) {
- if (m_Data.end() - m_Iter >= Size) {
+bool InputPersistenceBlock::checkBlockSize(int size) {
+ if (_data.end() - _iter >= size) {
return true;
} else {
- m_ErrorState = END_OF_DATA;
+ _errorState = END_OF_DATA;
BS_LOG_ERRORLN("Unexpected end of persistence block.");
return false;
}
}
-// -----------------------------------------------------------------------------
-
-bool InputPersistenceBlock::CheckMarker(byte Marker) {
- if (!isGood() || !CheckBlockSize(1)) return false;
+bool InputPersistenceBlock::checkMarker(byte marker) {
+ if (!isGood() || !checkBlockSize(1))
+ return false;
- if (*m_Iter++ == Marker) {
+ if (*_iter++ == marker) {
return true;
} else {
- m_ErrorState = OUT_OF_SYNC;
+ _errorState = OUT_OF_SYNC;
BS_LOG_ERRORLN("Wrong type marker found in persistence block.");
return false;
}
diff --git a/engines/sword25/kernel/inputpersistenceblock.h b/engines/sword25/kernel/inputpersistenceblock.h
index a6978e5899..a941d3cb5c 100644
--- a/engines/sword25/kernel/inputpersistenceblock.h
+++ b/engines/sword25/kernel/inputpersistenceblock.h
@@ -35,20 +35,12 @@
#ifndef SWORD25_INPUTPERSISTENCEBLOCK_H
#define SWORD25_INPUTPERSISTENCEBLOCK_H
-// -----------------------------------------------------------------------------
-// Includes
-// -----------------------------------------------------------------------------
-
#include "common/array.h"
#include "sword25/kernel/common.h"
#include "sword25/kernel/persistenceblock.h"
namespace Sword25 {
-// -----------------------------------------------------------------------------
-// Class declaration
-// -----------------------------------------------------------------------------
-
class InputPersistenceBlock : public PersistenceBlock {
public:
enum ErrorState {
@@ -57,32 +49,32 @@ public:
OUT_OF_SYNC
};
- InputPersistenceBlock(const void *Data, uint DataLength);
+ InputPersistenceBlock(const void *data, uint dataLength);
virtual ~InputPersistenceBlock();
- void read(int16 &Value);
- void read(signed int &Value);
- void read(uint &Value);
- void read(float &Value);
- void read(bool &Value);
- void read(Common::String &Value);
- void read(Common::Array<byte> &Value);
+ void read(int16 &value);
+ void read(signed int &value);
+ void read(uint &value);
+ void read(float &value);
+ void read(bool &value);
+ void read(Common::String &value);
+ void read(Common::Array<byte> &value);
bool isGood() const {
- return m_ErrorState == NONE;
+ return _errorState == NONE;
}
- ErrorState GetErrorState() const {
- return m_ErrorState;
+ ErrorState getErrorState() const {
+ return _errorState;
}
private:
- bool CheckMarker(byte Marker);
- bool CheckBlockSize(int Size);
- void RawRead(void *DestPtr, size_t Size);
+ bool checkMarker(byte marker);
+ bool checkBlockSize(int size);
+ void rawRead(void *destPtr, size_t size);
- Common::Array<byte> m_Data;
- Common::Array<byte>::const_iterator m_Iter;
- ErrorState m_ErrorState;
+ Common::Array<byte> _data;
+ Common::Array<byte>::const_iterator _iter;
+ ErrorState _errorState;
};
} // End of namespace Sword25
diff --git a/engines/sword25/kernel/kernel.cpp b/engines/sword25/kernel/kernel.cpp
index 3c3505a6b2..ed7eee1667 100644
--- a/engines/sword25/kernel/kernel.cpp
+++ b/engines/sword25/kernel/kernel.cpp
@@ -47,14 +47,13 @@ namespace Sword25 {
#define BS_LOG_PREFIX "KERNEL"
-
-Kernel *Kernel::_Instance = 0;
+Kernel *Kernel::_instance = 0;
Kernel::Kernel() :
_pWindow(NULL),
- _Running(false),
+ _running(false),
_pResourceManager(NULL),
- _InitSuccess(false) {
+ _initSuccess(false) {
// Log that the kernel is beign created
BS_LOGLN("created.");
@@ -63,10 +62,10 @@ Kernel::Kernel() :
for (uint i = 0; i < ARRAYSIZE(BS_SERVICE_TABLE); i++) {
// Is the superclass already registered?
Superclass *pCurSuperclass = NULL;
- Common::Array<Superclass *>::iterator Iter;
- for (Iter = _superclasses.begin(); Iter != _superclasses.end(); ++Iter)
- if ((*Iter)->GetIdentifier() == BS_SERVICE_TABLE[i].superclassId) {
- pCurSuperclass = *Iter;
+ Common::Array<Superclass *>::iterator iter;
+ for (iter = _superclasses.begin(); iter != _superclasses.end(); ++iter)
+ if ((*iter)->getIdentifier() == BS_SERVICE_TABLE[i].superclassId) {
+ pCurSuperclass = *iter;
break;
}
@@ -76,7 +75,7 @@ Kernel::Kernel() :
}
// Create window object
- _pWindow = Window::CreateBSWindow(0, 0, 0, 0, false);
+ _pWindow = Window::createBSWindow(0, 0, 0, 0, false);
if (!_pWindow) {
BS_LOG_ERRORLN("Failed to create the window.");
} else
@@ -86,29 +85,30 @@ Kernel::Kernel() :
_pResourceManager = new ResourceManager(this);
// Initialise the script engine
- ScriptEngine *pScript = static_cast<ScriptEngine *>(NewService("script", "lua"));
+ ScriptEngine *pScript = static_cast<ScriptEngine *>(newService("script", "lua"));
if (!pScript || !pScript->init()) {
- _InitSuccess = false;
+ _initSuccess = false;
return;
}
// Register kernel script bindings
- if (!_RegisterScriptBindings()) {
+ if (!registerScriptBindings()) {
BS_LOG_ERRORLN("Script bindings could not be registered.");
- _InitSuccess = false;
+ _initSuccess = false;
return;
}
BS_LOGLN("Script bindings registered.");
- _InitSuccess = true;
+ _initSuccess = true;
}
Kernel::~Kernel() {
// Services are de-registered in reverse order of creation
- while (!_ServiceCreationOrder.empty()) {
- Superclass *superclass = GetSuperclassByIdentifier(_ServiceCreationOrder.top());
- if (superclass) superclass->DisconnectService();
- _ServiceCreationOrder.pop();
+ while (!_serviceCreationOrder.empty()) {
+ Superclass *superclass = getSuperclassByIdentifier(_serviceCreationOrder.top());
+ if (superclass)
+ superclass->disconnectService();
+ _serviceCreationOrder.pop();
}
// Empty the Superclass list
@@ -127,21 +127,18 @@ Kernel::~Kernel() {
BS_LOGLN("destroyed.");
}
-// Service Methoden
-// ----------------
-
-Kernel::Superclass::Superclass(Kernel *pKernel, const Common::String &Identifier) :
+Kernel::Superclass::Superclass(Kernel *pKernel, const Common::String &identifier) :
_pKernel(pKernel),
- _Identifier(Identifier),
- _ServiceCount(0),
- _ActiveService(NULL) {
+ _identifier(identifier),
+ _serviceCount(0),
+ _activeService(NULL) {
for (uint i = 0; i < ARRAYSIZE(BS_SERVICE_TABLE); i++)
- if (BS_SERVICE_TABLE[i].superclassId == _Identifier)
- _ServiceCount++;
+ if (BS_SERVICE_TABLE[i].superclassId == _identifier)
+ _serviceCount++;
}
Kernel::Superclass::~Superclass() {
- DisconnectService();
+ disconnectService();
}
/**
@@ -153,16 +150,17 @@ Kernel::Superclass::~Superclass() {
* Hierbei ist zu beachten, dass der erste Service die Nummer 0 erhält. Number muss also eine Zahl zwischen
* 0 und GetServiceCount() - 1 sein.
*/
-Common::String Kernel::Superclass::GetServiceIdentifier(uint Number) {
- if (Number > _ServiceCount) return NULL;
+Common::String Kernel::Superclass::getServiceIdentifier(uint number) {
+ if (number > _serviceCount)
+ return NULL;
- uint CurServiceOrd = 0;
+ uint curServiceOrd = 0;
for (uint i = 0; i < ARRAYSIZE(BS_SERVICE_TABLE); i++) {
- if (BS_SERVICE_TABLE[i].superclassId == _Identifier) {
- if (Number == CurServiceOrd)
+ if (BS_SERVICE_TABLE[i].superclassId == _identifier) {
+ if (number == curServiceOrd)
return BS_SERVICE_TABLE[i].serviceId;
else
- CurServiceOrd++;
+ curServiceOrd++;
}
}
@@ -178,25 +176,25 @@ Common::String Kernel::Superclass::GetServiceIdentifier(uint Number) {
* @param serviceId The name of the service
* For the superclass "sfx" an example could be "Fmod" or "directsound"
*/
-Service *Kernel::Superclass::NewService(const Common::String &serviceId) {
+Service *Kernel::Superclass::newService(const Common::String &serviceId) {
for (uint i = 0; i < ARRAYSIZE(BS_SERVICE_TABLE); i++)
- if (BS_SERVICE_TABLE[i].superclassId == _Identifier &&
+ if (BS_SERVICE_TABLE[i].superclassId == _identifier &&
BS_SERVICE_TABLE[i].serviceId == serviceId) {
- Service *newService = BS_SERVICE_TABLE[i].create(_pKernel);
-
- if (newService) {
- DisconnectService();
- BS_LOGLN("Service '%s' created from superclass '%s'.", serviceId.c_str(), _Identifier.c_str());
- _ActiveService = newService;
- _ActiveServiceName = BS_SERVICE_TABLE[i].serviceId;
- return _ActiveService;
+ Service *newService_ = BS_SERVICE_TABLE[i].create(_pKernel);
+
+ if (newService_) {
+ disconnectService();
+ BS_LOGLN("Service '%s' created from superclass '%s'.", serviceId.c_str(), _identifier.c_str());
+ _activeService = newService_;
+ _activeServiceName = BS_SERVICE_TABLE[i].serviceId;
+ return _activeService;
} else {
- BS_LOG_ERRORLN("Failed to create service '%s' from superclass '%s'.", serviceId.c_str(), _Identifier.c_str());
+ BS_LOG_ERRORLN("Failed to create service '%s' from superclass '%s'.", serviceId.c_str(), _identifier.c_str());
return NULL;
}
}
- BS_LOG_ERRORLN("Service '%s' is not avaliable from superclass '%s'.", serviceId.c_str(), _Identifier.c_str());
+ BS_LOG_ERRORLN("Service '%s' is not avaliable from superclass '%s'.", serviceId.c_str(), _identifier.c_str());
return NULL;
}
@@ -206,32 +204,32 @@ Service *Kernel::Superclass::NewService(const Common::String &serviceId) {
* @param superclassId The name of the superclass which is to be disconnected
* e.g.: "sfx", "gfx", "package" ...
*/
-bool Kernel::Superclass::DisconnectService() {
- if (_ActiveService) {
- delete _ActiveService;
- _ActiveService = 0;
- BS_LOGLN("Active service '%s' disconnected from superclass '%s'.", _ActiveServiceName.c_str(), _Identifier.c_str());
+bool Kernel::Superclass::disconnectService() {
+ if (_activeService) {
+ delete _activeService;
+ _activeService = 0;
+ BS_LOGLN("Active service '%s' disconnected from superclass '%s'.", _activeServiceName.c_str(), _identifier.c_str());
return true;
}
return false;
}
-Kernel::Superclass *Kernel::GetSuperclassByIdentifier(const Common::String &Identifier) const {
- Common::Array<Superclass *>::const_iterator Iter;
- for (Iter = _superclasses.begin(); Iter != _superclasses.end(); ++Iter) {
- if ((*Iter)->GetIdentifier() == Identifier)
- return *Iter;
+Kernel::Superclass *Kernel::getSuperclassByIdentifier(const Common::String &identifier) const {
+ Common::Array<Superclass *>::const_iterator iter;
+ for (iter = _superclasses.begin(); iter != _superclasses.end(); ++iter) {
+ if ((*iter)->getIdentifier() == identifier)
+ return *iter;
}
- // BS_LOG_ERRORLN("Superclass '%s' does not exist.", Identifier.c_str());
+ // BS_LOG_ERRORLN("Superclass '%s' does not exist.", identifier.c_str());
return NULL;
}
/**
* Returns the number of register superclasses
*/
-uint Kernel::GetSuperclassCount() const {
+uint Kernel::getSuperclassCount() const {
return _superclasses.size();
}
@@ -241,17 +239,17 @@ uint Kernel::GetSuperclassCount() const {
* @param Number The number of the superclass to return the identifier for.
* It should be noted that the number should be between 0 und GetSuperclassCount() - 1.
*/
-Common::String Kernel::GetSuperclassIdentifier(uint Number) const {
- if (Number > _superclasses.size())
+Common::String Kernel::getSuperclassIdentifier(uint number) const {
+ if (number > _superclasses.size())
return NULL;
- uint CurSuperclassOrd = 0;
- Common::Array<Superclass *>::const_iterator Iter;
- for (Iter = _superclasses.begin(); Iter != _superclasses.end(); ++Iter) {
- if (CurSuperclassOrd == Number)
- return ((*Iter)->GetIdentifier());
+ uint curSuperclassOrd = 0;
+ Common::Array<Superclass *>::const_iterator iter;
+ for (iter = _superclasses.begin(); iter != _superclasses.end(); ++iter) {
+ if (curSuperclassOrd == number)
+ return ((*iter)->getIdentifier());
- CurSuperclassOrd++;
+ curSuperclassOrd++;
}
return Common::String();
@@ -262,12 +260,12 @@ Common::String Kernel::GetSuperclassIdentifier(uint Number) const {
* @param superclassId The name of the superclass
* e.g.: "sfx", "gfx", "package" ...
*/
-uint Kernel::GetServiceCount(const Common::String &superclassId) const {
- Superclass *pSuperclass = GetSuperclassByIdentifier(superclassId);
+uint Kernel::getServiceCount(const Common::String &superclassId) const {
+ Superclass *pSuperclass = getSuperclassByIdentifier(superclassId);
if (!pSuperclass)
return 0;
- return pSuperclass->GetServiceCount();
+ return pSuperclass->getServiceCount();
}
@@ -280,12 +278,12 @@ uint Kernel::GetServiceCount(const Common::String &superclassId) const {
* Hierbei ist zu beachten, dass der erste Service die Nummer 0 erhält. Number muss also eine Zahl zwischen
* 0 und GetServiceCount() - 1 sein.
*/
-Common::String Kernel::GetServiceIdentifier(const Common::String &superclassId, uint Number) const {
- Superclass *pSuperclass = GetSuperclassByIdentifier(superclassId);
+Common::String Kernel::getServiceIdentifier(const Common::String &superclassId, uint number) const {
+ Superclass *pSuperclass = getSuperclassByIdentifier(superclassId);
if (!pSuperclass)
return NULL;
- return (pSuperclass->GetServiceIdentifier(Number));
+ return (pSuperclass->getServiceIdentifier(number));
}
/**
@@ -297,15 +295,15 @@ Common::String Kernel::GetServiceIdentifier(const Common::String &superclassId,
* @param serviceId The name of the service
* For the superclass "sfx" an example could be "Fmod" or "directsound"
*/
-Service *Kernel::NewService(const Common::String &superclassId, const Common::String &serviceId) {
- Superclass *pSuperclass = GetSuperclassByIdentifier(superclassId);
+Service *Kernel::newService(const Common::String &superclassId, const Common::String &serviceId) {
+ Superclass *pSuperclass = getSuperclassByIdentifier(superclassId);
if (!pSuperclass)
return NULL;
// Die Reihenfolge merken, in der Services erstellt werden, damit sie später in umgekehrter Reihenfolge entladen werden können.
- _ServiceCreationOrder.push(superclassId);
+ _serviceCreationOrder.push(superclassId);
- return pSuperclass->NewService(serviceId);
+ return pSuperclass->newService(serviceId);
}
/**
@@ -314,12 +312,12 @@ Service *Kernel::NewService(const Common::String &superclassId, const Common::St
* e.g.: "sfx", "gfx", "package" ...
* @return true on success, and false if the superclass does not exist or if not service was active.
*/
-bool Kernel::DisconnectService(const Common::String &superclassId) {
- Superclass *pSuperclass = GetSuperclassByIdentifier(superclassId);
+bool Kernel::disconnectService(const Common::String &superclassId) {
+ Superclass *pSuperclass = getSuperclassByIdentifier(superclassId);
if (!pSuperclass)
return false;
- return pSuperclass->DisconnectService();
+ return pSuperclass->disconnectService();
}
/**
@@ -327,12 +325,12 @@ bool Kernel::DisconnectService(const Common::String &superclassId) {
* @param superclassId The name of the superclass
* e.g.: "sfx", "gfx", "package" ...
*/
-Service *Kernel::GetService(const Common::String &superclassId) {
- Superclass *pSuperclass = GetSuperclassByIdentifier(superclassId);
+Service *Kernel::getService(const Common::String &superclassId) {
+ Superclass *pSuperclass = getSuperclassByIdentifier(superclassId);
if (!pSuperclass)
return NULL;
- return (pSuperclass->GetActiveService());
+ return (pSuperclass->getActiveService());
}
/**
@@ -341,113 +339,83 @@ Service *Kernel::GetService(const Common::String &superclassId) {
* @param superclassId The name of the superclass
* e.g.: "sfx", "gfx", "package" ...
*/
-Common::String Kernel::GetActiveServiceIdentifier(const Common::String &superclassId) {
- Superclass *pSuperclass = GetSuperclassByIdentifier(superclassId);
+Common::String Kernel::getActiveServiceIdentifier(const Common::String &superclassId) {
+ Superclass *pSuperclass = getSuperclassByIdentifier(superclassId);
if (!pSuperclass)
return Common::String();
- return pSuperclass->GetActiveServiceName();
+ return pSuperclass->getActiveServiceName();
}
-// -----------------------------------------------------------------------------
-
/**
* Returns a random number
* @param Min The minimum allowed value
* @param Max The maximum allowed value
*/
-int Kernel::GetRandomNumber(int Min, int Max) {
- BS_ASSERT(Min <= Max);
+int Kernel::getRandomNumber(int min, int max) {
+ BS_ASSERT(min <= max);
- return Min + _rnd.getRandomNumber(Max - Min + 1);
+ return min + _rnd.getRandomNumber(max - min + 1);
}
/**
* Returns the elapsed time since startup in milliseconds
*/
-uint Kernel::GetMilliTicks() {
+uint Kernel::getMilliTicks() {
return g_system->getMillis();
}
-// Other methods
-// -----------------
-
/**
* Returns how much memory is being used
*/
-size_t Kernel::GetUsedMemory() {
+size_t Kernel::getUsedMemory() {
return 0;
-
-#ifdef SCUMMVM_DISABLED_CODE
- PROCESS_MEMORY_COUNTERS pmc;
- pmc.cb = sizeof(pmc);
- if (GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc))) {
- return pmc.WorkingSetSize;
- } else {
- BS_LOG_ERRORLN("Call to GetProcessMemoryInfo() failed. Error code: %d", GetLastError());
- return 0;
- }
-#endif
}
-// -----------------------------------------------------------------------------
-
/**
* Returns a pointer to the active Gfx Service, or NULL if no Gfx service is active.
*/
-GraphicEngine *Kernel::GetGfx() {
- return static_cast<GraphicEngine *>(GetService("gfx"));
+GraphicEngine *Kernel::getGfx() {
+ return static_cast<GraphicEngine *>(getService("gfx"));
}
-// -----------------------------------------------------------------------------
-
/**
* Returns a pointer to the active Sfx Service, or NULL if no Sfx service is active.
*/
-SoundEngine *Kernel::GetSfx() {
- return static_cast<SoundEngine *>(GetService("sfx"));
+SoundEngine *Kernel::getSfx() {
+ return static_cast<SoundEngine *>(getService("sfx"));
}
-// -----------------------------------------------------------------------------
-
/**
* Returns a pointer to the active input service, or NULL if no input service is active.
*/
-InputEngine *Kernel::GetInput() {
- return static_cast<InputEngine *>(GetService("input"));
+InputEngine *Kernel::getInput() {
+ return static_cast<InputEngine *>(getService("input"));
}
-// -----------------------------------------------------------------------------
-
/**
* Returns a pointer to the active package manager, or NULL if no manager is active.
*/
-PackageManager *Kernel::GetPackage() {
- return static_cast<PackageManager *>(GetService("package"));
+PackageManager *Kernel::getPackage() {
+ return static_cast<PackageManager *>(getService("package"));
}
-// -----------------------------------------------------------------------------
-
/**
* Returns a pointer to the script engine, or NULL if it is not active.
*/
-ScriptEngine *Kernel::GetScript() {
- return static_cast<ScriptEngine *>(GetService("script"));
+ScriptEngine *Kernel::getScript() {
+ return static_cast<ScriptEngine *>(getService("script"));
}
-// -----------------------------------------------------------------------------
-
/**
* Returns a pointer to the movie player, or NULL if it is not active.
*/
-MoviePlayer *Kernel::GetFMV() {
- return static_cast<MoviePlayer *>(GetService("fmv"));
+MoviePlayer *Kernel::getFMV() {
+ return static_cast<MoviePlayer *>(getService("fmv"));
}
-// -----------------------------------------------------------------------------
-
-void Kernel::Sleep(uint Msecs) const {
- g_system->delayMillis(Msecs);
+void Kernel::sleep(uint msecs) const {
+ g_system->delayMillis(msecs);
}
} // End of namespace Sword25
diff --git a/engines/sword25/kernel/kernel.h b/engines/sword25/kernel/kernel.h
index 9876830053..22eb3a82b8 100644
--- a/engines/sword25/kernel/kernel.h
+++ b/engines/sword25/kernel/kernel.h
@@ -45,7 +45,6 @@
#ifndef SWORD25_KERNEL_H
#define SWORD25_KERNEL_H
-// Includes
#include "common/scummsys.h"
#include "common/random.h"
#include "common/stack.h"
@@ -81,7 +80,7 @@ public:
/**
* Returns a pointer to the window object
*/
- Window *GetWindow() {
+ Window *getWindow() {
return _pWindow;
}
@@ -97,7 +96,7 @@ public:
* @param ServiceIdentifier The name of the service
* For the superclass "sfx" an example could be "Fmod" or "directsound"
*/
- Service *NewService(const Common::String &SuperclassIdentifier, const Common::String &ServiceIdentifier);
+ Service *newService(const Common::String &superclassIdentifier, const Common::String &serviceIdentifier);
/**
* Ends the current service of a superclass. Returns true on success, and false if the superclass
@@ -105,14 +104,14 @@ public:
* @param SuperclassIdentfier The name of the superclass which is to be disconnected
* z.B: "sfx", "gfx", "package" ...
*/
- bool DisconnectService(const Common::String &SuperclassIdentifier);
+ bool disconnectService(const Common::String &superclassIdentifier);
/**
* Returns a pointer to the currently active service object of a superclass
* @param SuperclassIdentfier The name of the superclass
* z.B: "sfx", "gfx", "package" ...
*/
- Service *GetService(const Common::String &SuperclassIdentifier);
+ Service *getService(const Common::String &superclassIdentifier);
/**
* Returns the name of the currentl active service object of a superclass.
@@ -120,12 +119,12 @@ public:
* @param SuperclassIdentfier The name of the superclass
* z.B: "sfx", "gfx", "package" ...
*/
- Common::String GetActiveServiceIdentifier(const Common::String &SuperclassIdentifier);
+ Common::String getActiveServiceIdentifier(const Common::String &superclassIdentifier);
/**
* Returns the number of register superclasses
*/
- uint GetSuperclassCount() const;
+ uint getSuperclassCount() const;
/**
* Returns the name of a superclass with the specified index.
@@ -133,14 +132,14 @@ public:
* @param Number The number of the superclass to return the identifier for.
* It should be noted that the number should be between 0 und GetSuperclassCount() - 1.
*/
- Common::String GetSuperclassIdentifier(uint Number) const;
+ Common::String getSuperclassIdentifier(uint number) const;
/**
* Returns the number of services registered with a given superclass
* @param SuperclassIdentifier The name of the superclass
* z.B: "sfx", "gfx", "package" ...
*/
- uint GetServiceCount(const Common::String &SuperclassIdentifier) const;
+ uint getServiceCount(const Common::String &superclassIdentifier) const;
/**
* Gets the identifier of a service with a given superclass.
@@ -151,73 +150,74 @@ public:
* Hierbei ist zu beachten, dass der erste Service die Nummer 0 erhält. Number muss also eine Zahl zwischen
* 0 und GetServiceCount() - 1 sein.
*/
- Common::String GetServiceIdentifier(const Common::String &SuperclassIdentifier, uint Number) const;
+ Common::String getServiceIdentifier(const Common::String &superclassIdentifier, uint number) const;
/**
* Returns the elapsed time since startup in milliseconds
*/
- uint GetMilliTicks();
+ uint getMilliTicks();
/**
* Specifies whether the kernel was successfully initialised
*/
- bool GetInitSuccess() const {
- return _InitSuccess;
+ bool getInitSuccess() const {
+ return _initSuccess;
}
/**
* Returns a pointer to the BS_ResourceManager
*/
- ResourceManager *GetResourceManager() {
+ ResourceManager *getResourceManager() {
return _pResourceManager;
}
/**
* Returns how much memory is being used
*/
- size_t GetUsedMemory();
+ size_t getUsedMemory();
/**
* Returns a random number
* @param Min The minimum allowed value
* @param Max The maximum allowed value
*/
- int GetRandomNumber(int Min, int Max);
+ int getRandomNumber(int min, int max);
/**
* Returns a pointer to the active Gfx Service, or NULL if no Gfx service is active
*/
- GraphicEngine *GetGfx();
+ GraphicEngine *getGfx();
/**
* Returns a pointer to the active Sfx Service, or NULL if no Sfx service is active
*/
- SoundEngine *GetSfx();
+ SoundEngine *getSfx();
/**
* Returns a pointer to the active input service, or NULL if no input service is active
*/
- InputEngine *GetInput();
+ InputEngine *getInput();
/**
* Returns a pointer to the active package manager, or NULL if no manager is active
*/
- PackageManager *GetPackage();
+ PackageManager *getPackage();
/**
* Returns a pointer to the script engine, or NULL if it is not active
*/
- ScriptEngine *GetScript();
+ ScriptEngine *getScript();
/**
* Returns a pointer to the movie player, or NULL if it is not active
*/
- MoviePlayer *GetFMV();
+ MoviePlayer *getFMV();
/**
* Pauses for the specified amount of time
* @param Msecs The amount of time in milliseconds
*/
- void Sleep(uint Msecs) const;
+ void sleep(uint msecs) const;
/**
* Returns the singleton instance for the kernel
*/
- static Kernel *GetInstance() {
- if (!_Instance) _Instance = new Kernel();
- return _Instance;
+ static Kernel *getInstance() {
+ if (!_instance)
+ _instance = new Kernel();
+ return _instance;
}
/**
@@ -225,18 +225,18 @@ public:
* This method should only be called when the game is ended. No subsequent calls to any kernel
* methods should be done after calling this method.
*/
- static void DeleteInstance() {
- if (_Instance) {
- delete _Instance;
- _Instance = NULL;
+ static void deleteInstance() {
+ if (_instance) {
+ delete _instance;
+ _instance = NULL;
}
}
/**
* Raises an error. This method is used in crashing testing.
*/
- void Crash() const {
- error("BS_Kernel::Crash");
+ void crash() const {
+ error("Kernel::Crash");
}
private:
@@ -251,45 +251,45 @@ private:
// -----------------------------------------------------------------------------
// Singleton instance
// -----------------------------------------------------------------------------
- static Kernel *_Instance;
+ static Kernel *_instance;
// Superclass class
// ----------------
class Superclass {
private:
Kernel *_pKernel;
- uint _ServiceCount;
- Common::String _Identifier;
- Service *_ActiveService;
- Common::String _ActiveServiceName;
+ uint _serviceCount;
+ Common::String _identifier;
+ Service *_activeService;
+ Common::String _activeServiceName;
public:
- Superclass(Kernel *pKernel, const Common::String &Identifier);
+ Superclass(Kernel *pKernel, const Common::String &identifier);
~Superclass();
- uint GetServiceCount() const {
- return _ServiceCount;
+ uint getServiceCount() const {
+ return _serviceCount;
}
- Common::String GetIdentifier() const {
- return _Identifier;
+ Common::String getIdentifier() const {
+ return _identifier;
}
- Service *GetActiveService() const {
- return _ActiveService;
+ Service *getActiveService() const {
+ return _activeService;
}
- Common::String GetActiveServiceName() const {
- return _ActiveServiceName;
+ Common::String getActiveServiceName() const {
+ return _activeServiceName;
}
- Common::String GetServiceIdentifier(uint Number);
- Service *NewService(const Common::String &ServiceIdentifier);
- bool DisconnectService();
+ Common::String getServiceIdentifier(uint number);
+ Service *newService(const Common::String &serviceIdentifier);
+ bool disconnectService();
};
Common::Array<Superclass *> _superclasses;
- Common::Stack<Common::String> _ServiceCreationOrder;
- Superclass *GetSuperclassByIdentifier(const Common::String &Identifier) const;
+ Common::Stack<Common::String> _serviceCreationOrder;
+ Superclass *getSuperclassByIdentifier(const Common::String &identifier) const;
- bool _InitSuccess; // Specifies whether the engine was set up correctly
- bool _Running; // Specifies whether the application should keep running on the next main loop iteration
+ bool _initSuccess; // Specifies whether the engine was set up correctly
+ bool _running; // Specifies whether the application should keep running on the next main loop iteration
// Active window
// -------------
@@ -299,34 +299,11 @@ private:
// -----------------------
Common::RandomSource _rnd;
- /*
- // Features variables and methods
- // ----------------------------------
- enum _CPU_FEATURES_BITMASKS
- {
- _MMX_BITMASK = (1 << 23),
- _SSE_BITMASK = (1 << 25),
- _SSE2_BITMASK = (1 << 26),
- _3DNOW_BITMASK = (1 << 30),
- _3DNOWEXT_BITMASK = (1 << 31)
- };
-
- bool _DetectCPU();
-
- bool _MMXPresent;
- bool _SSEPresent;
- bool _SSE2Present;
- bool _3DNowPresent;
- bool _3DNowExtPresent;
- CPU_TYPES _CPUType;
- Common::String _CPUVendorID;
- */
-
// Resourcemanager
// ---------------
ResourceManager *_pResourceManager;
- bool _RegisterScriptBindings();
+ bool registerScriptBindings();
};
} // End of namespace Sword25
diff --git a/engines/sword25/kernel/kernel_script.cpp b/engines/sword25/kernel/kernel_script.cpp
index a7169e9d30..9668768396 100644
--- a/engines/sword25/kernel/kernel_script.cpp
+++ b/engines/sword25/kernel/kernel_script.cpp
@@ -32,10 +32,6 @@
*
*/
-// -----------------------------------------------------------------------------
-// Includes
-// -----------------------------------------------------------------------------
-
#include "sword25/kernel/common.h"
#include "sword25/kernel/kernel.h"
#include "sword25/kernel/filesystemutil.h"
@@ -47,131 +43,107 @@
namespace Sword25 {
-// -----------------------------------------------------------------------------
-
-static int DisconnectService(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int disconnectService(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- lua_pushboolean(L, pKernel->DisconnectService(luaL_checkstring(L, 1)));
+ lua_pushboolean(L, pKernel->disconnectService(luaL_checkstring(L, 1)));
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int GetActiveServiceIdentifier(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int getActiveServiceIdentifier(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- lua_pushstring(L, pKernel->GetActiveServiceIdentifier(luaL_checkstring(L, 1)).c_str());
+ lua_pushstring(L, pKernel->getActiveServiceIdentifier(luaL_checkstring(L, 1)).c_str());
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int GetSuperclassCount(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int getSuperclassCount(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- lua_pushnumber(L, pKernel->GetSuperclassCount());
+ lua_pushnumber(L, pKernel->getSuperclassCount());
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int GetSuperclassIdentifier(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int getSuperclassIdentifier(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- lua_pushstring(L, pKernel->GetSuperclassIdentifier(
+ lua_pushstring(L, pKernel->getSuperclassIdentifier(
static_cast<uint>(luaL_checknumber(L, 1))).c_str());
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int GetServiceCount(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int getServiceCount(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- lua_pushnumber(L, pKernel->GetServiceCount(luaL_checkstring(L, 1)));
+ lua_pushnumber(L, pKernel->getServiceCount(luaL_checkstring(L, 1)));
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int GetServiceIdentifier(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int getServiceIdentifier(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- lua_pushstring(L, pKernel->GetServiceIdentifier(luaL_checkstring(L, 1),
+ lua_pushstring(L, pKernel->getServiceIdentifier(luaL_checkstring(L, 1),
static_cast<uint>(luaL_checknumber(L, 2))).c_str());
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int GetMilliTicks(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int getMilliTicks(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- lua_pushnumber(L, pKernel->GetMilliTicks());
+ lua_pushnumber(L, pKernel->getMilliTicks());
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int GetTimer(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int getTimer(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- lua_pushnumber(L, static_cast<lua_Number>(pKernel->GetMilliTicks()) / 1000.0);
+ lua_pushnumber(L, static_cast<lua_Number>(pKernel->getMilliTicks()) / 1000.0);
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int StartService(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int startService(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- lua_pushbooleancpp(L, pKernel->NewService(luaL_checkstring(L, 1), luaL_checkstring(L, 2)) != NULL);
+ lua_pushbooleancpp(L, pKernel->newService(luaL_checkstring(L, 1), luaL_checkstring(L, 2)) != NULL);
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int Sleep(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int sleep(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- pKernel->Sleep(static_cast<uint>(luaL_checknumber(L, 1) * 1000));
+ pKernel->sleep(static_cast<uint>(luaL_checknumber(L, 1) * 1000));
return 0;
}
-// -----------------------------------------------------------------------------
-
-static int Crash(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int crash(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- pKernel->Crash();
+ pKernel->crash();
return 0;
}
-// -----------------------------------------------------------------------------
-
-static int ExecuteFile(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int executeFile(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- ScriptEngine *pSE = pKernel->GetScript();
+ ScriptEngine *pSE = pKernel->getScript();
BS_ASSERT(pSE);
lua_pushbooleancpp(L, pSE->executeFile(luaL_checkstring(L, 1)));
@@ -179,551 +151,456 @@ static int ExecuteFile(lua_State *L) {
return 0;
}
-// -----------------------------------------------------------------------------
-
-static int GetUserdataDirectory(lua_State *L) {
- lua_pushstring(L, FileSystemUtil::GetInstance().GetUserdataDirectory().c_str());
+static int getUserdataDirectory(lua_State *L) {
+ lua_pushstring(L, FileSystemUtil::getInstance().getUserdataDirectory().c_str());
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int GetPathSeparator(lua_State *L) {
- lua_pushstring(L, FileSystemUtil::GetInstance().GetPathSeparator().c_str());
+static int getPathSeparator(lua_State *L) {
+ lua_pushstring(L, FileSystemUtil::getInstance().getPathSeparator().c_str());
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int FileExists(lua_State *L) {
- lua_pushbooleancpp(L, FileSystemUtil::GetInstance().FileExists(luaL_checkstring(L, 1)));
+static int fileExists(lua_State *L) {
+ lua_pushbooleancpp(L, FileSystemUtil::getInstance().fileExists(luaL_checkstring(L, 1)));
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int CreateDirectory(lua_State *L) {
- lua_pushbooleancpp(L, FileSystemUtil::GetInstance().CreateDirectory(luaL_checkstring(L, 1)));
+static int createDirectory(lua_State *L) {
+ lua_pushbooleancpp(L, FileSystemUtil::getInstance().createDirectory(luaL_checkstring(L, 1)));
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int GetWinCode(lua_State *L) {
+static int getWinCode(lua_State *L) {
lua_pushstring(L, "ScummVM");
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int GetSubversionRevision(lua_State *L) {
+static int getSubversionRevision(lua_State *L) {
// ScummVM is 1337
lua_pushnumber(L, 1337);
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int GetUsedMemory(lua_State *L) {
- lua_pushnumber(L, Kernel::GetInstance()->GetUsedMemory());
+static int getUsedMemory(lua_State *L) {
+ lua_pushnumber(L, Kernel::getInstance()->getUsedMemory());
return 1;
}
-// -----------------------------------------------------------------------------
-
static const char *KERNEL_LIBRARY_NAME = "Kernel";
static const luaL_reg KERNEL_FUNCTIONS[] = {
- {"DisconnectService", DisconnectService},
- {"GetActiveServiceIdentifier", GetActiveServiceIdentifier},
- {"GetSuperclassCount", GetSuperclassCount},
- {"GetSuperclassIdentifier", GetSuperclassIdentifier},
- {"GetServiceCount", GetServiceCount},
- {"GetServiceIdentifier", GetServiceIdentifier},
- {"GetMilliTicks", GetMilliTicks},
- {"GetTimer", GetTimer},
- {"StartService", StartService},
- {"Sleep", Sleep},
- {"Crash", Crash},
- {"ExecuteFile", ExecuteFile},
- {"GetUserdataDirectory", GetUserdataDirectory},
- {"GetPathSeparator", GetPathSeparator},
- {"FileExists", FileExists},
- {"CreateDirectory", CreateDirectory},
- {"GetWinCode", GetWinCode},
- {"GetSubversionRevision", GetSubversionRevision},
- {"GetUsedMemory", GetUsedMemory},
+ {"DisconnectService", disconnectService},
+ {"GetActiveServiceIdentifier", getActiveServiceIdentifier},
+ {"GetSuperclassCount", getSuperclassCount},
+ {"GetSuperclassIdentifier", getSuperclassIdentifier},
+ {"GetServiceCount", getServiceCount},
+ {"GetServiceIdentifier", getServiceIdentifier},
+ {"GetMilliTicks", getMilliTicks},
+ {"GetTimer", getTimer},
+ {"StartService", startService},
+ {"Sleep", sleep},
+ {"Crash", crash},
+ {"ExecuteFile", executeFile},
+ {"GetUserdataDirectory", getUserdataDirectory},
+ {"GetPathSeparator", getPathSeparator},
+ {"FileExists", fileExists},
+ {"CreateDirectory", createDirectory},
+ {"GetWinCode", getWinCode},
+ {"GetSubversionRevision", getSubversionRevision},
+ {"GetUsedMemory", getUsedMemory},
{0, 0}
};
-// -----------------------------------------------------------------------------
-
-static int IsVisible(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int isVisible(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- Window *pWindow = pKernel->GetWindow();
+ Window *pWindow = pKernel->getWindow();
BS_ASSERT(pWindow);
- lua_pushbooleancpp(L, pWindow->IsVisible());
+ lua_pushbooleancpp(L, pWindow->isVisible());
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int SetVisible(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int setVisible(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- Window *pWindow = pKernel->GetWindow();
+ Window *pWindow = pKernel->getWindow();
BS_ASSERT(pWindow);
- pWindow->SetVisible(lua_tobooleancpp(L, 1));
+ pWindow->setVisible(lua_tobooleancpp(L, 1));
return 0;
}
-// -----------------------------------------------------------------------------
-
-static int GetX(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int getX(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- Window *pWindow = pKernel->GetWindow();
+ Window *pWindow = pKernel->getWindow();
BS_ASSERT(pWindow);
- lua_pushnumber(L, pWindow->GetX());
+ lua_pushnumber(L, pWindow->getX());
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int GetY(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int getY(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- Window *pWindow = pKernel->GetWindow();
+ Window *pWindow = pKernel->getWindow();
BS_ASSERT(pWindow);
- lua_pushnumber(L, pWindow->GetY());
+ lua_pushnumber(L, pWindow->getY());
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int SetX(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int setX(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- Window *pWindow = pKernel->GetWindow();
+ Window *pWindow = pKernel->getWindow();
BS_ASSERT(pWindow);
- pWindow->SetX(static_cast<int>(luaL_checknumber(L, 1)));
+ pWindow->setX(static_cast<int>(luaL_checknumber(L, 1)));
return 0;
}
-// -----------------------------------------------------------------------------
-
-static int SetY(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int setY(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- Window *pWindow = pKernel->GetWindow();
+ Window *pWindow = pKernel->getWindow();
BS_ASSERT(pWindow);
- pWindow->SetY(static_cast<int>(luaL_checknumber(L, 1)));
+ pWindow->setY(static_cast<int>(luaL_checknumber(L, 1)));
return 0;
}
-// -----------------------------------------------------------------------------
-
-static int GetClientX(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int getClientX(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- Window *pWindow = pKernel->GetWindow();
+ Window *pWindow = pKernel->getWindow();
BS_ASSERT(pWindow);
- lua_pushnumber(L, pWindow->GetClientX());
+ lua_pushnumber(L, pWindow->getClientX());
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int GetClientY(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int getClientY(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- Window *pWindow = pKernel->GetWindow();
+ Window *pWindow = pKernel->getWindow();
BS_ASSERT(pWindow);
- lua_pushnumber(L, pWindow->GetClientY());
+ lua_pushnumber(L, pWindow->getClientY());
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int GetWidth(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int getWidth(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- Window *pWindow = pKernel->GetWindow();
+ Window *pWindow = pKernel->getWindow();
BS_ASSERT(pWindow);
- lua_pushnumber(L, pWindow->GetWidth());
+ lua_pushnumber(L, pWindow->getWidth());
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int GetHeight(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int getHeight(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- Window *pWindow = pKernel->GetWindow();
+ Window *pWindow = pKernel->getWindow();
BS_ASSERT(pWindow);
- lua_pushnumber(L, pWindow->GetHeight());
+ lua_pushnumber(L, pWindow->getHeight());
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int SetWidth(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int setWidth(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- Window *pWindow = pKernel->GetWindow();
+ Window *pWindow = pKernel->getWindow();
BS_ASSERT(pWindow);
- pWindow->SetWidth(static_cast<int>(luaL_checknumber(L, 1)));
+ pWindow->setWidth(static_cast<int>(luaL_checknumber(L, 1)));
return 0;
}
-// -----------------------------------------------------------------------------
-
-static int SetHeight(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int setHeight(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- Window *pWindow = pKernel->GetWindow();
+ Window *pWindow = pKernel->getWindow();
BS_ASSERT(pWindow);
- pWindow->SetHeight(static_cast<int>(luaL_checknumber(L, 1)));
+ pWindow->setHeight(static_cast<int>(luaL_checknumber(L, 1)));
return 0;
}
-// -----------------------------------------------------------------------------
-
-static int GetTitle(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int getTitle(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- Window *pWindow = pKernel->GetWindow();
+ Window *pWindow = pKernel->getWindow();
BS_ASSERT(pWindow);
- lua_pushstring(L, pWindow->GetTitle().c_str());
+ lua_pushstring(L, pWindow->getTitle().c_str());
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int SetTitle(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int setTitle(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- Window *pWindow = pKernel->GetWindow();
+ Window *pWindow = pKernel->getWindow();
BS_ASSERT(pWindow);
- pWindow->SetTitle(luaL_checkstring(L, 1));
+ pWindow->setTitle(luaL_checkstring(L, 1));
return 0;
}
-// -----------------------------------------------------------------------------
-
-static int ProcessMessages(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int processMessages(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- Window *pWindow = pKernel->GetWindow();
+ Window *pWindow = pKernel->getWindow();
BS_ASSERT(pWindow);
- lua_pushbooleancpp(L, pWindow->ProcessMessages());
+ lua_pushbooleancpp(L, pWindow->processMessages());
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int CloseWanted(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int closeWanted(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- Window *pWindow = pKernel->GetWindow();
+ Window *pWindow = pKernel->getWindow();
BS_ASSERT(pWindow);
- lua_pushbooleancpp(L, pWindow->CloseWanted());
+ lua_pushbooleancpp(L, pWindow->closeWanted());
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int WaitForFocus(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int waitForFocus(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- Window *pWindow = pKernel->GetWindow();
+ Window *pWindow = pKernel->getWindow();
BS_ASSERT(pWindow);
- lua_pushbooleancpp(L, pWindow->WaitForFocus());
+ lua_pushbooleancpp(L, pWindow->waitForFocus());
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int HasFocus(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int hasFocus(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- Window *pWindow = pKernel->GetWindow();
+ Window *pWindow = pKernel->getWindow();
BS_ASSERT(pWindow);
- lua_pushbooleancpp(L, pWindow->HasFocus());
+ lua_pushbooleancpp(L, pWindow->hasFocus());
return 1;
}
-// -----------------------------------------------------------------------------
-
static const char *WINDOW_LIBRARY_NAME = "Window";
static const luaL_reg WINDOW_FUNCTIONS[] = {
- {"IsVisible", IsVisible},
- {"SetVisible", SetVisible},
- {"GetX", GetX},
- {"SetX", SetX},
- {"GetY", GetY},
- {"SetY", SetY},
- {"GetClientX", GetClientX},
- {"GetClientY", GetClientY},
- {"GetWidth", GetWidth},
- {"GetHeight", GetHeight},
- {"SetWidth", SetWidth},
- {"SetHeight", SetHeight},
- {"GetTitle", GetTitle},
- {"SetTitle", SetTitle},
- {"ProcessMessages", ProcessMessages},
- {"CloseWanted", CloseWanted},
- {"WaitForFocus", WaitForFocus},
- {"HasFocus", HasFocus},
+ {"IsVisible", isVisible},
+ {"SetVisible", setVisible},
+ {"GetX", getX},
+ {"SetX", setX},
+ {"GetY", getY},
+ {"SetY", setY},
+ {"GetClientX", getClientX},
+ {"GetClientY", getClientY},
+ {"GetWidth", getWidth},
+ {"GetHeight", getHeight},
+ {"SetWidth", setWidth},
+ {"SetHeight", setHeight},
+ {"GetTitle", getTitle},
+ {"SetTitle", setTitle},
+ {"ProcessMessages", processMessages},
+ {"CloseWanted", closeWanted},
+ {"WaitForFocus", waitForFocus},
+ {"HasFocus", hasFocus},
{0, 0}
};
-// -----------------------------------------------------------------------------
-
-static int PrecacheResource(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int precacheResource(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- ResourceManager *pResource = pKernel->GetResourceManager();
+ ResourceManager *pResource = pKernel->getResourceManager();
BS_ASSERT(pResource);
- lua_pushbooleancpp(L, pResource->PrecacheResource(luaL_checkstring(L, 1)));
+ lua_pushbooleancpp(L, pResource->precacheResource(luaL_checkstring(L, 1)));
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int ForcePrecacheResource(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int forcePrecacheResource(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- ResourceManager *pResource = pKernel->GetResourceManager();
+ ResourceManager *pResource = pKernel->getResourceManager();
BS_ASSERT(pResource);
- lua_pushbooleancpp(L, pResource->PrecacheResource(luaL_checkstring(L, 1), true));
+ lua_pushbooleancpp(L, pResource->precacheResource(luaL_checkstring(L, 1), true));
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int GetMaxMemoryUsage(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int getMaxMemoryUsage(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- ResourceManager *pResource = pKernel->GetResourceManager();
+ ResourceManager *pResource = pKernel->getResourceManager();
BS_ASSERT(pResource);
- lua_pushnumber(L, pResource->GetMaxMemoryUsage());
+ lua_pushnumber(L, pResource->getMaxMemoryUsage());
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int SetMaxMemoryUsage(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int setMaxMemoryUsage(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- ResourceManager *pResource = pKernel->GetResourceManager();
+ ResourceManager *pResource = pKernel->getResourceManager();
BS_ASSERT(pResource);
- pResource->SetMaxMemoryUsage(static_cast<uint>(lua_tonumber(L, 1)));
+ pResource->setMaxMemoryUsage(static_cast<uint>(lua_tonumber(L, 1)));
return 0;
}
-// -----------------------------------------------------------------------------
-
-static int EmptyCache(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int emptyCache(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- ResourceManager *pResource = pKernel->GetResourceManager();
+ ResourceManager *pResource = pKernel->getResourceManager();
BS_ASSERT(pResource);
- pResource->EmptyCache();
+ pResource->emptyCache();
return 0;
}
-// -----------------------------------------------------------------------------
-
-static int IsLogCacheMiss(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int isLogCacheMiss(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- ResourceManager *pResource = pKernel->GetResourceManager();
+ ResourceManager *pResource = pKernel->getResourceManager();
BS_ASSERT(pResource);
- lua_pushbooleancpp(L, pResource->IsLogCacheMiss());
+ lua_pushbooleancpp(L, pResource->isLogCacheMiss());
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int SetLogCacheMiss(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int setLogCacheMiss(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- ResourceManager *pResource = pKernel->GetResourceManager();
+ ResourceManager *pResource = pKernel->getResourceManager();
BS_ASSERT(pResource);
- pResource->SetLogCacheMiss(lua_tobooleancpp(L, 1));
+ pResource->setLogCacheMiss(lua_tobooleancpp(L, 1));
return 0;
}
-// -----------------------------------------------------------------------------
-
-static int DumpLockedResources(lua_State *L) {
- Kernel *pKernel = Kernel::GetInstance();
+static int dumpLockedResources(lua_State *L) {
+ Kernel *pKernel = Kernel::getInstance();
BS_ASSERT(pKernel);
- ResourceManager *pResource = pKernel->GetResourceManager();
+ ResourceManager *pResource = pKernel->getResourceManager();
BS_ASSERT(pResource);
- pResource->DumpLockedResources();
+ pResource->dumpLockedResources();
return 0;
}
-// -----------------------------------------------------------------------------
-
static const char *RESOURCE_LIBRARY_NAME = "Resource";
static const luaL_reg RESOURCE_FUNCTIONS[] = {
- {"PrecacheResource", PrecacheResource},
- {"ForcePrecacheResource", ForcePrecacheResource},
- {"GetMaxMemoryUsage", GetMaxMemoryUsage},
- {"SetMaxMemoryUsage", SetMaxMemoryUsage},
- {"EmptyCache", EmptyCache},
- {"IsLogCacheMiss", IsLogCacheMiss},
- {"SetLogCacheMiss", SetLogCacheMiss},
- {"DumpLockedResources", DumpLockedResources},
+ {"PrecacheResource", precacheResource},
+ {"ForcePrecacheResource", forcePrecacheResource},
+ {"GetMaxMemoryUsage", getMaxMemoryUsage},
+ {"SetMaxMemoryUsage", setMaxMemoryUsage},
+ {"EmptyCache", emptyCache},
+ {"IsLogCacheMiss", isLogCacheMiss},
+ {"SetLogCacheMiss", setLogCacheMiss},
+ {"DumpLockedResources", dumpLockedResources},
{0, 0}
};
-// -----------------------------------------------------------------------------
-
-static int ReloadSlots(lua_State *L) {
- PersistenceService::GetInstance().ReloadSlots();
+static int reloadSlots(lua_State *L) {
+ PersistenceService::getInstance().reloadSlots();
lua_pushnil(L);
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int GetSlotCount(lua_State *L) {
- lua_pushnumber(L, PersistenceService::GetInstance().GetSlotCount());
+static int getSlotCount(lua_State *L) {
+ lua_pushnumber(L, PersistenceService::getInstance().getSlotCount());
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int IsSlotOccupied(lua_State *L) {
- lua_pushbooleancpp(L, PersistenceService::GetInstance().IsSlotOccupied(
- static_cast<uint>(luaL_checknumber(L, 1)) - 1));
+static int isSlotOccupied(lua_State *L) {
+ lua_pushbooleancpp(L, PersistenceService::getInstance().isSlotOccupied(static_cast<uint>(luaL_checknumber(L, 1)) - 1));
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int GetSavegameDirectory(lua_State *L) {
- lua_pushstring(L, PersistenceService::GetInstance().GetSavegameDirectory().c_str());
+static int getSavegameDirectory(lua_State *L) {
+ lua_pushstring(L, PersistenceService::getInstance().getSavegameDirectory().c_str());
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int IsSavegameCompatible(lua_State *L) {
- lua_pushbooleancpp(L, PersistenceService::GetInstance().IsSavegameCompatible(
+static int isSavegameCompatible(lua_State *L) {
+ lua_pushbooleancpp(L, PersistenceService::getInstance().isSavegameCompatible(
static_cast<uint>(luaL_checknumber(L, 1)) - 1));
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int GetSavegameDescription(lua_State *L) {
- lua_pushstring(L, PersistenceService::GetInstance().GetSavegameDescription(
+static int getSavegameDescription(lua_State *L) {
+ lua_pushstring(L, PersistenceService::getInstance().getSavegameDescription(
static_cast<uint>(luaL_checknumber(L, 1)) - 1).c_str());
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int GetSavegameFilename(lua_State *L) {
- lua_pushstring(L, PersistenceService::GetInstance().GetSavegameFilename(static_cast<uint>(luaL_checknumber(L, 1)) - 1).c_str());
+static int getSavegameFilename(lua_State *L) {
+ lua_pushstring(L, PersistenceService::getInstance().getSavegameFilename(static_cast<uint>(luaL_checknumber(L, 1)) - 1).c_str());
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int LoadGame(lua_State *L) {
- lua_pushbooleancpp(L, PersistenceService::GetInstance().LoadGame(static_cast<uint>(luaL_checknumber(L, 1)) - 1));
+static int loadGame(lua_State *L) {
+ lua_pushbooleancpp(L, PersistenceService::getInstance().loadGame(static_cast<uint>(luaL_checknumber(L, 1)) - 1));
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int SaveGame(lua_State *L) {
- lua_pushbooleancpp(L, PersistenceService::GetInstance().SaveGame(static_cast<uint>(luaL_checknumber(L, 1)) - 1, luaL_checkstring(L, 2)));
+static int saveGame(lua_State *L) {
+ lua_pushbooleancpp(L, PersistenceService::getInstance().saveGame(static_cast<uint>(luaL_checknumber(L, 1)) - 1, luaL_checkstring(L, 2)));
return 1;
}
-// -----------------------------------------------------------------------------
-
static const char *PERSISTENCE_LIBRARY_NAME = "Persistence";
static const luaL_reg PERSISTENCE_FUNCTIONS[] = {
- {"ReloadSlots", ReloadSlots},
- {"GetSlotCount", GetSlotCount},
- {"IsSlotOccupied", IsSlotOccupied},
- {"GetSavegameDirectory", GetSavegameDirectory},
- {"IsSavegameCompatible", IsSavegameCompatible},
- {"GetSavegameDescription", GetSavegameDescription},
- {"GetSavegameFilename", GetSavegameFilename},
- {"LoadGame", LoadGame},
- {"SaveGame", SaveGame},
+ {"ReloadSlots", reloadSlots},
+ {"GetSlotCount", getSlotCount},
+ {"IsSlotOccupied", isSlotOccupied},
+ {"GetSavegameDirectory", getSavegameDirectory},
+ {"IsSavegameCompatible", isSavegameCompatible},
+ {"GetSavegameDescription", getSavegameDescription},
+ {"GetSavegameFilename", getSavegameFilename},
+ {"LoadGame", loadGame},
+ {"SaveGame", saveGame},
{0, 0}
};
-// -----------------------------------------------------------------------------
-
-bool Kernel::_RegisterScriptBindings() {
- ScriptEngine *pScript = GetScript();
+bool Kernel::registerScriptBindings() {
+ ScriptEngine *pScript = getScript();
BS_ASSERT(pScript);
lua_State *L = static_cast<lua_State *>(pScript->getScriptObject());
BS_ASSERT(L);
diff --git a/engines/sword25/kernel/log.cpp b/engines/sword25/kernel/log.cpp
index 43a3ee0105..91b0c36ac1 100644
--- a/engines/sword25/kernel/log.cpp
+++ b/engines/sword25/kernel/log.cpp
@@ -39,32 +39,31 @@
namespace Sword25 {
-// Constants
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;
+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() {
+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();
+ _logFile = file.createWriteStream();
- if (_LogFile) {
+ 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");
+ log("Broken Sword 2.5 Engine - Build: %s - %s - VersionID: %s\n", __DATE__, __TIME__, gScummVMFullVersion);
+ log("-----------------------------------------------------------------------------------------------------\n");
return true;
}
@@ -73,141 +72,142 @@ bool BS_Log::_CreateLog() {
return false;
}
-void BS_Log::_CloseLog() {
- delete _LogFile;
- _LogFile = NULL;
+void BS_Log::closeLog() {
+ delete _logFile;
+ _logFile = NULL;
}
-void BS_Log::Log(const char *Format, ...) {
- char Message[LOG_BUFFERSIZE];
+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);
+ va_list argList;
+ va_start(argList, format);
+ vsnprintf(message, sizeof(message), format, argList);
// Log the message
- _WriteLog(Message);
+ writeLog(message);
- _FlushLog();
+ flushLog();
}
-void BS_Log::LogPrefix(const char *Prefix, const char *Format, ...) {
- char Message[LOG_BUFFERSIZE];
- char ExtFormat[LOG_BUFFERSIZE];
+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;
+ 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;
+ 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));
+ strncat(extFormat, format, (nextLine - format) + strlen("\n"));
+ Common::strlcat(extFormat, prefix, sizeof(extFormat));
+ Common::strlcat(extFormat, ": ", sizeof(extFormat));
}
- Format = NextLine + strlen("\n");
+ format = nextLine + strlen("\n");
}
// Create message
- va_list ArgList;
- va_start(ArgList, Format);
- vsnprintf(Message, sizeof(Message), ExtFormat, ArgList);
+ va_list argList;
+ va_start(argList, format);
+ vsnprintf(message, sizeof(message), extFormat, argList);
// Log the message
- _WriteLog(Message);
+ writeLog(message);
- _FlushLog();
+ flushLog();
}
-void BS_Log::LogDecorated(const char *Format, ...) {
+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);
+ 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);
+ // 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;
+ char *messageWalker = message;
for (;;) {
- char *NextLine = strstr(MessageWalker, "\n");
- if (NextLine) {
- *NextLine = 0;
- if (_LineBegin) {
- _WriteLog(_Prefix);
- if (_File && _Line)
- _WriteLog(SecondaryPrefix);
+ 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;
+ writeLog(messageWalker);
+ writeLog("\n");
+ messageWalker = nextLine + sizeof("\n") - 1;
+ _lineBegin = true;
} else {
- if (_LineBegin) {
- _WriteLog(_Prefix);
- if (_File && _Line)
- _WriteLog(SecondaryPrefix);
+ if (_lineBegin) {
+ writeLog(_prefix);
+ if (_file && _line)
+ writeLog(secondaryPrefix);
}
- _WriteLog(MessageWalker);
- _LineBegin = false;
+ writeLog(messageWalker);
+ _lineBegin = false;
break;
}
}
// Falls gewünscht, wird ans Ende der Nachricht automatisch ein Newline angehängt.
- if (_AutoNewline) {
- _WriteLog("\n");
- _LineBegin = true;
+ if (_autoNewline) {
+ writeLog("\n");
+ _lineBegin = true;
}
// Pseudoparameter zurücksetzen
- _Prefix = NULL;
- _File = 0;
- _Line = 0;
- _AutoNewline = false;
+ _prefix = NULL;
+ _file = 0;
+ _line = 0;
+ _autoNewline = false;
- _FlushLog();
+ flushLog();
}
-int BS_Log::_WriteLog(const char *Message) {
- if (!_LogFile && !_CreateLog())
+int BS_Log::writeLog(const char *message) {
+ if (!_logFile && !createLog())
return false;
- debugN(0, "%s", Message);
+ debugN(0, "%s", message);
- _LogFile->writeString(Message);
+ _logFile->writeString(message);
return true;
}
-void BS_Log::_FlushLog() {
- if (_LogFile)
- _LogFile->flush();
+void BS_Log::flushLog() {
+ if (_logFile)
+ _logFile->flush();
}
-void (*BS_LogPtr)(const char *, ...) = BS_Log::Log;
+void (*BS_LogPtr)(const char *, ...) = BS_Log::log;
-void BS_Log_C(const char *Message) {
- BS_LogPtr(Message);
+void BS_Log_C(const char *message) {
+ BS_LogPtr(message);
}
#else
-void BS_Log_C(const char *Message) {};
+void BS_Log_C(const char *message) {};
#endif
diff --git a/engines/sword25/kernel/log.h b/engines/sword25/kernel/log.h
index 02cfa3ab81..e7c5789a53 100644
--- a/engines/sword25/kernel/log.h
+++ b/engines/sword25/kernel/log.h
@@ -46,50 +46,50 @@ namespace Sword25 {
#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
+#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 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 setPrefix(const char *prefix) {
+ _prefix = prefix;
}
- static void SetFile(const char *File) {
- _File = File;
+ static void setFile(const char *file) {
+ _file = file;
}
- static void SetLine(int Line) {
- _Line = Line;
+ static void setLine(int line) {
+ _line = line;
}
- static void SetAutoNewline(bool AutoNewline) {
- _AutoNewline = AutoNewline;
+ static void setAutoNewline(bool autoNewline) {
+ _autoNewline = autoNewline;
}
- static void _CloseLog();
+ 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 Common::WriteStream *_logFile;
+ static bool _lineBegin;
+ static const char *_prefix;
+ static const char *_file;
+ static int _line;
+ static bool _autoNewline;
- static bool _CreateLog();
+ static bool createLog();
- static int _WriteLog(const char *Message);
- static void _FlushLog();
+ static int writeLog(const char *message);
+ static void flushLog();
};
// Auxiliary function that allows to log C functions (needed for Lua).
@@ -112,17 +112,17 @@ private:
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 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) {};
+ 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) {};
+ static void registerLogListener(LOG_LISTENER_CALLBACK callback) {};
};
#define BS_Log_C error
diff --git a/engines/sword25/kernel/outputpersistenceblock.cpp b/engines/sword25/kernel/outputpersistenceblock.cpp
index a6e598100e..811ca983dc 100644
--- a/engines/sword25/kernel/outputpersistenceblock.cpp
+++ b/engines/sword25/kernel/outputpersistenceblock.cpp
@@ -34,97 +34,67 @@
#define BS_LOG_PREFIX "OUTPUTPERSISTENCEBLOCK"
-// -----------------------------------------------------------------------------
-// Includes
-// -----------------------------------------------------------------------------
-
#include "sword25/kernel/outputpersistenceblock.h"
-// -----------------------------------------------------------------------------
-// Constants
-// -----------------------------------------------------------------------------
-
namespace {
const uint INITIAL_BUFFER_SIZE = 1024 * 64;
}
namespace Sword25 {
-// -----------------------------------------------------------------------------
-// Construction / Destruction
-// -----------------------------------------------------------------------------
-
OutputPersistenceBlock::OutputPersistenceBlock() {
- m_Data.reserve(INITIAL_BUFFER_SIZE);
+ _data.reserve(INITIAL_BUFFER_SIZE);
}
-// -----------------------------------------------------------------------------
-// Writing
-// -----------------------------------------------------------------------------
-
-void OutputPersistenceBlock::write(signed int Value) {
- WriteMarker(SINT_MARKER);
- Value = ConvertEndianessFromSystemToStorage(Value);
- RawWrite(&Value, sizeof(Value));
+void OutputPersistenceBlock::write(signed int value) {
+ writeMarker(SINT_MARKER);
+ value = convertEndianessFromSystemToStorage(value);
+ rawWrite(&value, sizeof(value));
}
-// -----------------------------------------------------------------------------
-
-void OutputPersistenceBlock::write(uint Value) {
- WriteMarker(UINT_MARKER);
- Value = ConvertEndianessFromSystemToStorage(Value);
- RawWrite(&Value, sizeof(Value));
+void OutputPersistenceBlock::write(uint value) {
+ writeMarker(UINT_MARKER);
+ value = convertEndianessFromSystemToStorage(value);
+ rawWrite(&value, sizeof(value));
}
-// -----------------------------------------------------------------------------
-
-void OutputPersistenceBlock::write(float Value) {
- WriteMarker(FLOAT_MARKER);
- Value = ConvertEndianessFromSystemToStorage(Value);
- RawWrite(&Value, sizeof(Value));
+void OutputPersistenceBlock::write(float value) {
+ writeMarker(FLOAT_MARKER);
+ value = convertEndianessFromSystemToStorage(value);
+ rawWrite(&value, sizeof(value));
}
-// -----------------------------------------------------------------------------
+void OutputPersistenceBlock::write(bool value) {
+ writeMarker(BOOL_MARKER);
-void OutputPersistenceBlock::write(bool Value) {
- WriteMarker(BOOL_MARKER);
-
- uint UIntBool = Value ? 1 : 0;
- UIntBool = ConvertEndianessFromSystemToStorage(UIntBool);
- RawWrite(&UIntBool, sizeof(UIntBool));
+ uint uintBool = value ? 1 : 0;
+ uintBool = convertEndianessFromSystemToStorage(uintBool);
+ rawWrite(&uintBool, sizeof(uintBool));
}
-// -----------------------------------------------------------------------------
-
-void OutputPersistenceBlock::write(const Common::String &String) {
- WriteMarker(STRING_MARKER);
+void OutputPersistenceBlock::write(const Common::String &string) {
+ writeMarker(STRING_MARKER);
- write(String.size());
- RawWrite(String.c_str(), String.size());
+ write(string.size());
+ rawWrite(string.c_str(), string.size());
}
-// -----------------------------------------------------------------------------
-
-void OutputPersistenceBlock::write(const void *BufferPtr, size_t Size) {
- WriteMarker(BLOCK_MARKER);
+void OutputPersistenceBlock::write(const void *bufferPtr, size_t size) {
+ writeMarker(BLOCK_MARKER);
- write((int) Size);
- RawWrite(BufferPtr, Size);
+ write((int)size);
+ rawWrite(bufferPtr, size);
}
-// -----------------------------------------------------------------------------
-
-void OutputPersistenceBlock::WriteMarker(byte Marker) {
- m_Data.push_back(Marker);
+void OutputPersistenceBlock::writeMarker(byte marker) {
+ _data.push_back(marker);
}
-// -----------------------------------------------------------------------------
-
-void OutputPersistenceBlock::RawWrite(const void *DataPtr, size_t Size) {
- if (Size > 0) {
- uint OldSize = m_Data.size();
- m_Data.resize(OldSize + Size);
- memcpy(&m_Data[OldSize], DataPtr, Size);
+void OutputPersistenceBlock::rawWrite(const void *dataPtr, size_t size) {
+ if (size > 0) {
+ uint oldSize = _data.size();
+ _data.resize(oldSize + size);
+ memcpy(&_data[oldSize], dataPtr, size);
}
}
diff --git a/engines/sword25/kernel/outputpersistenceblock.h b/engines/sword25/kernel/outputpersistenceblock.h
index 154dbc9763..3ece0175af 100644
--- a/engines/sword25/kernel/outputpersistenceblock.h
+++ b/engines/sword25/kernel/outputpersistenceblock.h
@@ -35,42 +35,34 @@
#ifndef SWORD25_OUTPUTPERSISTENCEBLOCK_H
#define SWORD25_OUTPUTPERSISTENCEBLOCK_H
-// -----------------------------------------------------------------------------
-// Includes
-// -----------------------------------------------------------------------------
-
#include "sword25/kernel/common.h"
#include "sword25/kernel/persistenceblock.h"
namespace Sword25 {
-// -----------------------------------------------------------------------------
-// Class declaration
-// -----------------------------------------------------------------------------
-
class OutputPersistenceBlock : public PersistenceBlock {
public:
OutputPersistenceBlock();
- void write(signed int Value);
- void write(uint Value);
- void write(float Value);
- void write(bool Value);
- void write(const Common::String &String);
- void write(const void *BufferPtr, size_t Size);
+ void write(signed int value);
+ void write(uint value);
+ void write(float value);
+ void write(bool value);
+ void write(const Common::String &string);
+ void write(const void *bufferPtr, size_t size);
- const void *GetData() const {
- return &m_Data[0];
+ const void *getData() const {
+ return &_data[0];
}
- uint GetDataSize() const {
- return m_Data.size();
+ uint getDataSize() const {
+ return _data.size();
}
private:
- void WriteMarker(byte Marker);
- void RawWrite(const void *DataPtr, size_t Size);
+ void writeMarker(byte marker);
+ void rawWrite(const void *dataPtr, size_t size);
- Common::Array<byte> m_Data;
+ Common::Array<byte> _data;
};
} // End of namespace Sword25
diff --git a/engines/sword25/kernel/persistenceblock.h b/engines/sword25/kernel/persistenceblock.h
index 1f043aa68a..4a64eff11b 100644
--- a/engines/sword25/kernel/persistenceblock.h
+++ b/engines/sword25/kernel/persistenceblock.h
@@ -35,34 +35,26 @@
#ifndef SWORD25_PERSISTENCEBLOCK_H
#define SWORD25_PERSISTENCEBLOCK_H
-// -----------------------------------------------------------------------------
-// Includes
-// -----------------------------------------------------------------------------
-
#include "sword25/kernel/common.h"
namespace Sword25 {
-// -----------------------------------------------------------------------------
-// Class definition
-// -----------------------------------------------------------------------------
-
class PersistenceBlock {
public:
- static uint GetSInt32Size() {
+ static uint getSInt32Size() {
return sizeof(signed int) + sizeof(byte);
}
- static uint GetUInt32Size() {
+ static uint getUInt32Size() {
return sizeof(uint) + sizeof(byte);
}
- static uint GetFloat32Size() {
+ static uint getFloat32Size() {
return sizeof(float) + sizeof(byte);
}
- static uint GetBoolSize() {
+ static uint getBoolSize() {
return sizeof(byte) + sizeof(byte);
}
- static uint GetStringSize(const Common::String &String) {
- return static_cast<uint>(sizeof(uint) + String.size() + sizeof(byte));
+ static uint getStringSize(const Common::String &string) {
+ return static_cast<uint>(sizeof(uint) + string.size() + sizeof(byte));
}
protected:
@@ -84,43 +76,41 @@ protected:
//
template<typename T>
- static T ConvertEndianessFromSystemToStorage(T Value) {
- if (IsBigEndian()) ReverseByteOrder(&Value);
- return Value;
+ static T convertEndianessFromSystemToStorage(T value) {
+ if (isBigEndian())
+ reverseByteOrder(&value);
+ return value;
}
template<typename T>
- static T ConvertEndianessFromStorageToSystem(T Value) {
- if (IsBigEndian()) ReverseByteOrder(&Value);
- return Value;
+ static T convertEndianessFromStorageToSystem(T value) {
+ if (isBigEndian())
+ reverseByteOrder(&value);
+ return value;
}
private:
- static bool IsBigEndian() {
- uint Dummy = 1;
- byte *DummyPtr = reinterpret_cast<byte *>(&Dummy);
- return DummyPtr[0] == 0;
+ static bool isBigEndian() {
+ uint dummy = 1;
+ byte *dummyPtr = reinterpret_cast<byte *>(&dummy);
+ return dummyPtr[0] == 0;
}
template<typename T>
- static void Swap(T &One, T &Two) {
- T Temp = One;
- One = Two;
- Two = Temp;
+ static void swap(T &one, T &two) {
+ T temp = one;
+ one = two;
+ two = temp;
}
- static void ReverseByteOrder(void *Ptr) {
+ static void reverseByteOrder(void *ptr) {
// Reverses the byte order of the 32-bit word pointed to by Ptr
- byte *CharPtr = static_cast<byte *>(Ptr);
- Swap(CharPtr[0], CharPtr[3]);
- Swap(CharPtr[1], CharPtr[2]);
+ byte *charPtr = static_cast<byte *>(ptr);
+ swap(charPtr[0], charPtr[3]);
+ swap(charPtr[1], charPtr[2]);
}
};
-// -----------------------------------------------------------------------------
-// Compile time asserts
-// -----------------------------------------------------------------------------
-
#define CTASSERT(ex) typedef char ctassert_type[(ex) ? 1 : -1]
CTASSERT(sizeof(byte) == 1);
CTASSERT(sizeof(signed int) == 4);
diff --git a/engines/sword25/kernel/persistenceservice.cpp b/engines/sword25/kernel/persistenceservice.cpp
index 79dbcb62e9..b821b91c55 100644
--- a/engines/sword25/kernel/persistenceservice.cpp
+++ b/engines/sword25/kernel/persistenceservice.cpp
@@ -32,10 +32,6 @@
*
*/
-// -----------------------------------------------------------------------------
-// Includes
-// -----------------------------------------------------------------------------
-
#include "common/fs.h"
#include "common/savefile.h"
#include "sword25/kernel/kernel.h"
@@ -52,37 +48,27 @@
#define BS_LOG_PREFIX "PERSISTENCESERVICE"
-// -----------------------------------------------------------------------------
-// Constants and utility functions
-// -----------------------------------------------------------------------------
-
namespace Sword25 {
-const char *SAVEGAME_EXTENSION = ".b25s";
-const char *SAVEGAME_DIRECTORY = "saves";
-const char *FILE_MARKER = "BS25SAVEGAME";
+const char *SAVEGAME_EXTENSION = ".b25s";
+const char *SAVEGAME_DIRECTORY = "saves";
+const char *FILE_MARKER = "BS25SAVEGAME";
const uint SLOT_COUNT = 18;
const uint FILE_COPY_BUFFER_SIZE = 1024 * 10;
const char *VERSIONID = "SCUMMVM1";
-// -------------------------------------------------------------------------
-
-Common::String GenerateSavegameFilename(uint slotID) {
+Common::String generateSavegameFilename(uint slotID) {
char buffer[10];
sprintf(buffer, "%d%s", slotID, SAVEGAME_EXTENSION);
return Common::String(buffer);
}
-// -------------------------------------------------------------------------
-
-Common::String GenerateSavegamePath(uint SlotID) {
- Common::FSNode folder(PersistenceService::GetSavegameDirectory());
+Common::String generateSavegamePath(uint slotID) {
+ Common::FSNode folder(PersistenceService::getSavegameDirectory());
- return folder.getChild(GenerateSavegameFilename(SlotID)).getPath();
+ return folder.getChild(generateSavegameFilename(slotID)).getPath();
}
-// -------------------------------------------------------------------------
-
-Common::String FormatTimestamp(TimeDate Time) {
+Common::String formatTimestamp(TimeDate time) {
// In the original BS2.5 engine, this used a local object to show the date/time as as a string.
// For now in ScummVM it's being hardcoded to 'dd-MON-yyyy hh:mm:ss'
Common::String monthList[12] = {
@@ -90,157 +76,132 @@ Common::String FormatTimestamp(TimeDate Time) {
};
char buffer[100];
snprintf(buffer, 100, "%.2d-%s-%.4d %.2d:%.2d:%.2d",
- Time.tm_mday, monthList[Time.tm_mon].c_str(), 1900 + Time.tm_year,
- Time.tm_hour, Time.tm_min, Time.tm_sec
+ time.tm_mday, monthList[time.tm_mon].c_str(), 1900 + time.tm_year,
+ time.tm_hour, time.tm_min, time.tm_sec
);
return Common::String(buffer);
}
-// -------------------------------------------------------------------------
-
-Common::String LoadString(Common::InSaveFile *In, uint MaxSize = 999) {
- Common::String Result;
+Common::String loadString(Common::InSaveFile *in, uint maxSize = 999) {
+ Common::String result;
- char ch = (char)In->readByte();
+ char ch = (char)in->readByte();
while ((ch != '\0') && (ch != ' ')) {
- Result += ch;
- if (Result.size() >= MaxSize) break;
- ch = (char)In->readByte();
+ result += ch;
+ if (result.size() >= maxSize)
+ break;
+ ch = (char)in->readByte();
}
- return Result;
+ return result;
}
}
namespace Sword25 {
-// -----------------------------------------------------------------------------
-// Private Implementation
-// -----------------------------------------------------------------------------
-
struct SavegameInformation {
- bool IsOccupied;
- bool IsCompatible;
- Common::String Description;
- Common::String Filename;
- uint GamedataLength;
- uint GamedataOffset;
- uint GamedataUncompressedLength;
+ bool isOccupied;
+ bool isCompatible;
+ Common::String description;
+ Common::String filename;
+ uint gamedataLength;
+ uint gamedataOffset;
+ uint gamedataUncompressedLength;
SavegameInformation() {
- Clear();
+ clear();
}
- void Clear() {
- IsOccupied = false;
- IsCompatible = false;
- Description = "";
- Filename = "";
- GamedataLength = 0;
- GamedataOffset = 0;
- GamedataUncompressedLength = 0;
+ void clear() {
+ isOccupied = false;
+ isCompatible = false;
+ description = "";
+ filename = "";
+ gamedataLength = 0;
+ gamedataOffset = 0;
+ gamedataUncompressedLength = 0;
}
};
struct PersistenceService::Impl {
- SavegameInformation m_SavegameInformations[SLOT_COUNT];
-
- // -----------------------------------------------------------------------------
+ SavegameInformation _savegameInformations[SLOT_COUNT];
Impl() {
- ReloadSlots();
+ reloadSlots();
}
- // -----------------------------------------------------------------------------
-
- void ReloadSlots() {
+ void reloadSlots() {
// Über alle Spielstanddateien iterieren und deren Infos einlesen.
for (uint i = 0; i < SLOT_COUNT; ++i) {
- ReadSlotSavegameInformation(i);
+ readSlotSavegameInformation(i);
}
}
- void ReadSlotSavegameInformation(uint SlotID) {
+ void readSlotSavegameInformation(uint slotID) {
// Aktuelle Slotinformationen in den Ausgangszustand versetzen, er wird im Folgenden neu gefüllt.
- SavegameInformation &CurSavegameInfo = m_SavegameInformations[SlotID];
- CurSavegameInfo.Clear();
+ SavegameInformation &curSavegameInfo = _savegameInformations[slotID];
+ curSavegameInfo.clear();
// Den Dateinamen für den Spielstand des Slots generieren.
- Common::String Filename = GenerateSavegameFilename(SlotID);
+ Common::String filename = generateSavegameFilename(slotID);
// Try to open the savegame for loading
Common::SaveFileManager *sfm = g_system->getSavefileManager();
- Common::InSaveFile *File = sfm->openForLoading(Filename);
+ Common::InSaveFile *file = sfm->openForLoading(filename);
- if (File) {
+ if (file) {
// Read in the header
- Common::String StoredMarker = LoadString(File);
- Common::String StoredVersionID = LoadString(File);
- Common::String gameDataLength = LoadString(File);
- CurSavegameInfo.GamedataLength = atoi(gameDataLength.c_str());
- Common::String gamedataUncompressedLength = LoadString(File);
- CurSavegameInfo.GamedataUncompressedLength = atoi(gamedataUncompressedLength.c_str());
+ Common::String storedMarker = loadString(file);
+ Common::String storedVersionID = loadString(file);
+ Common::String gameDataLength = loadString(file);
+ curSavegameInfo.gamedataLength = atoi(gameDataLength.c_str());
+ Common::String gamedataUncompressedLength = loadString(file);
+ curSavegameInfo.gamedataUncompressedLength = atoi(gamedataUncompressedLength.c_str());
// If the header can be read in and is detected to be valid, we will have a valid file
- if (StoredMarker == FILE_MARKER) {
+ if (storedMarker == FILE_MARKER) {
// Der Slot wird als belegt markiert.
- CurSavegameInfo.IsOccupied = true;
+ curSavegameInfo.isOccupied = true;
// Speichern, ob der Spielstand kompatibel mit der aktuellen Engine-Version ist.
- CurSavegameInfo.IsCompatible = (StoredVersionID == Common::String(VERSIONID));
+ curSavegameInfo.isCompatible = (storedVersionID == Common::String(VERSIONID));
// Dateinamen des Spielstandes speichern.
- CurSavegameInfo.Filename = GenerateSavegameFilename(SlotID);
+ curSavegameInfo.filename = generateSavegameFilename(slotID);
// Die Beschreibung des Spielstandes besteht aus einer textuellen Darstellung des Änderungsdatums der Spielstanddatei.
- CurSavegameInfo.Description = FormatTimestamp(FileSystemUtil::GetInstance().GetFileTime(Filename));
+ curSavegameInfo.description = formatTimestamp(FileSystemUtil::getInstance().getFileTime(filename));
// Den Offset zu den gespeicherten Spieldaten innerhalb der Datei speichern.
// Dieses entspricht der aktuellen Position, da nach der letzten Headerinformation noch ein Leerzeichen als trenner folgt.
- CurSavegameInfo.GamedataOffset = static_cast<uint>(File->pos());
+ curSavegameInfo.gamedataOffset = static_cast<uint>(file->pos());
}
- delete File;
+ delete file;
}
}
};
-// -----------------------------------------------------------------------------
-// Construction / Destruction
-// -----------------------------------------------------------------------------
-
-PersistenceService &PersistenceService::GetInstance() {
- static PersistenceService Instance;
- return Instance;
+PersistenceService &PersistenceService::getInstance() {
+ static PersistenceService instance;
+ return instance;
}
-// -----------------------------------------------------------------------------
-
-PersistenceService::PersistenceService() : m_impl(new Impl) {
+PersistenceService::PersistenceService() : _impl(new Impl) {
}
-// -----------------------------------------------------------------------------
-
PersistenceService::~PersistenceService() {
- delete m_impl;
+ delete _impl;
}
-// -----------------------------------------------------------------------------
-// Implementation
-// -----------------------------------------------------------------------------
-
-void PersistenceService::ReloadSlots() {
- m_impl->ReloadSlots();
+void PersistenceService::reloadSlots() {
+ _impl->reloadSlots();
}
-// -----------------------------------------------------------------------------
-
-uint PersistenceService::GetSlotCount() {
+uint PersistenceService::getSlotCount() {
return SLOT_COUNT;
}
-// -----------------------------------------------------------------------------
-
-Common::String PersistenceService::GetSavegameDirectory() {
- Common::FSNode node(FileSystemUtil::GetInstance().GetUserdataDirectory());
+Common::String PersistenceService::getSavegameDirectory() {
+ Common::FSNode node(FileSystemUtil::getInstance().getUserdataDirectory());
Common::FSNode childNode = node.getChild(SAVEGAME_DIRECTORY);
// Try and return the path using the savegame subfolder. But if doesn't exist, fall back on the data directory
@@ -250,13 +211,11 @@ Common::String PersistenceService::GetSavegameDirectory() {
return node.getPath();
}
-// -----------------------------------------------------------------------------
-
namespace {
-bool CheckSlotID(uint SlotID) {
+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);
+ 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);
return false;
} else {
return true;
@@ -264,142 +223,134 @@ bool CheckSlotID(uint SlotID) {
}
}
-// -----------------------------------------------------------------------------
-
-bool PersistenceService::IsSlotOccupied(uint SlotID) {
- if (!CheckSlotID(SlotID)) return false;
- return m_impl->m_SavegameInformations[SlotID].IsOccupied;
+bool PersistenceService::isSlotOccupied(uint slotID) {
+ if (!checkslotID(slotID))
+ return false;
+ return _impl->_savegameInformations[slotID].isOccupied;
}
-// -----------------------------------------------------------------------------
-
-bool PersistenceService::IsSavegameCompatible(uint SlotID) {
- if (!CheckSlotID(SlotID)) return false;
- return m_impl->m_SavegameInformations[SlotID].IsCompatible;
+bool PersistenceService::isSavegameCompatible(uint slotID) {
+ if (!checkslotID(slotID))
+ return false;
+ return _impl->_savegameInformations[slotID].isCompatible;
}
-// -----------------------------------------------------------------------------
-
-Common::String &PersistenceService::GetSavegameDescription(uint SlotID) {
- static Common::String EmptyString;
- if (!CheckSlotID(SlotID)) return EmptyString;
- return m_impl->m_SavegameInformations[SlotID].Description;
+Common::String &PersistenceService::getSavegameDescription(uint slotID) {
+ static Common::String emptyString;
+ if (!checkslotID(slotID))
+ return emptyString;
+ return _impl->_savegameInformations[slotID].description;
}
-// -----------------------------------------------------------------------------
-
-Common::String &PersistenceService::GetSavegameFilename(uint SlotID) {
- static Common::String EmptyString;
- if (!CheckSlotID(SlotID)) return EmptyString;
- return m_impl->m_SavegameInformations[SlotID].Filename;
+Common::String &PersistenceService::getSavegameFilename(uint slotID) {
+ static Common::String emptyString;
+ if (!checkslotID(slotID))
+ return emptyString;
+ return _impl->_savegameInformations[slotID].filename;
}
-// -----------------------------------------------------------------------------
-
-bool PersistenceService::SaveGame(uint SlotID, const Common::String &ScreenshotFilename) {
+bool PersistenceService::saveGame(uint slotID, const Common::String &screenshotFilename) {
// Ü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);
+ 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);
return false;
}
// Dateinamen erzeugen.
- Common::String Filename = GenerateSavegameFilename(SlotID);
+ Common::String filename = generateSavegameFilename(slotID);
// Sicherstellen, dass das Verzeichnis für die Spielstanddateien existiert.
- FileSystemUtil::GetInstance().CreateDirectory(GetSavegameDirectory());
+ FileSystemUtil::getInstance().createDirectory(getSavegameDirectory());
// Spielstanddatei öffnen und die Headerdaten schreiben.
Common::SaveFileManager *sfm = g_system->getSavefileManager();
- Common::OutSaveFile *File = sfm->openForSaving(Filename);
+ Common::OutSaveFile *file = sfm->openForSaving(filename);
- File->writeString(FILE_MARKER);
- File->writeByte(' ');
- File->writeString(VERSIONID);
- File->writeByte(' ');
+ file->writeString(FILE_MARKER);
+ file->writeByte(' ');
+ file->writeString(VERSIONID);
+ file->writeByte(' ');
- if (File->err()) {
- error("Unable to write header data to savegame file \"%s\".", Filename.c_str());
+ if (file->err()) {
+ error("Unable to write header data to savegame file \"%s\".", filename.c_str());
}
// Alle notwendigen Module persistieren.
- OutputPersistenceBlock Writer;
- bool Success = true;
- Success &= Kernel::GetInstance()->GetScript()->persist(Writer);
- Success &= RegionRegistry::instance().persist(Writer);
- Success &= Kernel::GetInstance()->GetGfx()->persist(Writer);
- Success &= Kernel::GetInstance()->GetSfx()->persist(Writer);
- Success &= Kernel::GetInstance()->GetInput()->persist(Writer);
- if (!Success) {
- error("Unable to persist modules for savegame file \"%s\".", Filename.c_str());
+ OutputPersistenceBlock writer;
+ bool success = true;
+ success &= Kernel::getInstance()->getScript()->persist(writer);
+ success &= RegionRegistry::instance().persist(writer);
+ success &= Kernel::getInstance()->getGfx()->persist(writer);
+ success &= Kernel::getInstance()->getSfx()->persist(writer);
+ success &= Kernel::getInstance()->getInput()->persist(writer);
+ if (!success) {
+ error("Unable to persist modules for savegame file \"%s\".", filename.c_str());
}
// Daten komprimieren.
- uLongf CompressedLength = Writer.GetDataSize() + (Writer.GetDataSize() + 500) / 1000 + 12;
- Bytef *CompressionBuffer = new Bytef[CompressedLength];
+ uLongf compressedLength = writer.getDataSize() + (writer.getDataSize() + 500) / 1000 + 12;
+ Bytef *compressionBuffer = new Bytef[compressedLength];
- if (compress2(&CompressionBuffer[0], &CompressedLength, reinterpret_cast<const Bytef *>(Writer.GetData()), Writer.GetDataSize(), 6) != Z_OK) {
- error("Unable to compress savegame data in savegame file \"%s\".", Filename.c_str());
+ if (compress2(&compressionBuffer[0], &compressedLength, reinterpret_cast<const Bytef *>(writer.getData()), writer.getDataSize(), 6) != Z_OK) {
+ error("Unable to compress savegame data in savegame file \"%s\".", filename.c_str());
}
// Länge der komprimierten Daten und der unkomprimierten Daten in die Datei schreiben.
char sBuffer[10];
- snprintf(sBuffer, 10, "%ld", CompressedLength);
- File->writeString(sBuffer);
- File->writeByte(' ');
- snprintf(sBuffer, 10, "%u", Writer.GetDataSize());
- File->writeString(sBuffer);
- File->writeByte(' ');
+ snprintf(sBuffer, 10, "%ld", compressedLength);
+ file->writeString(sBuffer);
+ file->writeByte(' ');
+ snprintf(sBuffer, 10, "%u", writer.getDataSize());
+ file->writeString(sBuffer);
+ file->writeByte(' ');
// Komprimierte Daten in die Datei schreiben.
- File->write(reinterpret_cast<char *>(&CompressionBuffer[0]), CompressedLength);
- if (File->err()) {
- error("Unable to write game data to savegame file \"%s\".", Filename.c_str());
+ file->write(reinterpret_cast<char *>(&compressionBuffer[0]), compressedLength);
+ if (file->err()) {
+ error("Unable to write game data to savegame file \"%s\".", filename.c_str());
}
// Get the screenshot
- Common::MemoryReadStream *thumbnail = Kernel::GetInstance()->GetGfx()->getThumbnail();
+ Common::MemoryReadStream *thumbnail = Kernel::getInstance()->getGfx()->getThumbnail();
if (thumbnail) {
- byte *Buffer = new Byte[FILE_COPY_BUFFER_SIZE];
+ byte *buffer = new Byte[FILE_COPY_BUFFER_SIZE];
while (!thumbnail->eos()) {
- int bytesRead = thumbnail->read(&Buffer[0], FILE_COPY_BUFFER_SIZE);
- File->write(&Buffer[0], bytesRead);
+ int bytesRead = thumbnail->read(&buffer[0], FILE_COPY_BUFFER_SIZE);
+ file->write(&buffer[0], bytesRead);
}
- delete[] Buffer;
+ delete[] buffer;
} else {
- BS_LOG_WARNINGLN("The screenshot file \"%s\" does not exist. Savegame is written without a screenshot.", Filename.c_str());
+ BS_LOG_WARNINGLN("The screenshot file \"%s\" does not exist. Savegame is written without a screenshot.", filename.c_str());
}
// Savegameinformationen für diesen Slot aktualisieren.
- m_impl->ReadSlotSavegameInformation(SlotID);
+ _impl->readSlotSavegameInformation(slotID);
- File->finalize();
- delete File;
- delete[] CompressionBuffer;
+ file->finalize();
+ delete file;
+ delete[] compressionBuffer;
// Erfolg signalisieren.
return true;
}
-// -----------------------------------------------------------------------------
-
-bool PersistenceService::LoadGame(uint SlotID) {
+bool PersistenceService::loadGame(uint slotID) {
Common::SaveFileManager *sfm = g_system->getSavefileManager();
- Common::InSaveFile *File;
+ Common::InSaveFile *file;
// Ü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);
+ 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);
return false;
}
- SavegameInformation &CurSavegameInfo = m_impl->m_SavegameInformations[SlotID];
+ SavegameInformation &curSavegameInfo = _impl->_savegameInformations[slotID];
// Überprüfen, ob der Slot belegt ist.
- if (!CurSavegameInfo.IsOccupied) {
- BS_LOG_ERRORLN("Tried to load from an empty slot (%d).", SlotID);
+ if (!curSavegameInfo.isOccupied) {
+ BS_LOG_ERRORLN("Tried to load from an empty slot (%d).", slotID);
return false;
}
@@ -407,54 +358,54 @@ bool PersistenceService::LoadGame(uint SlotID) {
// Im Debug-Modus wird dieser Test übersprungen. Für das Testen ist es hinderlich auf die Einhaltung dieser strengen Bedingung zu bestehen,
// 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);
+ if (!curSavegameInfo.isCompatible) {
+ BS_LOG_ERRORLN("Tried to load a savegame (%d) that is not compatible with this engine version.", slotID);
return false;
}
#endif
- byte *CompressedDataBuffer = new byte[CurSavegameInfo.GamedataLength];
- byte *UncompressedDataBuffer = new Bytef[CurSavegameInfo.GamedataUncompressedLength];
+ byte *compressedDataBuffer = new byte[curSavegameInfo.gamedataLength];
+ byte *uncompressedDataBuffer = new Bytef[curSavegameInfo.gamedataUncompressedLength];
- File = sfm->openForLoading(GenerateSavegameFilename(SlotID));
+ file = sfm->openForLoading(generateSavegameFilename(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());
- delete[] CompressedDataBuffer;
- delete[] UncompressedDataBuffer;
+ 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());
+ delete[] compressedDataBuffer;
+ delete[] uncompressedDataBuffer;
return false;
}
// Spieldaten dekomprimieren.
- 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());
- delete[] UncompressedDataBuffer;
- delete[] CompressedDataBuffer;
- delete File;
+ 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());
+ delete[] uncompressedDataBuffer;
+ delete[] compressedDataBuffer;
+ delete file;
return false;
}
- InputPersistenceBlock Reader(&UncompressedDataBuffer[0], CurSavegameInfo.GamedataUncompressedLength);
+ InputPersistenceBlock reader(&uncompressedDataBuffer[0], curSavegameInfo.gamedataUncompressedLength);
// Einzelne Engine-Module depersistieren.
- bool Success = true;
- Success &= Kernel::GetInstance()->GetScript()->unpersist(Reader);
+ bool success = true;
+ success &= Kernel::getInstance()->getScript()->unpersist(reader);
// Muss unbedingt nach Script passieren. Da sonst die bereits wiederhergestellten Regions per Garbage-Collection gekillt werden.
- Success &= RegionRegistry::instance().unpersist(Reader);
- Success &= Kernel::GetInstance()->GetGfx()->unpersist(Reader);
- Success &= Kernel::GetInstance()->GetSfx()->unpersist(Reader);
- Success &= Kernel::GetInstance()->GetInput()->unpersist(Reader);
+ success &= RegionRegistry::instance().unpersist(reader);
+ success &= Kernel::getInstance()->getGfx()->unpersist(reader);
+ success &= Kernel::getInstance()->getSfx()->unpersist(reader);
+ success &= Kernel::getInstance()->getInput()->unpersist(reader);
- delete[] CompressedDataBuffer;
- delete[] UncompressedDataBuffer;
- delete File;
+ delete[] compressedDataBuffer;
+ delete[] uncompressedDataBuffer;
+ delete file;
- if (!Success) {
- BS_LOG_ERRORLN("Unable to unpersist the gamedata from savegame file \"%s\".", CurSavegameInfo.Filename.c_str());
+ if (!success) {
+ BS_LOG_ERRORLN("Unable to unpersist the gamedata from savegame file \"%s\".", curSavegameInfo.filename.c_str());
return false;
}
diff --git a/engines/sword25/kernel/persistenceservice.h b/engines/sword25/kernel/persistenceservice.h
index d14185eac2..c06cae6096 100644
--- a/engines/sword25/kernel/persistenceservice.h
+++ b/engines/sword25/kernel/persistenceservice.h
@@ -35,18 +35,10 @@
#ifndef SWORD25_PERSISTENCESERVICE_H
#define SWORD25_PERSISTENCESERVICE_H
-// -----------------------------------------------------------------------------
-// Includes
-// -----------------------------------------------------------------------------
-
#include "sword25/kernel/common.h"
namespace Sword25 {
-// -----------------------------------------------------------------------------
-// Class declaration
-// -----------------------------------------------------------------------------
-
class PersistenceService {
public:
PersistenceService();
@@ -56,27 +48,27 @@ public:
// Singleton Method
// -----------------------------------------------------------------------------
- static PersistenceService &GetInstance();
+ static PersistenceService &getInstance();
// -----------------------------------------------------------------------------
// Interface
// -----------------------------------------------------------------------------
- static uint GetSlotCount();
- static Common::String GetSavegameDirectory();
+ static uint getSlotCount();
+ static Common::String getSavegameDirectory();
- void ReloadSlots();
- bool IsSlotOccupied(uint SlotID);
- bool IsSavegameCompatible(uint SlotID);
- Common::String &GetSavegameDescription(uint SlotID);
- Common::String &GetSavegameFilename(uint SlotID);
+ void reloadSlots();
+ bool isSlotOccupied(uint slotID);
+ bool isSavegameCompatible(uint slotID);
+ Common::String &getSavegameDescription(uint slotID);
+ Common::String &getSavegameFilename(uint slotID);
- bool SaveGame(uint SlotID, const Common::String &ScreenshotFilename);
- bool LoadGame(uint SlotID);
+ bool saveGame(uint slotID, const Common::String &screenshotFilename);
+ bool loadGame(uint slotID);
private:
struct Impl;
- Impl *m_impl;
+ Impl *_impl;
};
} // End of namespace Sword25
diff --git a/engines/sword25/kernel/resmanager.cpp b/engines/sword25/kernel/resmanager.cpp
index 0374acf307..c2ecb04a6f 100644
--- a/engines/sword25/kernel/resmanager.cpp
+++ b/engines/sword25/kernel/resmanager.cpp
@@ -45,20 +45,20 @@ namespace Sword25 {
ResourceManager::~ResourceManager() {
// Clear all unlocked resources
- EmptyCache();
+ emptyCache();
// All remaining resources are not released, so print warnings and release
- Common::List<Resource *>::iterator Iter = m_Resources.begin();
- for (; Iter != m_Resources.end(); ++Iter) {
- BS_LOG_WARNINGLN("Resource \"%s\" was not released.", (*Iter)->getFileName().c_str());
+ Common::List<Resource *>::iterator iter = _resources.begin();
+ for (; iter != _resources.end(); ++iter) {
+ BS_LOG_WARNINGLN("Resource \"%s\" was not released.", (*iter)->getFileName().c_str());
// Set the lock count to zero
- while ((*Iter)->GetLockCount() > 0) {
- (*Iter)->release();
+ while ((*iter)->getLockCount() > 0) {
+ (*iter)->release();
};
// Delete the resource
- delete(*Iter);
+ delete(*iter);
}
}
@@ -67,19 +67,19 @@ ResourceManager::~ResourceManager() {
* Note: This method is not optimised for speed and should be used only for debugging purposes
* @param Ord Ordinal number of the resource. Must be between 0 and GetResourceCount() - 1.
*/
-Resource *ResourceManager::GetResourceByOrdinal(int Ord) const {
+Resource *ResourceManager::getResourceByOrdinal(int ord) const {
// Überprüfen ob der Index Ord innerhald der Listengrenzen liegt.
- if (Ord < 0 || Ord >= GetResourceCount()) {
- BS_LOG_ERRORLN("Resource ordinal (%d) out of bounds (0 - %d).", Ord, GetResourceCount() - 1);
+ if (ord < 0 || ord >= getResourceCount()) {
+ BS_LOG_ERRORLN("Resource ordinal (%d) out of bounds (0 - %d).", ord, getResourceCount() - 1);
return NULL;
}
// Liste durchlaufen und die Resource mit dem gewünschten Index zurückgeben.
- int CurOrd = 0;
- Common::List<Resource *>::const_iterator Iter = m_Resources.begin();
- for (; Iter != m_Resources.end(); ++Iter, ++CurOrd) {
- if (CurOrd == Ord)
- return (*Iter);
+ int curOrd = 0;
+ Common::List<Resource *>::const_iterator iter = _resources.begin();
+ for (; iter != _resources.end(); ++iter, ++curOrd) {
+ if (curOrd == ord)
+ return (*iter);
}
// Die Ausführung sollte nie an diesem Punkt ankommen.
@@ -92,13 +92,13 @@ Resource *ResourceManager::GetResourceByOrdinal(int Ord) const {
* BS_ResourceService, and thus helps all resource services in the ResourceManager list
* @param pService Which service
*/
-bool ResourceManager::RegisterResourceService(ResourceService *pService) {
+bool ResourceManager::registerResourceService(ResourceService *pService) {
if (!pService) {
BS_LOG_ERRORLN("Can't register NULL resource service.");
return false;
}
- m_ResourceServices.push_back(pService);
+ _resourceServices.push_back(pService);
return true;
}
@@ -106,34 +106,36 @@ bool ResourceManager::RegisterResourceService(ResourceService *pService) {
/**
* Deletes resources as necessary until the specified memory limit is not being exceeded.
*/
-void ResourceManager::DeleteResourcesIfNecessary() {
+void ResourceManager::deleteResourcesIfNecessary() {
// If enough memory is available, or no resources are loaded, then the function can immediately end
- if (m_KernelPtr->GetUsedMemory() < m_MaxMemoryUsage || m_Resources.empty()) return;
+ if (_kernelPtr->getUsedMemory() < _maxMemoryUsage || _resources.empty())
+ return;
// Keep deleting resources until the memory usage of the process falls below the set maximum limit.
// The list is processed backwards in order to first release those resources who have been
// not been accessed for the longest
- Common::List<Resource *>::iterator Iter = m_Resources.end();
+ Common::List<Resource *>::iterator iter = _resources.end();
do {
- --Iter;
+ --iter;
// The resource may be released only if it isn't locked
- if ((*Iter)->GetLockCount() == 0) Iter = DeleteResource(*Iter);
- } while (Iter != m_Resources.begin() && m_KernelPtr->GetUsedMemory() > m_MaxMemoryUsage);
+ if ((*iter)->getLockCount() == 0)
+ iter = deleteResource(*iter);
+ } while (iter != _resources.begin() && _kernelPtr->getUsedMemory() > _maxMemoryUsage);
}
/**
* Releases all resources that are not locked.
**/
-void ResourceManager::EmptyCache() {
+void ResourceManager::emptyCache() {
// Scan through the resource list
- Common::List<Resource *>::iterator Iter = m_Resources.begin();
- while (Iter != m_Resources.end()) {
- if ((*Iter)->GetLockCount() == 0) {
+ Common::List<Resource *>::iterator iter = _resources.begin();
+ while (iter != _resources.end()) {
+ if ((*iter)->getLockCount() == 0) {
// Delete the resource
- Iter = DeleteResource(*Iter);
+ iter = deleteResource(*iter);
} else
- ++Iter;
+ ++iter;
}
}
@@ -141,29 +143,30 @@ void ResourceManager::EmptyCache() {
* Returns a requested resource. If any error occurs, returns NULL
* @param FileName Filename of resource
*/
-Resource *ResourceManager::RequestResource(const Common::String &FileName) {
+Resource *ResourceManager::requestResource(const Common::String &fileName) {
// Get the absolute path to the file
- Common::String UniqueFileName = GetUniqueFileName(FileName);
- if (UniqueFileName == "")
+ Common::String uniqueFileName = getUniqueFileName(fileName);
+ if (uniqueFileName == "")
return NULL;
// Determine whether the resource is already loaded
// If the resource is found, it will be placed at the head of the resource list and returned
{
- Resource *pResource = GetResource(UniqueFileName);
+ Resource *pResource = getResource(uniqueFileName);
if (pResource) {
- MoveToFront(pResource);
- (pResource)->AddReference();
+ moveToFront(pResource);
+ (pResource)->addReference();
return pResource;
}
}
// The resource was not found, therefore, must not be loaded yet
- if (m_LogCacheMiss) BS_LOG_WARNINGLN("\"%s\" was not precached.", UniqueFileName.c_str());
+ if (_logCacheMiss)
+ BS_LOG_WARNINGLN("\"%s\" was not precached.", uniqueFileName.c_str());
Resource *pResource;
- if ((pResource = loadResource(UniqueFileName))) {
- pResource->AddReference();
+ if ((pResource = loadResource(uniqueFileName))) {
+ pResource->addReference();
return pResource;
}
@@ -176,26 +179,26 @@ Resource *ResourceManager::RequestResource(const Common::String &FileName) {
* @param ForceReload Indicates whether the file should be reloaded if it's already in the cache.
* This is useful for files that may have changed in the interim
*/
-bool ResourceManager::PrecacheResource(const Common::String &FileName, bool ForceReload) {
+bool ResourceManager::precacheResource(const Common::String &fileName, bool forceReload) {
// Get the absolute path to the file
- Common::String UniqueFileName = GetUniqueFileName(FileName);
- if (UniqueFileName == "")
+ Common::String uniqueFileName = getUniqueFileName(fileName);
+ if (uniqueFileName == "")
return false;
- Resource *ResourcePtr = GetResource(UniqueFileName);
+ Resource *resourcePtr = getResource(uniqueFileName);
- if (ForceReload && ResourcePtr) {
- if (ResourcePtr->GetLockCount()) {
- BS_LOG_ERRORLN("Could not force precaching of \"%s\". The resource is locked.", FileName.c_str());
+ if (forceReload && resourcePtr) {
+ if (resourcePtr->getLockCount()) {
+ BS_LOG_ERRORLN("Could not force precaching of \"%s\". The resource is locked.", fileName.c_str());
return false;
} else {
- DeleteResource(ResourcePtr);
- ResourcePtr = 0;
+ deleteResource(resourcePtr);
+ resourcePtr = 0;
}
}
- if (!ResourcePtr && loadResource(UniqueFileName) == NULL) {
- BS_LOG_ERRORLN("Could not precache \"%s\",", FileName.c_str());
+ if (!resourcePtr && loadResource(uniqueFileName) == NULL) {
+ BS_LOG_ERRORLN("Could not precache \"%s\",", fileName.c_str());
return false;
}
@@ -206,13 +209,13 @@ bool ResourceManager::PrecacheResource(const Common::String &FileName, bool Forc
* Moves a resource to the top of the resource list
* @param pResource The resource
*/
-void ResourceManager::MoveToFront(Resource *pResource) {
+void ResourceManager::moveToFront(Resource *pResource) {
// Erase the resource from it's current position
- m_Resources.erase(pResource->_iterator);
+ _resources.erase(pResource->_iterator);
// Re-add the resource at the front of the list
- m_Resources.push_front(pResource);
+ _resources.push_front(pResource);
// Reset the resource iterator to the repositioned item
- pResource->_iterator = m_Resources.begin();
+ pResource->_iterator = _resources.begin();
}
/**
@@ -223,24 +226,24 @@ void ResourceManager::MoveToFront(Resource *pResource) {
*/
Resource *ResourceManager::loadResource(const Common::String &fileName) {
// ResourceService finden, der die Resource laden kann.
- for (uint i = 0; i < m_ResourceServices.size(); ++i) {
- if (m_ResourceServices[i]->canLoadResource(fileName)) {
+ for (uint i = 0; i < _resourceServices.size(); ++i) {
+ if (_resourceServices[i]->canLoadResource(fileName)) {
// If more memory is desired, memory must be released
- DeleteResourcesIfNecessary();
+ deleteResourcesIfNecessary();
// Load the resource
Resource *pResource;
- if (!(pResource = m_ResourceServices[i]->loadResource(fileName))) {
+ if (!(pResource = _resourceServices[i]->loadResource(fileName))) {
BS_LOG_ERRORLN("Responsible service could not load resource \"%s\".", fileName.c_str());
return NULL;
}
// Add the resource to the front of the list
- m_Resources.push_front(pResource);
- pResource->_iterator = m_Resources.begin();
+ _resources.push_front(pResource);
+ pResource->_iterator = _resources.begin();
// Also store the resource in the hash table for quick lookup
- m_ResourceHashTable[pResource->GetFileNameHash() % HASH_TABLE_BUCKETS].push_front(pResource);
+ _resourceHashTable[pResource->getFileNameHash() % HASH_TABLE_BUCKETS].push_front(pResource);
return pResource;
}
@@ -254,56 +257,55 @@ Resource *ResourceManager::loadResource(const Common::String &fileName) {
* Returns the full path of a given resource filename.
* It will return an empty string if a path could not be created.
*/
-Common::String ResourceManager::GetUniqueFileName(const Common::String &FileName) const {
+Common::String ResourceManager::getUniqueFileName(const Common::String &fileName) const {
// Get a pointer to the package manager
- PackageManager *pPackage = (PackageManager *)m_KernelPtr->GetPackage();
+ PackageManager *pPackage = (PackageManager *)_kernelPtr->getPackage();
if (!pPackage) {
BS_LOG_ERRORLN("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 == "")
- BS_LOG_ERRORLN("Could not create absolute file name for \"%s\".", FileName.c_str());
+ Common::String uniquefileName = pPackage->getAbsolutePath(fileName);
+ if (uniquefileName == "")
+ BS_LOG_ERRORLN("Could not create absolute file name for \"%s\".", fileName.c_str());
- return UniqueFileName;
+ return uniquefileName;
}
/**
* Deletes a resource, removes it from the lists, and updates m_UsedMemory
*/
-Common::List<Resource *>::iterator ResourceManager::DeleteResource(Resource *pResource) {
+Common::List<Resource *>::iterator ResourceManager::deleteResource(Resource *pResource) {
// Remove the resource from the hash table
- m_ResourceHashTable[pResource->GetFileNameHash() % HASH_TABLE_BUCKETS].remove(pResource);
+ _resourceHashTable[pResource->getFileNameHash() % HASH_TABLE_BUCKETS].remove(pResource);
Resource *pDummy = pResource;
// Delete the resource from the resource list
- Common::List<Resource *>::iterator Result = m_Resources.erase(pResource->_iterator);
+ Common::List<Resource *>::iterator result = _resources.erase(pResource->_iterator);
// Delete the resource
delete(pDummy);
// Return the iterator
- return Result;
+ return result;
}
/**
* Returns a pointer to a loaded resource. If any error occurs, NULL will be returned.
- * @param UniqueFileName The absolute path and filename
+ * @param UniquefileName The absolute path and filename
* Gibt einen Pointer auf die angeforderte Resource zurück, oder NULL, wenn die Resourcen nicht geladen ist.
*/
-Resource *ResourceManager::GetResource(const Common::String &UniqueFileName) const {
+Resource *ResourceManager::getResource(const Common::String &uniquefileName) const {
// Determine whether the resource is already loaded
- const Common::List<Resource *>& HashBucket = m_ResourceHashTable[
- BS_String::GetHash(UniqueFileName) % HASH_TABLE_BUCKETS];
+ const Common::List<Resource *>& hashBucket = _resourceHashTable[BS_String::getHash(uniquefileName) % HASH_TABLE_BUCKETS];
{
- Common::List<Resource *>::const_iterator Iter = HashBucket.begin();
- for (; Iter != HashBucket.end(); ++Iter) {
+ Common::List<Resource *>::const_iterator iter = hashBucket.begin();
+ for (; iter != hashBucket.end(); ++iter) {
// Wenn die Resource gefunden wurde wird sie zurückgegeben.
- if ((*Iter)->getFileName() == UniqueFileName)
- return *Iter;
+ if ((*iter)->getFileName() == uniquefileName)
+ return *iter;
}
}
@@ -314,10 +316,10 @@ Resource *ResourceManager::GetResource(const Common::String &UniqueFileName) con
/**
* Writes the names of all currently locked resources to the log file
*/
-void ResourceManager::DumpLockedResources() {
- for (Common::List<Resource *>::iterator Iter = m_Resources.begin(); Iter != m_Resources.end(); ++Iter) {
- if ((*Iter)->GetLockCount() > 0) {
- BS_LOGLN("%s", (*Iter)->getFileName().c_str());
+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());
}
}
}
@@ -328,9 +330,9 @@ void ResourceManager::DumpLockedResources() {
* as a guideline, and not as a fixed boundary. It is not guaranteed not to be exceeded;
* the whole game engine may still use more memory than any amount specified.
*/
-void ResourceManager::SetMaxMemoryUsage(uint MaxMemoryUsage) {
- m_MaxMemoryUsage = MaxMemoryUsage;
- DeleteResourcesIfNecessary();
+void ResourceManager::setMaxMemoryUsage(uint maxMemoryUsage) {
+ _maxMemoryUsage = maxMemoryUsage;
+ deleteResourcesIfNecessary();
}
} // End of namespace Sword25
diff --git a/engines/sword25/kernel/resmanager.h b/engines/sword25/kernel/resmanager.h
index 940a04147b..7f438bb709 100644
--- a/engines/sword25/kernel/resmanager.h
+++ b/engines/sword25/kernel/resmanager.h
@@ -35,14 +35,12 @@
#ifndef SWORD25_RESOURCEMANAGER_H
#define SWORD25_RESOURCEMANAGER_H
-// Includes
#include "common/list.h"
#include "sword25/kernel/common.h"
namespace Sword25 {
-// Class definitions
class ResourceService;
class Resource;
class Kernel;
@@ -55,7 +53,7 @@ public:
* Returns a requested resource. If any error occurs, returns NULL
* @param FileName Filename of resource
*/
- Resource *RequestResource(const Common::String &FileName);
+ Resource *requestResource(const Common::String &fileName);
/**
* Loads a resource into the cache
@@ -63,13 +61,13 @@ public:
* @param ForceReload Indicates whether the file should be reloaded if it's already in the cache.
* This is useful for files that may have changed in the interim
*/
- bool PrecacheResource(const Common::String &FileName, bool ForceReload = false);
+ bool precacheResource(const Common::String &fileName, bool forceReload = false);
/**
* Returns the number of loaded resources
*/
- int GetResourceCount() const {
- return static_cast<int>(m_Resources.size());
+ int getResourceCount() const {
+ return static_cast<int>(_resources.size());
}
/**
@@ -77,25 +75,25 @@ public:
* Note: This method is not optimised for speed and should be used only for debugging purposes
* @param Ord Ordinal number of the resource. Must be between 0 and GetResourceCount() - 1.
*/
- Resource *GetResourceByOrdinal(int Ord) const;
+ Resource *getResourceByOrdinal(int ord) const;
/**
* Registers a RegisterResourceService. This method is the constructor of
* BS_ResourceService, and thus helps all resource services in the ResourceManager list
* @param pService Which service
*/
- bool RegisterResourceService(ResourceService *pService);
+ bool registerResourceService(ResourceService *pService);
/**
* Releases all resources that are not locked.
**/
- void EmptyCache();
+ void emptyCache();
/**
* Returns the maximum memory the kernel has used
*/
- int GetMaxMemoryUsage() const {
- return m_MaxMemoryUsage;
+ int getMaxMemoryUsage() const {
+ return _maxMemoryUsage;
}
/**
@@ -104,28 +102,28 @@ public:
* as a guideline, and not as a fixed boundary. It is not guaranteed not to be exceeded;
* the whole game engine may still use more memory than any amount specified.
*/
- void SetMaxMemoryUsage(uint MaxMemoryUsage);
+ void setMaxMemoryUsage(uint maxMemoryUsage);
/**
* Specifies whether a warning is written to the log when a cache miss occurs.
* THe default value is "false".
*/
- bool IsLogCacheMiss() const {
- return m_LogCacheMiss;
+ bool isLogCacheMiss() const {
+ return _logCacheMiss;
}
/**
* Sets whether warnings are written to the log if a cache miss occurs.
* @param Flag If "true", then future warnings will be logged
*/
- void SetLogCacheMiss(bool Flag) {
- m_LogCacheMiss = Flag;
+ void setLogCacheMiss(bool flag) {
+ _logCacheMiss = flag;
}
/**
* Writes the names of all currently locked resources to the log file
*/
- void DumpLockedResources();
+ void dumpLockedResources();
private:
/**
@@ -133,9 +131,9 @@ private:
* Only the BS_Kernel class can generate copies this class. Thus, the constructor is private
*/
ResourceManager(Kernel *pKernel) :
- m_KernelPtr(pKernel),
- m_MaxMemoryUsage(100000000),
- m_LogCacheMiss(false)
+ _kernelPtr(pKernel),
+ _maxMemoryUsage(100000000),
+ _logCacheMiss(false)
{}
virtual ~ResourceManager();
@@ -147,7 +145,7 @@ private:
* Moves a resource to the top of the resource list
* @param pResource The resource
*/
- void MoveToFront(Resource *pResource);
+ void moveToFront(Resource *pResource);
/**
* Loads a resource and updates the m_UsedMemory total
@@ -161,31 +159,31 @@ private:
* Returns the full path of a given resource filename.
* It will return an empty string if a path could not be created.
*/
- Common::String GetUniqueFileName(const Common::String &FileName) const;
+ Common::String getUniqueFileName(const Common::String &fileName) const;
/**
* Deletes a resource, removes it from the lists, and updates m_UsedMemory
*/
- Common::List<Resource *>::iterator DeleteResource(Resource *pResource);
+ Common::List<Resource *>::iterator deleteResource(Resource *pResource);
/**
* Returns a pointer to a loaded resource. If any error occurs, NULL will be returned.
* @param UniqueFileName The absolute path and filename
* Gibt einen Pointer auf die angeforderte Resource zurück, oder NULL, wenn die Resourcen nicht geladen ist.
*/
- Resource *GetResource(const Common::String &UniqueFileName) const;
+ Resource *getResource(const Common::String &uniqueFileName) const;
/**
* Deletes resources as necessary until the specified memory limit is not being exceeded.
*/
- void DeleteResourcesIfNecessary();
-
- Kernel *m_KernelPtr;
- uint m_MaxMemoryUsage;
- Common::Array<ResourceService *> m_ResourceServices;
- Common::List<Resource *> m_Resources;
- Common::List<Resource *> m_ResourceHashTable[HASH_TABLE_BUCKETS];
- bool m_LogCacheMiss;
+ void deleteResourcesIfNecessary();
+
+ Kernel *_kernelPtr;
+ uint _maxMemoryUsage;
+ Common::Array<ResourceService *> _resourceServices;
+ Common::List<Resource *> _resources;
+ Common::List<Resource *> _resourceHashTable[HASH_TABLE_BUCKETS];
+ bool _logCacheMiss;
};
} // End of namespace Sword25
diff --git a/engines/sword25/kernel/resource.cpp b/engines/sword25/kernel/resource.cpp
index 3ae4bee98a..aa1f3bc1f6 100644
--- a/engines/sword25/kernel/resource.cpp
+++ b/engines/sword25/kernel/resource.cpp
@@ -44,11 +44,11 @@ namespace Sword25 {
Resource::Resource(const Common::String &fileName, RESOURCE_TYPES type) :
_type(type),
_refCount(0) {
- PackageManager *pPM = Kernel::GetInstance()->GetPackage();
+ PackageManager *pPM = Kernel::getInstance()->getPackage();
BS_ASSERT(pPM);
_fileName = pPM->getAbsolutePath(fileName);
- _fileNameHash = BS_String::GetHash(fileName);
+ _fileNameHash = BS_String::getHash(fileName);
}
void Resource::release() {
diff --git a/engines/sword25/kernel/resource.h b/engines/sword25/kernel/resource.h
index 6d77c3dd6e..27003641dd 100644
--- a/engines/sword25/kernel/resource.h
+++ b/engines/sword25/kernel/resource.h
@@ -62,7 +62,7 @@ public:
* Prevents the resource from being released.
* @remarks This method allows a resource to be locked multiple times.
**/
- void AddReference() {
+ void addReference() {
++_refCount;
}
@@ -77,7 +77,7 @@ public:
* Returns the current lock count for the resource
* @return The current lock count
**/
- int GetLockCount() const {
+ int getLockCount() const {
return _refCount;
}
@@ -91,14 +91,14 @@ public:
/**
* Returns the hash of the filename of a resource
*/
- uint GetFileNameHash() const {
+ uint getFileNameHash() const {
return _fileNameHash;
}
/**
* Returns a resource's type
*/
- uint GetType() const {
+ uint getType() const {
return _type;
}
@@ -106,10 +106,10 @@ protected:
virtual ~Resource() {}
private:
- Common::String _fileName; ///< The absolute filename
- uint _fileNameHash; ///< The hash value of the filename
- uint _refCount; ///< The number of locks
- uint _type; ///< The type of the resource
+ Common::String _fileName; ///< The absolute filename
+ uint _fileNameHash; ///< The hash value of the filename
+ uint _refCount; ///< The number of locks
+ uint _type; ///< The type of the resource
Common::List<Resource *>::iterator _iterator; ///< Points to the resource position in the LRU list
};
diff --git a/engines/sword25/kernel/resservice.h b/engines/sword25/kernel/resservice.h
index d5961d52ae..a0f2669231 100644
--- a/engines/sword25/kernel/resservice.h
+++ b/engines/sword25/kernel/resservice.h
@@ -35,7 +35,6 @@
#ifndef SWORD25_RESOURCESERVICE_H
#define SWORD25_RESOURCESERVICE_H
-// Includes
#include "sword25/kernel/common.h"
#include "sword25/kernel/service.h"
#include "sword25/kernel/kernel.h"
@@ -48,8 +47,8 @@ class Resource;
class ResourceService : public Service {
public:
ResourceService(Kernel *pKernel) : Service(pKernel) {
- ResourceManager *pResource = pKernel->GetResourceManager();
- pResource->RegisterResourceService(this);
+ ResourceManager *pResource = pKernel->getResourceManager();
+ pResource->registerResourceService(this);
}
virtual ~ResourceService() {}
diff --git a/engines/sword25/kernel/scummvmwindow.cpp b/engines/sword25/kernel/scummvmwindow.cpp
index 35fd27a05c..8669280da3 100644
--- a/engines/sword25/kernel/scummvmwindow.cpp
+++ b/engines/sword25/kernel/scummvmwindow.cpp
@@ -43,31 +43,31 @@
namespace Sword25 {
-bool ScummVMWindow::_ClassRegistered = false;
+bool ScummVMWindow::_classRegistered = false;
// Constructor / Destructor
// ------------------------
-ScummVMWindow::ScummVMWindow(int X, int Y, int Width, int Height, bool Visible) {
+ScummVMWindow::ScummVMWindow(int x, int y, int width, int height, bool visible) {
// Presume that init will fail
- _InitSuccess = false;
+ _initSuccess = false;
// We don't support any window creation except at the origin 0,0
- assert(X == 0);
- assert(Y == 0);
+ assert(x == 0);
+ assert(y == 0);
- if (!_ClassRegistered) {
+ if (!_classRegistered) {
// Nothing here currently
- _ClassRegistered = true;
+ _classRegistered = true;
}
// Fenstersichtbarkeit setzen
- SetVisible(Visible);
+ setVisible(visible);
// Indicate success
- _InitSuccess = true;
- _WindowAlive = true;
- _CloseWanted = false;
+ _initSuccess = true;
+ _windowAlive = true;
+ _closeWanted = false;
}
ScummVMWindow::~ScummVMWindow() {
@@ -75,86 +75,86 @@ ScummVMWindow::~ScummVMWindow() {
// Get Methods
// ------------
-int ScummVMWindow::GetX() {
+int ScummVMWindow::getX() {
return 0;
}
-int ScummVMWindow::GetY() {
+int ScummVMWindow::getY() {
return 0;
}
-int ScummVMWindow::GetClientX() {
+int ScummVMWindow::getClientX() {
return 0;
}
-int ScummVMWindow::GetClientY() {
+int ScummVMWindow::getClientY() {
return 0;
}
-int ScummVMWindow::GetWidth() {
+int ScummVMWindow::getWidth() {
return g_system->getWidth();
}
-int ScummVMWindow::GetHeight() {
+int ScummVMWindow::getHeight() {
return g_system->getHeight();
}
-Common::String ScummVMWindow::GetTitle() {
+Common::String ScummVMWindow::getTitle() {
return Common::String("");
}
-bool ScummVMWindow::IsVisible() {
+bool ScummVMWindow::isVisible() {
return true;
}
-bool ScummVMWindow::HasFocus() {
+bool ScummVMWindow::hasFocus() {
// FIXME: Is there a way to tell if ScummVM has the focus in Windowed mode?
return true;
}
-uint ScummVMWindow::GetWindowHandle() {
+uint ScummVMWindow::getWindowHandle() {
return 0;
}
-void ScummVMWindow::SetWindowAlive(bool v) {
- _WindowAlive = v;
+void ScummVMWindow::setWindowAlive(bool v) {
+ _windowAlive = v;
}
// Set Methods
// ------------
-void ScummVMWindow::SetX(int X) {
+void ScummVMWindow::setX(int X) {
// No implementation
}
-void ScummVMWindow::SetY(int Y) {
+void ScummVMWindow::setY(int Y) {
// No implementation
}
-void ScummVMWindow::SetWidth(int Width) {
+void ScummVMWindow::setWidth(int width) {
// No implementation
}
-void ScummVMWindow::SetHeight(int Height) {
+void ScummVMWindow::setHeight(int height) {
// No implementation
}
-void ScummVMWindow::SetVisible(bool Visible) {
+void ScummVMWindow::setVisible(bool visible) {
// No implementation
}
-void ScummVMWindow::SetTitle(const Common::String &Title) {
+void ScummVMWindow::setTitle(const Common::String &title) {
// No implementation
}
-bool ScummVMWindow::ProcessMessages() {
+bool ScummVMWindow::processMessages() {
// All messages are handled separately in the input manager. The only thing we
// need to do here is to keep returning whether the window/game is still alive
- return _WindowAlive;
+ return _windowAlive;
}
-bool ScummVMWindow::WaitForFocus() {
+bool ScummVMWindow::waitForFocus() {
// No implementation
return true;
}
diff --git a/engines/sword25/kernel/scummvmwindow.h b/engines/sword25/kernel/scummvmwindow.h
index 2b5f514b7d..3c8c1a4f3c 100644
--- a/engines/sword25/kernel/scummvmwindow.h
+++ b/engines/sword25/kernel/scummvmwindow.h
@@ -41,43 +41,41 @@
#ifndef SWORD25_SCUMMVMWINDOW_H
#define SWORD25_SCUMMVMWINDOW_H
-// Includes
#include "sword25/kernel/common.h"
#include "sword25/kernel/window.h"
namespace Sword25 {
-// Class definition
class ScummVMWindow : public Window {
public:
- ScummVMWindow(int X, int Y, int Width, int Height, bool Visible);
+ ScummVMWindow(int x, int y, int width, int height, bool visible);
virtual ~ScummVMWindow();
- bool IsVisible();
- void SetVisible(bool Visible);
- int GetX();
- void SetX(int X);
- int GetY();
- void SetY(int X);
- int GetClientX();
- int GetClientY();
- int GetWidth();
- void SetWidth(int Width);
- int GetHeight();
- void SetHeight(int Height);
- Common::String GetTitle();
- void SetWindowAlive(bool v);
- void SetTitle(const Common::String &Title);
- bool HasFocus();
- uint GetWindowHandle();
- bool WaitForFocus();
- bool ProcessMessages();
+ bool isVisible();
+ void setVisible(bool visible);
+ int getX();
+ void setX(int x);
+ int getY();
+ void setY(int x);
+ int getClientX();
+ int getClientY();
+ int getWidth();
+ void setWidth(int width);
+ int getHeight();
+ void setHeight(int height);
+ Common::String getTitle();
+ void setWindowAlive(bool v);
+ void setTitle(const Common::String &title);
+ bool hasFocus();
+ uint getWindowHandle();
+ bool waitForFocus();
+ bool processMessages();
private:
- static bool _ClassRegistered;
- bool _WindowAlive;
- int _ClientXDelta;
- int _ClientYDelta;
+ static bool _classRegistered;
+ bool _windowAlive;
+ int _clientXDelta;
+ int _clientYDelta;
};
} // End of namespace Sword25
diff --git a/engines/sword25/kernel/service_ids.h b/engines/sword25/kernel/service_ids.h
index 2552d279cc..b5ffaef16c 100644
--- a/engines/sword25/kernel/service_ids.h
+++ b/engines/sword25/kernel/service_ids.h
@@ -81,7 +81,6 @@ const BS_ServiceInfo BS_SERVICE_TABLE[] = {
{ "fmv", "oggtheora", OggTheora_CreateObject }
};
-
} // End of namespace Sword25
#endif
diff --git a/engines/sword25/kernel/string.h b/engines/sword25/kernel/string.h
index b701e2312b..948c5f31e4 100644
--- a/engines/sword25/kernel/string.h
+++ b/engines/sword25/kernel/string.h
@@ -39,71 +39,75 @@
namespace BS_String {
-inline uint GetHash(const Common::String &Str) {
- uint Result = 0;
+inline uint getHash(const Common::String &str) {
+ uint result = 0;
- for (uint i = 0; i < Str.size(); i++)
- Result = ((Result << 5) - Result) + Str[i];
+ for (uint i = 0; i < str.size(); i++)
+ result = ((result << 5) - result) + str[i];
- return Result;
+ return result;
}
-inline bool ToInt(const Common::String &Str, int &Result) {
- Common::String::const_iterator Iter = Str.begin();
+inline bool toInt(const Common::String &str, int &result) {
+ Common::String::const_iterator iter = str.begin();
// Skip whitespaces
- while (*Iter && (*Iter == ' ' || *Iter == '\t')) {
- ++Iter;
+ while (*iter && (*iter == ' ' || *iter == '\t')) {
+ ++iter;
}
- if (Iter == Str.end()) return false;
+ if (iter == str.end())
+ return false;
// Read sign, if available
- bool IsNegative = false;
- if (*Iter == '-') {
- IsNegative = true;
- ++Iter;
- } else if (*Iter == '+')
- ++Iter;
+ bool isNegative = false;
+ if (*iter == '-') {
+ isNegative = true;
+ ++iter;
+ } else if (*iter == '+')
+ ++iter;
// Skip whitespaces
- while (*Iter && (*Iter == ' ' || *Iter == '\t')) {
- ++Iter;
+ while (*iter && (*iter == ' ' || *iter == '\t')) {
+ ++iter;
}
- if (Iter == Str.end()) return false;
+ if (iter == str.end())
+ return false;
// Convert string to integer
- Result = 0;
- while (Iter != Str.end()) {
- if (*Iter < '0' || *Iter > '9') {
- while (*Iter && (*Iter == ' ' || *Iter == '\t')) {
- ++Iter;
+ result = 0;
+ while (iter != str.end()) {
+ if (*iter < '0' || *iter > '9') {
+ while (*iter && (*iter == ' ' || *iter == '\t')) {
+ ++iter;
}
- if (Iter != Str.end()) return false;
+ if (iter != str.end())
+ return false;
break;
}
- Result = (Result * 10) + (*Iter - '0');
- ++Iter;
+ result = (result * 10) + (*iter - '0');
+ ++iter;
}
- if (IsNegative) Result = -Result;
+ if (isNegative)
+ result = -result;
return true;
}
-inline bool ToBool(const Common::String &Str, bool &Result) {
- if (Str == "true" || Str == "TRUE") {
- Result = true;
+inline bool toBool(const Common::String &str, bool &result) {
+ if (str == "true" || str == "TRUE") {
+ result = true;
return true;
- } else if (Str == "false" || Str == "FALSE") {
- Result = false;
+ } else if (str == "false" || str == "FALSE") {
+ result = false;
return true;
}
return false;
}
-inline void ToLower(Common::String &Str) {
- Str.toLowercase();
+inline void toLower(Common::String &str) {
+ str.toLowercase();
}
} // End of namespace BS_String
diff --git a/engines/sword25/kernel/window.cpp b/engines/sword25/kernel/window.cpp
index 8d2dc309e7..84f1d9f87a 100644
--- a/engines/sword25/kernel/window.cpp
+++ b/engines/sword25/kernel/window.cpp
@@ -40,13 +40,13 @@
namespace Sword25 {
// Erstellt ein Fenster des GUI des aktuellen Betriebssystems
-Window *Window::CreateBSWindow(int X, int Y, int Width, int Height, bool Visible) {
+Window *Window::createBSWindow(int x, int y, int width, int height, bool visible) {
// Fenster erstellen
- Window *pWindow = (Window *) new ScummVMWindow(X, Y, Width, Height, Visible);
+ Window *pWindow = (Window *) new ScummVMWindow(x, y, width, height, visible);
// Falls das Fenster erfolgreich initialisiert wurde, wird ein Pointer auf das Fensterobjekt
// zurückgegeben
- if (pWindow->_InitSuccess)
+ if (pWindow->_initSuccess)
return pWindow;
// Ansonsten wird das Fensterobjekt zerstört und NULL zurückgegeben
@@ -56,14 +56,14 @@ Window *Window::CreateBSWindow(int X, int Y, int Width, int Height, bool Visible
// Gibt True zurück wenn das Fenster WM_CLOSE empfangen hat -
// solange, bis RejectClose() aufgerufen wurde.
-bool Window::CloseWanted() {
- bool result = _CloseWanted;
- _CloseWanted = false;
+bool Window::closeWanted() {
+ bool result = _closeWanted;
+ _closeWanted = false;
return result;
}
-void Window::SetCloseWanted(bool Wanted) {
- _CloseWanted = Wanted;
+void Window::setCloseWanted(bool wanted) {
+ _closeWanted = wanted;
}
} // End of namespace Sword25
diff --git a/engines/sword25/kernel/window.h b/engines/sword25/kernel/window.h
index 3efdb89093..5f2406851b 100644
--- a/engines/sword25/kernel/window.h
+++ b/engines/sword25/kernel/window.h
@@ -44,13 +44,10 @@
#ifndef SWORD25_WINDOW_H
#define SWORD25_WINDOW_H
-// Includes
#include "sword25/kernel/common.h"
namespace Sword25 {
-// Class definitions
-
/**
* A simple window class interface
*
@@ -59,8 +56,8 @@ namespace Sword25 {
*/
class Window {
protected:
- bool _InitSuccess;
- bool _CloseWanted;
+ bool _initSuccess;
+ bool _closeWanted;
public:
virtual ~Window() {}
@@ -68,97 +65,97 @@ public:
/**
* Returns the visibility of the window.
*/
- virtual bool IsVisible() = 0;
+ virtual bool isVisible() = 0;
/**
* Sets the visibility of the window
* @param Visible Specifies whether the window should be visible or hidden
*/
- virtual void SetVisible(bool Visible) = 0;
+ virtual void setVisible(bool visible) = 0;
/**
* Returns the X position of the window
*/
- virtual int GetX() = 0;
+ virtual int getX() = 0;
/**
* Sets the X position of the window
* @paramX The new X position for the window, or -1 for centre aligned
*/
- virtual void SetX(int X) = 0;
+ virtual void setX(int X) = 0;
/**
* Gets the Y position of the window
*/
- virtual int GetY() = 0;
+ virtual int getY() = 0;
/**
* Sets the Y position of the window
* @param Y The new Y position for the window, or -1 for centre aligned
*/
- virtual void SetY(int X) = 0;
+ virtual void setY(int X) = 0;
/**
* Returns the X position of the window's client area
*/
- virtual int GetClientX() = 0;
+ virtual int getClientX() = 0;
/**
* Returns the Y position of the window's client area
*/
- virtual int GetClientY() = 0;
+ virtual int getClientY() = 0;
/**
* Returns the width of the window without the frame
*/
- virtual int GetWidth() = 0;
+ virtual int getWidth() = 0;
/**
* Sets the width of the window without the frame
*/
- virtual void SetWidth(int Width) = 0;
+ virtual void setWidth(int width) = 0;
/**
* Gets the height of the window without the frame
*/
- virtual int GetHeight() = 0;
+ virtual int getHeight() = 0;
/**
* Sets the height of the window without the frame
*/
- virtual void SetHeight(int Height) = 0;
+ virtual void setHeight(int height) = 0;
/**
* Returns the title of the window
*/
- virtual Common::String GetTitle() = 0;
+ virtual Common::String getTitle() = 0;
/**
* Sets the title of the window
* @param Title The new window title
*/
- virtual void SetTitle(const Common::String &Title) = 0;
+ virtual void setTitle(const Common::String &title) = 0;
/**
* Handle the processing of any pending window messages. This method should be called
* during the main loop.
*/
- virtual bool ProcessMessages() = 0;
+ virtual bool processMessages() = 0;
/**
* Pauses the applicaiton until the window has focus, or has been closed.
* Returns false if the window was closed.
*/
- virtual bool WaitForFocus() = 0;
+ virtual bool waitForFocus() = 0;
/**
* Returns true if the window has focus, false otherwise.
*/
- virtual bool HasFocus() = 0;
+ virtual bool hasFocus() = 0;
/**
* Returns the system handle that represents the window. Note that any use of the handle
* will not be portable code.
*/
- virtual uint GetWindowHandle() = 0;
+ virtual uint getWindowHandle() = 0;
- virtual void SetWindowAlive(bool v) = 0;
+ virtual void setWindowAlive(bool v) = 0;
/**
* Specifies whether the window is wanted to be closed. This is used together with CloseWanted()
* to allow scripts to query when the main window should be closed, or the user is asking it to close
**/
- void SetCloseWanted(bool Wanted);
+ void setCloseWanted(bool wanted);
/**
* Returns the previous value set in a call to SetCloseWanted.
* Note that calling this also resets the value back to false, until such time as the SetCloseWanted()
* method is called again.
**/
- bool CloseWanted();
+ bool closeWanted();
/**
* Creates a new window instance. Returns a pointer to the window, or NULL if the creation failed.
@@ -169,7 +166,7 @@ public:
* @param Height The height of the window without the frame
* @param Visible Specifies whether window should be visible
*/
- static Window *CreateBSWindow(int X, int Y, int Width, int Height, bool Visible);
+ static Window *createBSWindow(int x, int y, int width, int height, bool visible);
};
} // End of namespace Sword25