aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2010-09-25 19:48:26 +0000
committerEugene Sandulenko2010-10-13 00:02:51 +0000
commit8582c1ad5770b6385381f524a4610934d115cd88 (patch)
tree3a0c29c16f23c5c8992f5d29b36dbbda53a6fa3c
parent736ae4c07aa33589a5f9651643d7af07b5d0a877 (diff)
downloadscummvm-rg350-8582c1ad5770b6385381f524a4610934d115cd88.tar.gz
scummvm-rg350-8582c1ad5770b6385381f524a4610934d115cd88.tar.bz2
scummvm-rg350-8582c1ad5770b6385381f524a4610934d115cd88.zip
SWORD25: Enforse code naming conventions in PackageManager and Sword25Engine
svn-id: r53380
-rw-r--r--engines/sword25/fmv/movieplayer.cpp2
-rw-r--r--engines/sword25/gfx/animationresource.cpp10
-rw-r--r--engines/sword25/gfx/fontresource.cpp4
-rw-r--r--engines/sword25/gfx/graphicengine.cpp2
-rw-r--r--engines/sword25/gfx/image/renderedimage.cpp2
-rw-r--r--engines/sword25/gfx/image/swimage.cpp2
-rw-r--r--engines/sword25/kernel/resmanager.cpp2
-rw-r--r--engines/sword25/kernel/resource.cpp2
-rw-r--r--engines/sword25/package/packagemanager.cpp36
-rw-r--r--engines/sword25/package/packagemanager.h34
-rw-r--r--engines/sword25/package/packagemanager_script.cpp151
-rw-r--r--engines/sword25/script/luascript.cpp4
-rw-r--r--engines/sword25/sfx/soundengine.cpp2
-rw-r--r--engines/sword25/sword25.cpp56
-rw-r--r--engines/sword25/sword25.h9
15 files changed, 141 insertions, 177 deletions
diff --git a/engines/sword25/fmv/movieplayer.cpp b/engines/sword25/fmv/movieplayer.cpp
index d0901ec4b4..8b1d6d2e08 100644
--- a/engines/sword25/fmv/movieplayer.cpp
+++ b/engines/sword25/fmv/movieplayer.cpp
@@ -62,7 +62,7 @@ MoviePlayer::~MoviePlayer() {
bool MoviePlayer::LoadMovie(const Common::String &filename, uint z) {
// Get the file and load it into the decoder
- Common::SeekableReadStream *in = Kernel::GetInstance()->GetPackage()->GetStream(filename);
+ Common::SeekableReadStream *in = Kernel::GetInstance()->GetPackage()->getStream(filename);
_decoder.load(in);
// Ausgabebitmap erstellen
diff --git a/engines/sword25/gfx/animationresource.cpp b/engines/sword25/gfx/animationresource.cpp
index 6a1e3d4f2c..4a6bfc34db 100644
--- a/engines/sword25/gfx/animationresource.cpp
+++ b/engines/sword25/gfx/animationresource.cpp
@@ -73,15 +73,15 @@ AnimationResource::AnimationResource(const Common::String &filename) :
BS_ASSERT(_pPackage);
// Switch to the folder the specified Xml fiile is in
- Common::String oldDirectory = _pPackage->GetCurrentDirectory();
+ Common::String oldDirectory = _pPackage->getCurrentDirectory();
if (getFileName().contains('/')) {
Common::String dir = Common::String(getFileName().c_str(), strrchr(getFileName().c_str(), '/'));
- _pPackage->ChangeDirectory(dir);
+ _pPackage->changeDirectory(dir);
}
// Load the contents of the file
uint fileSize;
- char *xmlData = _pPackage->GetXmlFile(getFileName(), &fileSize);
+ char *xmlData = _pPackage->getXmlFile(getFileName(), &fileSize);
if (!xmlData) {
BS_LOG_ERRORLN("Could not read \"%s\".", getFileName().c_str());
return;
@@ -96,7 +96,7 @@ AnimationResource::AnimationResource(const Common::String &filename) :
free(xmlData);
// Switch back to the previous folder
- _pPackage->ChangeDirectory(oldDirectory);
+ _pPackage->changeDirectory(oldDirectory);
// Give an error message if there weren't any frames specified
if (_frames.empty()) {
@@ -172,7 +172,7 @@ bool AnimationResource::parserCallback_frame(ParserNode *node) {
BS_LOG_ERRORLN("<frame> tag without file attribute occurred in \"%s\".", getFileName().c_str());
return false;
}
- frame.FileName = _pPackage->GetAbsolutePath(fileString);
+ frame.FileName = _pPackage->getAbsolutePath(fileString);
if (frame.FileName.empty()) {
BS_LOG_ERRORLN("Could not create absolute path for file specified in <frame> tag in \"%s\": \"%s\".",
getFileName().c_str(), fileString);
diff --git a/engines/sword25/gfx/fontresource.cpp b/engines/sword25/gfx/fontresource.cpp
index d48f849743..9f23133a71 100644
--- a/engines/sword25/gfx/fontresource.cpp
+++ b/engines/sword25/gfx/fontresource.cpp
@@ -70,7 +70,7 @@ FontResource::FontResource(Kernel *pKernel, const Common::String &FileName) :
// Load the contents of the file
uint fileSize;
- char *xmlData = pPackage->GetXmlFile(getFileName(), &fileSize);
+ char *xmlData = pPackage->getXmlFile(getFileName(), &fileSize);
if (!xmlData) {
BS_LOG_ERRORLN("Could not read \"%s\".", getFileName().c_str());
return;
@@ -109,7 +109,7 @@ bool FontResource::parserCallback_font(ParserNode *node) {
BS_ASSERT(pPackage);
// Get the full path and filename for the bitmap resource
- _BitmapFileName = pPackage->GetAbsolutePath(bitmapFilename);
+ _BitmapFileName = pPackage->getAbsolutePath(bitmapFilename);
if (_BitmapFileName == "") {
BS_LOG_ERRORLN("Image file \"%s\" was specified in <font> tag of \"%s\" but could not be found.",
_BitmapFileName.c_str(), getFileName().c_str());
diff --git a/engines/sword25/gfx/graphicengine.cpp b/engines/sword25/gfx/graphicengine.cpp
index fe19dc7df5..fa1c0300da 100644
--- a/engines/sword25/gfx/graphicengine.cpp
+++ b/engines/sword25/gfx/graphicengine.cpp
@@ -308,7 +308,7 @@ Resource *GraphicEngine::LoadResource(const Common::String &FileName) {
// Datei laden
byte *pFileData;
uint FileSize;
- if (!(pFileData = static_cast<byte *>(pPackage->GetFile(FileName, &FileSize)))) {
+ if (!(pFileData = static_cast<byte *>(pPackage->getFile(FileName, &FileSize)))) {
BS_LOG_ERRORLN("File \"%s\" could not be loaded.", FileName.c_str());
return 0;
}
diff --git a/engines/sword25/gfx/image/renderedimage.cpp b/engines/sword25/gfx/image/renderedimage.cpp
index e6afffe3b0..96b6139a59 100644
--- a/engines/sword25/gfx/image/renderedimage.cpp
+++ b/engines/sword25/gfx/image/renderedimage.cpp
@@ -64,7 +64,7 @@ RenderedImage::RenderedImage(const Common::String &filename, bool &result) :
// Datei laden
byte *pFileData;
uint fileSize;
- if (!(pFileData = (byte *)pPackage->GetFile(filename, &fileSize))) {
+ if (!(pFileData = (byte *)pPackage->getFile(filename, &fileSize))) {
BS_LOG_ERRORLN("File \"%s\" could not be loaded.", filename.c_str());
return;
}
diff --git a/engines/sword25/gfx/image/swimage.cpp b/engines/sword25/gfx/image/swimage.cpp
index b135be7209..ac4463ea16 100644
--- a/engines/sword25/gfx/image/swimage.cpp
+++ b/engines/sword25/gfx/image/swimage.cpp
@@ -61,7 +61,7 @@ SWImage::SWImage(const Common::String &filename, bool &result) :
// Datei laden
byte *pFileData;
uint fileSize;
- if (!(pFileData = (byte *)pPackage->GetFile(filename, &fileSize))) {
+ if (!(pFileData = (byte *)pPackage->getFile(filename, &fileSize))) {
BS_LOG_ERRORLN("File \"%s\" could not be loaded.", filename.c_str());
return;
}
diff --git a/engines/sword25/kernel/resmanager.cpp b/engines/sword25/kernel/resmanager.cpp
index a671f9568d..ff82e6b797 100644
--- a/engines/sword25/kernel/resmanager.cpp
+++ b/engines/sword25/kernel/resmanager.cpp
@@ -263,7 +263,7 @@ Common::String ResourceManager::GetUniqueFileName(const Common::String &FileName
}
// Absoluten Pfad der Datei bekommen und somit die Eindeutigkeit des Dateinamens sicherstellen
- Common::String UniqueFileName = pPackage->GetAbsolutePath(FileName);
+ Common::String UniqueFileName = pPackage->getAbsolutePath(FileName);
if (UniqueFileName == "")
BS_LOG_ERRORLN("Could not create absolute file name for \"%s\".", FileName.c_str());
diff --git a/engines/sword25/kernel/resource.cpp b/engines/sword25/kernel/resource.cpp
index 813ee54cd3..f6f4f13f68 100644
--- a/engines/sword25/kernel/resource.cpp
+++ b/engines/sword25/kernel/resource.cpp
@@ -46,7 +46,7 @@ Resource::Resource(const Common::String &fileName, RESOURCE_TYPES type) :
_refCount(0) {
BS_ASSERT(Kernel::GetInstance()->GetService("package"));
- _fileName = static_cast<PackageManager *>(Kernel::GetInstance()->GetService("package"))->GetAbsolutePath(fileName);
+ _fileName = static_cast<PackageManager *>(Kernel::GetInstance()->GetService("package"))->getAbsolutePath(fileName);
_fileNameHash = BS_String::GetHash(fileName);
}
diff --git a/engines/sword25/package/packagemanager.cpp b/engines/sword25/package/packagemanager.cpp
index 801f695f15..18b2453d6d 100644
--- a/engines/sword25/package/packagemanager.cpp
+++ b/engines/sword25/package/packagemanager.cpp
@@ -61,7 +61,7 @@ static Common::String normalizePath(const Common::String &path, const Common::St
PackageManager::PackageManager(Kernel *pKernel) : Service(pKernel),
_currentDirectory(PATH_SEPARATOR),
_rootFolder(ConfMan.get("path")) {
- if (!_RegisterScriptBindings())
+ if (!registerScriptBindings())
BS_LOG_ERRORLN("Script bindings could not be registered.");
else
BS_LOGLN("Script bindings registered.");
@@ -82,7 +82,7 @@ Service *PackageManager_CreateObject(Kernel *kernelPtr) {
/**
* Scans through the archive list for a specified file
*/
-Common::ArchiveMemberPtr PackageManager::GetArchiveMember(const Common::String &fileName) {
+Common::ArchiveMemberPtr PackageManager::getArchiveMember(const Common::String &fileName) {
// Loop through checking each archive
Common::List<ArchiveEntry *>::iterator i;
for (i = _archiveList.begin(); i != _archiveList.end(); ++i) {
@@ -105,8 +105,8 @@ Common::ArchiveMemberPtr PackageManager::GetArchiveMember(const Common::String &
return Common::ArchiveMemberPtr();
}
-bool PackageManager::LoadPackage(const Common::String &fileName, const Common::String &mountPosition) {
- debug(0, "LoadPackage(%s, %s)", fileName.c_str(), mountPosition.c_str());
+bool PackageManager::loadPackage(const Common::String &fileName, const Common::String &mountPosition) {
+ debug(3, "loadPackage(%s, %s)", fileName.c_str(), mountPosition.c_str());
Common::Archive *zipFile = Common::makeZipArchive(fileName);
if (zipFile == NULL) {
@@ -116,7 +116,7 @@ bool PackageManager::LoadPackage(const Common::String &fileName, const Common::S
BS_LOGLN("Package '%s' mounted as '%s'.", fileName.c_str(), mountPosition.c_str());
Common::ArchiveMemberList files;
zipFile->listMembers(files);
- debug(0, "Capacity %d", files.size());
+ debug(3, "Capacity %d", files.size());
for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); ++it)
debug(3, "%s", (*it)->getName().c_str());
@@ -127,7 +127,7 @@ bool PackageManager::LoadPackage(const Common::String &fileName, const Common::S
}
}
-bool PackageManager::LoadDirectoryAsPackage(const Common::String &directoryName, const Common::String &mountPosition) {
+bool PackageManager::loadDirectoryAsPackage(const Common::String &directoryName, const Common::String &mountPosition) {
Common::FSNode directory(directoryName);
Common::Archive *folderArchive = new Common::FSDirectory(directory, 6);
if (!directory.exists() || (folderArchive == NULL)) {
@@ -146,7 +146,7 @@ bool PackageManager::LoadDirectoryAsPackage(const Common::String &directoryName,
}
}
-byte *PackageManager::GetFile(const Common::String &fileName, uint *fileSizePtr) {
+byte *PackageManager::getFile(const Common::String &fileName, uint *fileSizePtr) {
const Common::String B25S_EXTENSION(".b25s");
Common::SeekableReadStream *in;
@@ -170,7 +170,7 @@ byte *PackageManager::GetFile(const Common::String &fileName, uint *fileSizePtr)
return buffer;
}
- Common::ArchiveMemberPtr fileNode = GetArchiveMember(normalizePath(fileName, _currentDirectory));
+ Common::ArchiveMemberPtr fileNode = getArchiveMember(normalizePath(fileName, _currentDirectory));
if (!fileNode)
return 0;
if (!(in = fileNode->createReadStream()))
@@ -196,9 +196,9 @@ byte *PackageManager::GetFile(const Common::String &fileName, uint *fileSizePtr)
return buffer;
}
-Common::SeekableReadStream *PackageManager::GetStream(const Common::String &fileName) {
+Common::SeekableReadStream *PackageManager::getStream(const Common::String &fileName) {
Common::SeekableReadStream *in;
- Common::ArchiveMemberPtr fileNode = GetArchiveMember(normalizePath(fileName, _currentDirectory));
+ Common::ArchiveMemberPtr fileNode = getArchiveMember(normalizePath(fileName, _currentDirectory));
if (!fileNode)
return 0;
if (!(in = fileNode->createReadStream()))
@@ -207,23 +207,23 @@ Common::SeekableReadStream *PackageManager::GetStream(const Common::String &file
return in;
}
-Common::String PackageManager::GetCurrentDirectory() {
+Common::String PackageManager::getCurrentDirectory() {
return _currentDirectory;
}
-bool PackageManager::ChangeDirectory(const Common::String &directory) {
+bool PackageManager::changeDirectory(const Common::String &directory) {
// Get the path elements for the file
_currentDirectory = normalizePath(directory, _currentDirectory);
return true;
}
-Common::String PackageManager::GetAbsolutePath(const Common::String &fileName) {
+Common::String PackageManager::getAbsolutePath(const Common::String &fileName) {
return normalizePath(fileName, _currentDirectory);
}
-uint PackageManager::GetFileSize(const Common::String &fileName) {
+uint PackageManager::getFileSize(const Common::String &fileName) {
Common::SeekableReadStream *in;
- Common::ArchiveMemberPtr fileNode = GetArchiveMember(normalizePath(fileName, _currentDirectory));
+ Common::ArchiveMemberPtr fileNode = getArchiveMember(normalizePath(fileName, _currentDirectory));
if (!fileNode)
return 0;
if (!(in = fileNode->createReadStream()))
@@ -234,15 +234,15 @@ uint PackageManager::GetFileSize(const Common::String &fileName) {
return fileSize;
}
-uint PackageManager::GetFileType(const Common::String &fileName) {
+uint PackageManager::getFileType(const Common::String &fileName) {
warning("STUB: BS_PackageManager::GetFileType(%s)", fileName.c_str());
//return fileNode.isDirectory() ? BS_PackageManager::FT_DIRECTORY : BS_PackageManager::FT_FILE;
return PackageManager::FT_FILE;
}
-bool PackageManager::FileExists(const Common::String &fileName) {
- Common::ArchiveMemberPtr fileNode = GetArchiveMember(normalizePath(fileName, _currentDirectory));
+bool PackageManager::fileExists(const Common::String &fileName) {
+ Common::ArchiveMemberPtr fileNode = getArchiveMember(normalizePath(fileName, _currentDirectory));
return fileNode;
}
diff --git a/engines/sword25/package/packagemanager.h b/engines/sword25/package/packagemanager.h
index 1441c92606..96f136dd83 100644
--- a/engines/sword25/package/packagemanager.h
+++ b/engines/sword25/package/packagemanager.h
@@ -91,7 +91,7 @@ private:
Common::FSNode _rootFolder;
Common::List<ArchiveEntry *> _archiveList;
- Common::ArchiveMemberPtr GetArchiveMember(const Common::String &fileName);
+ Common::ArchiveMemberPtr getArchiveMember(const Common::String &fileName);
public:
PackageManager(Kernel *pKernel);
@@ -108,14 +108,14 @@ public:
* @param MountPosition The directory name under which the package should be mounted
* @return Returns true if the mount was successful, otherwise false.
*/
- bool LoadPackage(const Common::String &FileName, const Common::String &MountPosition);
+ bool loadPackage(const Common::String &fileName, const Common::String &mountPosition);
/**
* Mounts the contents of a directory in the specified directory in the directory tree.
* @param The name of the directory to mount
* @param MountPosition The directory name under which the package should be mounted
* @return Returns true if the mount was successful, otherwise false.
*/
- bool LoadDirectoryAsPackage(const Common::String &DirectoryName, const Common::String &MountPosition);
+ bool loadDirectoryAsPackage(const Common::String &directoryName, const Common::String &mountPosition);
/**
* Downloads a file from the directory tree
* @param FileName The filename of the file to load
@@ -123,14 +123,14 @@ public:
* @return Specifies a pointer to the loaded data of the file
* @remark The client must not forget to release the data of the file using BE_DELETE_A.
*/
- byte *GetFile(const Common::String &FileName, uint *pFileSize = NULL);
+ byte *getFile(const Common::String &fileName, uint *pFileSize = NULL);
/**
* Returns a stream from file file from the directory tree
* @param FileName The filename of the file to load
* @return Pointer to the stream object
*/
- Common::SeekableReadStream *GetStream(const Common::String &fileName);
+ Common::SeekableReadStream *getStream(const Common::String &fileName);
/**
* Downloads an XML file and prefixes it with an XML Version key, since the XML files don't contain it,
* and it is required for ScummVM to correctly parse the XML.
@@ -139,17 +139,19 @@ public:
* @return Specifies a pointer to the loaded data of the file
* @remark The client must not forget to release the data of the file using BE_DELETE_A.
*/
- char *GetXmlFile(const Common::String &FileName, uint *pFileSize = NULL) {
+ char *getXmlFile(const Common::String &fileName, uint *pFileSize = NULL) {
const char *versionStr = "<?xml version=\"1.0\"?>";
uint fileSize;
- char *data = (char *)GetFile(FileName, &fileSize);
+ char *data = (char *)getFile(fileName, &fileSize);
char *result = (char *)malloc(fileSize + strlen(versionStr) + 1);
strcpy(result, versionStr);
Common::copy(data, data + fileSize, result + strlen(versionStr));
result[fileSize + strlen(versionStr)] = '\0';
delete[] data;
- if (pFileSize) *pFileSize = fileSize + strlen(versionStr);
+ if (pFileSize)
+ *pFileSize = fileSize + strlen(versionStr);
+
return result;
}
@@ -159,14 +161,14 @@ public:
* If the path could not be determined, an empty string is returned.
* @remark For cutting path elements '\' is used rather than '/' elements.
*/
- Common::String GetCurrentDirectory();
+ Common::String getCurrentDirectory();
/**
* Changes the current directory.
* @param Directory The path to the new directory. The path can be relative.
* @return Returns true if the operation was successful, otherwise false.
* @remark For cutting path elements '\' is used rather than '/' elements.
*/
- bool ChangeDirectory(const Common::String &Directory);
+ bool changeDirectory(const Common::String &directory);
/**
* Returns the absolute path to a file in the directory tree.
* @param FileName The filename of the file whose absolute path is to be determined.
@@ -174,7 +176,7 @@ public:
* @return Returns an absolute path to the given file.
* @remark For cutting path elements '\' is used rather than '/' elements.
*/
- Common::String GetAbsolutePath(const Common::String &FileName);
+ Common::String getAbsolutePath(const Common::String &fileName);
/**
* Creates a BS_PackageManager::FileSearch object to search for files
* @param Filter Specifies the search string. Wildcards of '*' and '?' are allowed
@@ -185,7 +187,7 @@ public:
* @return Specifies a pointer to a BS_PackageManager::FileSearch object, or NULL if no file was found.
* @remark Do not forget to delete the object after use.
*/
- int doSearch(Common::ArchiveMemberList &list, const Common::String &Filter, const Common::String &Path, uint TypeFilter = FT_DIRECTORY | FT_FILE);
+ int doSearch(Common::ArchiveMemberList &list, const Common::String &filter, const Common::String &path, uint typeFilter = FT_DIRECTORY | FT_FILE);
/**
* Returns a file's size
@@ -193,7 +195,7 @@ public:
* @return The file size. If an error occurs, then 0xffffffff is returned.
* @remarks For files in packages, then uncompressed size is returned.
**/
- uint GetFileSize(const Common::String &FileName);
+ uint getFileSize(const Common::String &fileName);
/**
* Returns the type of a file.
@@ -202,17 +204,17 @@ public:
* or BS_PackageManager::FT_FILE).
* If the file was not found, then 0 is returned.
*/
- uint GetFileType(const Common::String &FileName);
+ uint getFileType(const Common::String &fileName);
/**
* Determines whether a file exists
* @param FileName The filename
* @return Returns true if the file exists, otherwise false.
*/
- bool FileExists(const Common::String &FileName);
+ bool fileExists(const Common::String &FileName);
private:
- bool _RegisterScriptBindings();
+ bool registerScriptBindings();
};
} // End of namespace Sword25
diff --git a/engines/sword25/package/packagemanager_script.cpp b/engines/sword25/package/packagemanager_script.cpp
index b3e987ea62..409eb1ab7a 100644
--- a/engines/sword25/package/packagemanager_script.cpp
+++ b/engines/sword25/package/packagemanager_script.cpp
@@ -32,10 +32,6 @@
*
*/
-// -----------------------------------------------------------------------------
-// Includes
-// -----------------------------------------------------------------------------
-
#include "sword25/kernel/common.h"
#include "sword25/kernel/kernel.h"
#include "sword25/script/script.h"
@@ -47,9 +43,7 @@ namespace Sword25 {
using namespace Lua;
-// -----------------------------------------------------------------------------
-
-static PackageManager *GetPM() {
+static PackageManager *getPM() {
Kernel *pKernel = Kernel::GetInstance();
BS_ASSERT(pKernel);
PackageManager *pPM = static_cast<PackageManager *>(pKernel->GetService("package"));
@@ -57,104 +51,86 @@ static PackageManager *GetPM() {
return pPM;
}
-// -----------------------------------------------------------------------------
-
-static int LoadPackage(lua_State *L) {
- PackageManager *pPM = GetPM();
+static int loadPackage(lua_State *L) {
+ PackageManager *pPM = getPM();
- lua_pushbooleancpp(L, pPM->LoadPackage(luaL_checkstring(L, 1), luaL_checkstring(L, 2)));
+ lua_pushbooleancpp(L, pPM->loadPackage(luaL_checkstring(L, 1), luaL_checkstring(L, 2)));
return 1;
}
-// -----------------------------------------------------------------------------
+static int loadDirectoryAsPackage(lua_State *L) {
+ PackageManager *pPM = getPM();
-static int LoadDirectoryAsPackage(lua_State *L) {
- PackageManager *pPM = GetPM();
-
- lua_pushbooleancpp(L, pPM->LoadDirectoryAsPackage(luaL_checkstring(L, 1), luaL_checkstring(L, 2)));
+ lua_pushbooleancpp(L, pPM->loadDirectoryAsPackage(luaL_checkstring(L, 1), luaL_checkstring(L, 2)));
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int GetCurrentDirectory(lua_State *L) {
- PackageManager *pPM = GetPM();
+static int getCurrentDirectory(lua_State *L) {
+ PackageManager *pPM = getPM();
- lua_pushstring(L, pPM->GetCurrentDirectory().c_str());
+ lua_pushstring(L, pPM->getCurrentDirectory().c_str());
return 1;
}
-// -----------------------------------------------------------------------------
+static int changeDirectory(lua_State *L) {
+ PackageManager *pPM = getPM();
-static int ChangeDirectory(lua_State *L) {
- PackageManager *pPM = GetPM();
-
- lua_pushbooleancpp(L, pPM->ChangeDirectory(luaL_checkstring(L, 1)));
+ lua_pushbooleancpp(L, pPM->changeDirectory(luaL_checkstring(L, 1)));
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int GetAbsolutePath(lua_State *L) {
- PackageManager *pPM = GetPM();
+static int getAbsolutePath(lua_State *L) {
+ PackageManager *pPM = getPM();
- lua_pushstring(L, pPM->GetAbsolutePath(luaL_checkstring(L, 1)).c_str());
+ lua_pushstring(L, pPM->getAbsolutePath(luaL_checkstring(L, 1)).c_str());
return 1;
}
-// -----------------------------------------------------------------------------
+static int getFileSize(lua_State *L) {
+ PackageManager *pPM = getPM();
-static int GetFileSize(lua_State *L) {
- PackageManager *pPM = GetPM();
-
- lua_pushnumber(L, pPM->GetFileSize(luaL_checkstring(L, 1)));
+ lua_pushnumber(L, pPM->getFileSize(luaL_checkstring(L, 1)));
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int GetFileType(lua_State *L) {
- PackageManager *pPM = GetPM();
+static int getFileType(lua_State *L) {
+ PackageManager *pPM = getPM();
- lua_pushnumber(L, pPM->GetFileType(luaL_checkstring(L, 1)));
+ lua_pushnumber(L, pPM->getFileType(luaL_checkstring(L, 1)));
return 1;
}
-// -----------------------------------------------------------------------------
-
-static void SplitSearchPath(const Common::String &Path, Common::String &Directory, Common::String &Filter) {
+static void splitSearchPath(const Common::String &path, Common::String &directory, Common::String &filter) {
// Scan backwards for a trailing slash
- const char *sPath = Path.c_str();
+ const char *sPath = path.c_str();
const char *lastSlash = sPath + strlen(sPath) - 1;
while ((lastSlash >= sPath) && (*lastSlash != '/')) --lastSlash;
if (lastSlash >= sPath) {
- Directory = "";
- Filter = Path;
+ directory = "";
+ filter = path;
} else {
- Directory = Common::String(sPath, lastSlash - sPath);
- Filter = Common::String(lastSlash + 1);
+ directory = Common::String(sPath, lastSlash - sPath);
+ filter = Common::String(lastSlash + 1);
}
}
-// -----------------------------------------------------------------------------
-
-static void DoSearch(lua_State *L, const Common::String &path, uint type) {
- PackageManager *pPM = GetPM();
+static void doSearch(lua_State *L, const Common::String &path, uint type) {
+ PackageManager *pPM = getPM();
// Der Packagemanager-Service muss den Suchstring und den Pfad getrennt übergeben bekommen.
// Um die Benutzbarkeit zu verbessern sollen Skriptprogrammierer dieses als ein Pfad übergeben können.
// Daher muss der übergebene Pfad am letzten Slash aufgesplittet werden.
Common::String directory;
Common::String filter;
- SplitSearchPath(path, directory, filter);
+ splitSearchPath(path, directory, filter);
// Ergebnistable auf dem Lua-Stack erstellen
lua_newtable(L);
@@ -176,65 +152,53 @@ static void DoSearch(lua_State *L, const Common::String &path, uint type) {
}
}
-// -----------------------------------------------------------------------------
-
-static int FindFiles(lua_State *L) {
- DoSearch(L, luaL_checkstring(L, 1), PackageManager::FT_FILE);
+static int findFiles(lua_State *L) {
+ doSearch(L, luaL_checkstring(L, 1), PackageManager::FT_FILE);
return 1;
}
-// -----------------------------------------------------------------------------
-
-static int FindDirectories(lua_State *L) {
- DoSearch(L, luaL_checkstring(L, 1), PackageManager::FT_DIRECTORY);
+static int findDirectories(lua_State *L) {
+ doSearch(L, luaL_checkstring(L, 1), PackageManager::FT_DIRECTORY);
return 1;
}
-// -----------------------------------------------------------------------------
+static int getFileAsString(lua_State *L) {
+ PackageManager *pPM = getPM();
-static int GetFileAsString(lua_State *L) {
- PackageManager *pPM = GetPM();
-
- uint FileSize;
- char *FileData = (char *)pPM->GetFile(luaL_checkstring(L, 1), &FileSize);
- if (FileData) {
- lua_pushlstring(L, FileData, FileSize);
- delete[] FileData;
+ uint fileSize;
+ char *fileData = (char *)pPM->getFile(luaL_checkstring(L, 1), &fileSize);
+ if (fileData) {
+ lua_pushlstring(L, fileData, fileSize);
+ delete[] fileData;
return 1;
} else
return 0;
}
-// -----------------------------------------------------------------------------
-
-static int FileExists(lua_State *L) {
- lua_pushbooleancpp(L, GetPM()->FileExists(luaL_checkstring(L, 1)));
+static int fileExists(lua_State *L) {
+ lua_pushbooleancpp(L, getPM()->fileExists(luaL_checkstring(L, 1)));
return 1;
}
-// -----------------------------------------------------------------------------
-
static const char *PACKAGE_LIBRARY_NAME = "Package";
static const luaL_reg PACKAGE_FUNCTIONS[] = {
- {"LoadPackage", LoadPackage},
- {"LoadDirectoryAsPackage", LoadDirectoryAsPackage},
- {"GetCurrentDirectory", GetCurrentDirectory},
- {"ChangeDirectory", ChangeDirectory},
- {"GetAbsolutePath", GetAbsolutePath},
- {"GetFileSize", GetFileSize},
- {"GetFileType", GetFileType},
- {"FindFiles", FindFiles},
- {"FindDirectories", FindDirectories},
- {"GetFileAsString", GetFileAsString},
- {"FileExists", FileExists},
+ {"LoadPackage", loadPackage},
+ {"LoadDirectoryAsPackage", loadDirectoryAsPackage},
+ {"GetCurrentDirectory", getCurrentDirectory},
+ {"ChangeDirectory", changeDirectory},
+ {"GetAbsolutePath", getAbsolutePath},
+ {"GetFileSize", getFileSize},
+ {"GetFileType", getFileType},
+ {"FindFiles", findFiles},
+ {"FindDirectories", findDirectories},
+ {"GetFileAsString", getFileAsString},
+ {"FileExists", fileExists},
{0, 0}
};
-// -----------------------------------------------------------------------------
-
-bool PackageManager::_RegisterScriptBindings() {
+bool PackageManager::registerScriptBindings() {
Kernel *pKernel = Kernel::GetInstance();
BS_ASSERT(pKernel);
ScriptEngine *pScript = static_cast<ScriptEngine *>(pKernel->GetService("script"));
@@ -242,7 +206,8 @@ bool PackageManager::_RegisterScriptBindings() {
lua_State *L = static_cast<lua_State *>(pScript->GetScriptObject());
BS_ASSERT(L);
- if (!LuaBindhelper::AddFunctionsToLib(L, PACKAGE_LIBRARY_NAME, PACKAGE_FUNCTIONS)) return false;
+ if (!LuaBindhelper::AddFunctionsToLib(L, PACKAGE_LIBRARY_NAME, PACKAGE_FUNCTIONS))
+ return false;
return true;
}
diff --git a/engines/sword25/script/luascript.cpp b/engines/sword25/script/luascript.cpp
index 8e65010298..0e8052411c 100644
--- a/engines/sword25/script/luascript.cpp
+++ b/engines/sword25/script/luascript.cpp
@@ -182,7 +182,7 @@ bool LuaScriptEngine::ExecuteFile(const Common::String &FileName) {
// File read
uint FileSize;
- byte *FileData = pPackage->GetFile(FileName, &FileSize);
+ byte *FileData = pPackage->getFile(FileName, &FileSize);
if (!FileData) {
BS_LOG_ERRORLN("Couldn't read \"%s\".", FileName.c_str());
#ifdef DEBUG
@@ -192,7 +192,7 @@ bool LuaScriptEngine::ExecuteFile(const Common::String &FileName) {
}
// Run the file content
- if (!ExecuteBuffer(FileData, FileSize, "@" + pPackage->GetAbsolutePath(FileName))) {
+ if (!ExecuteBuffer(FileData, FileSize, "@" + pPackage->getAbsolutePath(FileName))) {
// Release file buffer
delete[] FileData;
#ifdef DEBUG
diff --git a/engines/sword25/sfx/soundengine.cpp b/engines/sword25/sfx/soundengine.cpp
index 308c8dd6e5..f057a657c0 100644
--- a/engines/sword25/sfx/soundengine.cpp
+++ b/engines/sword25/sfx/soundengine.cpp
@@ -157,7 +157,7 @@ bool SoundEngine::PlaySound(const Common::String &fileName, SOUND_TYPES type, fl
}
uint SoundEngine::PlaySoundEx(const Common::String &fileName, SOUND_TYPES type, float volume, float pan, bool loop, int loopStart, int loopEnd, uint layer) {
- Common::SeekableReadStream *in = Kernel::GetInstance()->GetPackage()->GetStream(fileName);
+ Common::SeekableReadStream *in = Kernel::GetInstance()->GetPackage()->getStream(fileName);
Audio::SeekableAudioStream *stream = Audio::makeVorbisStream(in, DisposeAfterUse::YES);
uint id;
SndHandle *handle = getHandle(&id);
diff --git a/engines/sword25/sword25.cpp b/engines/sword25/sword25.cpp
index 723775f133..524988ab51 100644
--- a/engines/sword25/sword25.cpp
+++ b/engines/sword25/sword25.cpp
@@ -49,7 +49,7 @@ namespace Sword25 {
const char *const PACKAGE_MANAGER = "archiveFS";
const char *const DEFAULT_SCRIPT_FILE = "/system/boot.lua";
-void LogToStdout(const char *Message) {
+void logToStdout(const char *Message) {
debugN(0, "%s", Message);
}
@@ -67,25 +67,24 @@ Sword25Engine::~Sword25Engine() {
Common::Error Sword25Engine::run() {
// Engine initialisation
- Common::StringArray commandParameters;
- Common::Error errorCode = AppStart(commandParameters);
+ Common::Error errorCode = appStart();
if (errorCode != Common::kNoError) {
- AppEnd();
+ appEnd();
return errorCode;
}
// Run the game
- bool RunSuccess = AppMain();
+ bool runSuccess = appMain();
// Engine de-initialisation
- bool DeinitSuccess = AppEnd();
+ bool deinitSuccess = appEnd();
- return (RunSuccess && DeinitSuccess) ? Common::kNoError : Common::kUnknownError;
+ return (runSuccess && deinitSuccess) ? Common::kNoError : Common::kUnknownError;
}
-Common::Error Sword25Engine::AppStart(const Common::StringArray &CommandParameters) {
+Common::Error Sword25Engine::appStart() {
// All log messages will be sent to StdOut
- BS_Log::RegisterLogListener(LogToStdout);
+ BS_Log::RegisterLogListener(logToStdout);
// Initialise the graphics mode to ARGB8888
Graphics::PixelFormat format = Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24);
@@ -100,44 +99,41 @@ Common::Error Sword25Engine::AppStart(const Common::StringArray &CommandParamete
}
// Package-Manager starten, damit die Packfiles geladen werden können.
- PackageManager *PackageManagerPtr = static_cast<PackageManager *>(Kernel::GetInstance()->NewService("package", PACKAGE_MANAGER));
- if (!PackageManagerPtr) {
- BS_LOG_ERRORLN("Packagemanager initialization failed.");
+ PackageManager *packageManagerPtr = static_cast<PackageManager *>(Kernel::GetInstance()->NewService("package", PACKAGE_MANAGER));
+ if (!packageManagerPtr) {
+ BS_LOG_ERRORLN("PackageManager initialization failed.");
return Common::kUnknownError;
}
// Packages laden oder das aktuelle Verzeichnis mounten, wenn das über Kommandozeile angefordert wurde.
if (getGameFlags() & GF_EXTRACTED) {
- if (!PackageManagerPtr->LoadDirectoryAsPackage(ConfMan.get("path"), "/"))
+ if (!packageManagerPtr->loadDirectoryAsPackage(ConfMan.get("path"), "/"))
return Common::kUnknownError;
} else {
- if (!LoadPackages())
+ if (!loadPackages())
return Common::kUnknownError;
}
// Einen Pointer auf den Skript-Engine holen.
- ScriptEngine *ScriptPtr = static_cast<ScriptEngine *>(Kernel::GetInstance()->GetService("script"));
- if (!ScriptPtr) {
+ ScriptEngine *scriptPtr = static_cast<ScriptEngine *>(Kernel::GetInstance()->GetService("script"));
+ if (!scriptPtr) {
BS_LOG_ERRORLN("Script intialization failed.");
return Common::kUnknownError;
}
- // Die Kommandozeilen-Parameter der Skriptumgebung zugänglich machen.
- ScriptPtr->SetCommandLine(CommandParameters);
-
return Common::kNoError;
}
-bool Sword25Engine::AppMain() {
+bool Sword25Engine::appMain() {
// The main script start. This script loads all the other scripts and starts the actual game.
- ScriptEngine *ScriptPtr = static_cast<ScriptEngine *>(Kernel::GetInstance()->GetService("script"));
- BS_ASSERT(ScriptPtr);
- ScriptPtr->ExecuteFile(DEFAULT_SCRIPT_FILE);
+ ScriptEngine *scriptPtr = static_cast<ScriptEngine *>(Kernel::GetInstance()->GetService("script"));
+ BS_ASSERT(scriptPtr);
+ scriptPtr->ExecuteFile(DEFAULT_SCRIPT_FILE);
return true;
}
-bool Sword25Engine::AppEnd() {
+bool Sword25Engine::appEnd() {
// The kernel is shutdown, and un-initialises all subsystems
Kernel::DeleteInstance();
@@ -147,12 +143,12 @@ bool Sword25Engine::AppEnd() {
return true;
}
-bool Sword25Engine::LoadPackages() {
- PackageManager *PackageManagerPtr = reinterpret_cast<PackageManager *>(Kernel::GetInstance()->GetService("package"));
- BS_ASSERT(PackageManagerPtr);
+bool Sword25Engine::loadPackages() {
+ PackageManager *packageManagerPtr = reinterpret_cast<PackageManager *>(Kernel::GetInstance()->GetService("package"));
+ BS_ASSERT(packageManagerPtr);
// Load the main package
- if (!PackageManagerPtr->LoadPackage("data.b25c", "/")) return false;
+ if (!packageManagerPtr->loadPackage("data.b25c", "/")) return false;
// Get the contents of the main program directory and sort them alphabetically
Common::FSNode dir(ConfMan.get("path"));
@@ -172,7 +168,7 @@ bool Sword25Engine::LoadPackages() {
// existing files in the virtual file system, if they include files with the same name.
for (Common::FSList::const_iterator it = files.begin(); it != files.end(); ++it) {
if (it->getName().matchString("patch???.b25c", true))
- if (!PackageManagerPtr->LoadPackage(it->getName(), "/"))
+ if (!packageManagerPtr->loadPackage(it->getName(), "/"))
return false;
}
@@ -180,7 +176,7 @@ bool Sword25Engine::LoadPackages() {
// The filename of the packages have the form lang_*.b25c (eg. lang_de.b25c)
for (Common::FSList::const_iterator it = files.begin(); it != files.end(); ++it) {
if (it->getName().matchString("lang_*.b25c", true))
- if (!PackageManagerPtr->LoadPackage(it->getName(), "/"))
+ if (!packageManagerPtr->loadPackage(it->getName(), "/"))
return false;
}
diff --git a/engines/sword25/sword25.h b/engines/sword25/sword25.h
index a763f80753..8f31a05562 100644
--- a/engines/sword25/sword25.h
+++ b/engines/sword25/sword25.h
@@ -56,11 +56,12 @@ enum GameFlags {
class Sword25Engine : public Engine {
private:
- Common::Error AppStart(const Common::StringArray &CommandParameters);
- bool AppMain();
- bool AppEnd();
+ Common::Error appStart();
+ bool appMain();
+ bool appEnd();
+
+ bool loadPackages();
- bool LoadPackages();
protected:
virtual Common::Error run();
void shutdown();