diff options
54 files changed, 1518 insertions, 1989 deletions
diff --git a/engines/sword25/fmv/movieplayer.cpp b/engines/sword25/fmv/movieplayer.cpp index 8152b7d949..a0dda3d7cc 100644 --- a/engines/sword25/fmv/movieplayer.cpp +++ b/engines/sword25/fmv/movieplayer.cpp @@ -65,11 +65,11 @@ 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 - GraphicEngine *pGfx = Kernel::GetInstance()->GetGfx(); + GraphicEngine *pGfx = Kernel::getInstance()->getGfx(); #if INDIRECTRENDERING _outputBitmap = pGfx->getMainPanel()->addDynamicBitmap(_decoder.getWidth(), _decoder.getHeight()); @@ -167,7 +167,7 @@ void MoviePlayer::setScaleFactor(float scaleFactor) { _outputBitmap->setScaleFactor(scaleFactor); // Ausgabebitmap auf dem Bildschirm zentrieren - GraphicEngine *gfxPtr = Kernel::GetInstance()->GetGfx(); + GraphicEngine *gfxPtr = Kernel::getInstance()->getGfx(); _outputBitmap->setX((gfxPtr->getDisplayWidth() - _outputBitmap->getWidth()) / 2); _outputBitmap->setY((gfxPtr->getDisplayHeight() - _outputBitmap->getHeight()) / 2); } diff --git a/engines/sword25/fmv/movieplayer_script.cpp b/engines/sword25/fmv/movieplayer_script.cpp index ea1a9c3a6b..aa854448ff 100644 --- a/engines/sword25/fmv/movieplayer_script.cpp +++ b/engines/sword25/fmv/movieplayer_script.cpp @@ -44,7 +44,7 @@ namespace Sword25 { int loadMovie(lua_State *L) { - MoviePlayer *FMVPtr = Kernel::GetInstance()->GetFMV(); + MoviePlayer *FMVPtr = Kernel::getInstance()->getFMV(); BS_ASSERT(FMVPtr); lua_pushbooleancpp(L, FMVPtr->loadMovie(luaL_checkstring(L, 1), lua_gettop(L) == 2 ? static_cast<uint>(luaL_checknumber(L, 2)) : 10)); @@ -53,7 +53,7 @@ int loadMovie(lua_State *L) { } int unloadMovie(lua_State *L) { - MoviePlayer *FMVPtr = Kernel::GetInstance()->GetFMV(); + MoviePlayer *FMVPtr = Kernel::getInstance()->getFMV(); BS_ASSERT(FMVPtr); lua_pushbooleancpp(L, FMVPtr->unloadMovie()); @@ -62,7 +62,7 @@ int unloadMovie(lua_State *L) { } int play(lua_State *L) { - MoviePlayer *FMVPtr = Kernel::GetInstance()->GetFMV(); + MoviePlayer *FMVPtr = Kernel::getInstance()->getFMV(); BS_ASSERT(FMVPtr); lua_pushbooleancpp(L, FMVPtr->play()); @@ -71,7 +71,7 @@ int play(lua_State *L) { } int pause(lua_State *L) { - MoviePlayer *FMVPtr = Kernel::GetInstance()->GetFMV(); + MoviePlayer *FMVPtr = Kernel::getInstance()->getFMV(); BS_ASSERT(FMVPtr); lua_pushbooleancpp(L, FMVPtr->pause()); @@ -80,7 +80,7 @@ int pause(lua_State *L) { } int update(lua_State *L) { - MoviePlayer *FMVPtr = Kernel::GetInstance()->GetFMV(); + MoviePlayer *FMVPtr = Kernel::getInstance()->getFMV(); BS_ASSERT(FMVPtr); FMVPtr->update(); @@ -89,7 +89,7 @@ int update(lua_State *L) { } int isMovieLoaded(lua_State *L) { - MoviePlayer *FMVPtr = Kernel::GetInstance()->GetFMV(); + MoviePlayer *FMVPtr = Kernel::getInstance()->getFMV(); BS_ASSERT(FMVPtr); lua_pushbooleancpp(L, FMVPtr->isMovieLoaded()); @@ -98,7 +98,7 @@ int isMovieLoaded(lua_State *L) { } int isPaused(lua_State *L) { - MoviePlayer *FMVPtr = Kernel::GetInstance()->GetFMV(); + MoviePlayer *FMVPtr = Kernel::getInstance()->getFMV(); BS_ASSERT(FMVPtr); lua_pushbooleancpp(L, FMVPtr->isPaused()); @@ -107,7 +107,7 @@ int isPaused(lua_State *L) { } int getScaleFactor(lua_State *L) { - MoviePlayer *FMVPtr = Kernel::GetInstance()->GetFMV(); + MoviePlayer *FMVPtr = Kernel::getInstance()->getFMV(); BS_ASSERT(FMVPtr); lua_pushnumber(L, FMVPtr->getScaleFactor()); @@ -116,7 +116,7 @@ int getScaleFactor(lua_State *L) { } int setScaleFactor(lua_State *L) { - MoviePlayer *FMVPtr = Kernel::GetInstance()->GetFMV(); + MoviePlayer *FMVPtr = Kernel::getInstance()->getFMV(); BS_ASSERT(FMVPtr); FMVPtr->setScaleFactor(static_cast<float>(luaL_checknumber(L, 1))); @@ -125,7 +125,7 @@ int setScaleFactor(lua_State *L) { } int getTime(lua_State *L) { - MoviePlayer *FMVPtr = Kernel::GetInstance()->GetFMV(); + MoviePlayer *FMVPtr = Kernel::getInstance()->getFMV(); BS_ASSERT(FMVPtr); lua_pushnumber(L, FMVPtr->getTime()); @@ -150,7 +150,7 @@ const luaL_reg LIBRARY_FUNCTIONS[] = { }; bool MoviePlayer::registerScriptBindings() { - ScriptEngine *pScript = Kernel::GetInstance()->GetScript(); + ScriptEngine *pScript = Kernel::getInstance()->getScript(); BS_ASSERT(pScript); lua_State *L = static_cast<lua_State *>(pScript->getScriptObject()); BS_ASSERT(L); diff --git a/engines/sword25/gfx/animation.cpp b/engines/sword25/gfx/animation.cpp index 3f51c8be4c..fd302be222 100644 --- a/engines/sword25/gfx/animation.cpp +++ b/engines/sword25/gfx/animation.cpp @@ -99,8 +99,8 @@ Animation::Animation(InputPersistenceBlock &reader, RenderObjectPtr<RenderObject void Animation::initializeAnimationResource(const Common::String &fileName) { // Die Resource wird für die gesamte Lebensdauer des Animations-Objektes gelockt. - Resource *resourcePtr = Kernel::GetInstance()->GetResourceManager()->RequestResource(fileName); - if (resourcePtr && resourcePtr->GetType() == Resource::TYPE_ANIMATION) + Resource *resourcePtr = Kernel::getInstance()->getResourceManager()->requestResource(fileName); + if (resourcePtr && resourcePtr->getType() == Resource::TYPE_ANIMATION) _animationResourcePtr = static_cast<AnimationResource *>(resourcePtr); else { BS_LOG_ERRORLN("The resource \"%s\" could not be requested. The Animation can't be created.", fileName.c_str()); @@ -182,13 +182,13 @@ bool Animation::doRender() { BS_ASSERT(_currentFrame < animationDescriptionPtr->getFrameCount()); // Bitmap des aktuellen Frames holen - Resource *pResource = Kernel::GetInstance()->GetResourceManager()->RequestResource(animationDescriptionPtr->getFrame(_currentFrame).fileName); + Resource *pResource = Kernel::getInstance()->getResourceManager()->requestResource(animationDescriptionPtr->getFrame(_currentFrame).fileName); BS_ASSERT(pResource); - BS_ASSERT(pResource->GetType() == Resource::TYPE_BITMAP); + BS_ASSERT(pResource->getType() == Resource::TYPE_BITMAP); BitmapResource *pBitmapResource = static_cast<BitmapResource *>(pResource); // Framebufferobjekt holen - GraphicEngine *pGfx = Kernel::GetInstance()->GetGfx(); + GraphicEngine *pGfx = Kernel::getInstance()->getGfx(); BS_ASSERT(pGfx); // Bitmap zeichnen @@ -315,9 +315,9 @@ void Animation::computeCurrentCharacteristics() { BS_ASSERT(animationDescriptionPtr); const AnimationResource::Frame &curFrame = animationDescriptionPtr->getFrame(_currentFrame); - Resource *pResource = Kernel::GetInstance()->GetResourceManager()->RequestResource(curFrame.fileName); + Resource *pResource = Kernel::getInstance()->getResourceManager()->requestResource(curFrame.fileName); BS_ASSERT(pResource); - BS_ASSERT(pResource->GetType() == Resource::TYPE_BITMAP); + BS_ASSERT(pResource->getType() == Resource::TYPE_BITMAP); BitmapResource *pBitmap = static_cast<BitmapResource *>(pResource); // Größe des Bitmaps auf die Animation übertragen @@ -338,7 +338,7 @@ bool Animation::lockAllFrames() { AnimationDescription *animationDescriptionPtr = getAnimationDescription(); BS_ASSERT(animationDescriptionPtr); for (uint i = 0; i < animationDescriptionPtr->getFrameCount(); ++i) { - if (!Kernel::GetInstance()->GetResourceManager()->RequestResource(animationDescriptionPtr->getFrame(i).fileName)) { + if (!Kernel::getInstance()->getResourceManager()->requestResource(animationDescriptionPtr->getFrame(i).fileName)) { BS_LOG_ERRORLN("Could not lock all animation frames."); return false; } @@ -356,14 +356,14 @@ bool Animation::unlockAllFrames() { BS_ASSERT(animationDescriptionPtr); for (uint i = 0; i < animationDescriptionPtr->getFrameCount(); ++i) { Resource *pResource; - if (!(pResource = Kernel::GetInstance()->GetResourceManager()->RequestResource(animationDescriptionPtr->getFrame(i).fileName))) { + if (!(pResource = Kernel::getInstance()->getResourceManager()->requestResource(animationDescriptionPtr->getFrame(i).fileName))) { BS_LOG_ERRORLN("Could not unlock all animation frames."); return false; } // Zwei mal freigeben um den Request von LockAllFrames() und den jetzigen Request aufzuheben pResource->release(); - if (pResource->GetLockCount()) + if (pResource->getLockCount()) pResource->release(); } @@ -524,9 +524,9 @@ int Animation::computeXModifier() const { BS_ASSERT(animationDescriptionPtr); const AnimationResource::Frame &curFrame = animationDescriptionPtr->getFrame(_currentFrame); - Resource *pResource = Kernel::GetInstance()->GetResourceManager()->RequestResource(curFrame.fileName); + Resource *pResource = Kernel::getInstance()->getResourceManager()->requestResource(curFrame.fileName); BS_ASSERT(pResource); - BS_ASSERT(pResource->GetType() == Resource::TYPE_BITMAP); + BS_ASSERT(pResource->getType() == Resource::TYPE_BITMAP); BitmapResource *pBitmap = static_cast<BitmapResource *>(pResource); int result = curFrame.flipV ? - static_cast<int>((pBitmap->getWidth() - 1 - curFrame.hotspotX) * _scaleFactorX) : @@ -542,9 +542,9 @@ int Animation::computeYModifier() const { BS_ASSERT(animationDescriptionPtr); const AnimationResource::Frame &curFrame = animationDescriptionPtr->getFrame(_currentFrame); - Resource *pResource = Kernel::GetInstance()->GetResourceManager()->RequestResource(curFrame.fileName); + Resource *pResource = Kernel::getInstance()->getResourceManager()->requestResource(curFrame.fileName); BS_ASSERT(pResource); - BS_ASSERT(pResource->GetType() == Resource::TYPE_BITMAP); + BS_ASSERT(pResource->getType() == Resource::TYPE_BITMAP); BitmapResource *pBitmap = static_cast<BitmapResource *>(pResource); int result = curFrame.flipH ? - static_cast<int>((pBitmap->getHeight() - 1 - curFrame.hotspotY) * _scaleFactorY) : diff --git a/engines/sword25/gfx/animationresource.cpp b/engines/sword25/gfx/animationresource.cpp index 6609725c1b..8268ba9c46 100644 --- a/engines/sword25/gfx/animationresource.cpp +++ b/engines/sword25/gfx/animationresource.cpp @@ -54,7 +54,7 @@ AnimationResource::AnimationResource(const Common::String &filename) : Common::XMLParser(), _valid(false) { // Get a pointer to the package manager - _pPackage = Kernel::GetInstance()->GetPackage(); + _pPackage = Kernel::getInstance()->getPackage(); BS_ASSERT(_pPackage); // Switch to the folder the specified Xml fiile is in @@ -211,7 +211,7 @@ AnimationResource::~AnimationResource() { bool AnimationResource::precacheAllFrames() const { Common::Array<Frame>::const_iterator iter = _frames.begin(); for (; iter != _frames.end(); ++iter) { - if (!Kernel::GetInstance()->GetResourceManager()->PrecacheResource((*iter).fileName)) { + if (!Kernel::getInstance()->getResourceManager()->precacheResource((*iter).fileName)) { BS_LOG_ERRORLN("Could not precache \"%s\".", (*iter).fileName.c_str()); return false; } @@ -232,7 +232,7 @@ bool AnimationResource::computeFeatures() { Common::Array<Frame>::const_iterator iter = _frames.begin(); for (; iter != _frames.end(); ++iter) { BitmapResource *pBitmap; - if (!(pBitmap = static_cast<BitmapResource *>(Kernel::GetInstance()->GetResourceManager()->RequestResource((*iter).fileName)))) { + if (!(pBitmap = static_cast<BitmapResource *>(Kernel::getInstance()->getResourceManager()->requestResource((*iter).fileName)))) { BS_LOG_ERRORLN("Could not request \"%s\".", (*iter).fileName.c_str()); return false; } diff --git a/engines/sword25/gfx/animationtemplate.cpp b/engines/sword25/gfx/animationtemplate.cpp index c2dba550d7..948dfbfa4d 100644 --- a/engines/sword25/gfx/animationtemplate.cpp +++ b/engines/sword25/gfx/animationtemplate.cpp @@ -125,9 +125,9 @@ AnimationTemplate::AnimationTemplate(InputPersistenceBlock &reader, uint handle) } AnimationResource *AnimationTemplate::requestSourceAnimation(const Common::String &sourceAnimation) const { - ResourceManager *RMPtr = Kernel::GetInstance()->GetResourceManager(); + ResourceManager *RMPtr = Kernel::getInstance()->getResourceManager(); Resource *resourcePtr; - if (NULL == (resourcePtr = RMPtr->RequestResource(sourceAnimation)) || resourcePtr->GetType() != Resource::TYPE_ANIMATION) { + if (NULL == (resourcePtr = RMPtr->requestResource(sourceAnimation)) || resourcePtr->getType() != Resource::TYPE_ANIMATION) { BS_LOG_ERRORLN("The resource \"%s\" could not be requested or is has an invalid type. The animation template can't be created.", sourceAnimation.c_str()); return 0; } diff --git a/engines/sword25/gfx/dynamicbitmap.cpp b/engines/sword25/gfx/dynamicbitmap.cpp index 2766294d48..612e370712 100644 --- a/engines/sword25/gfx/dynamicbitmap.cpp +++ b/engines/sword25/gfx/dynamicbitmap.cpp @@ -77,7 +77,7 @@ uint DynamicBitmap::getPixel(int x, int y) const { bool DynamicBitmap::doRender() { // Framebufferobjekt holen - GraphicEngine *pGfx = Kernel::GetInstance()->GetGfx(); + GraphicEngine *pGfx = Kernel::getInstance()->getGfx(); BS_ASSERT(pGfx); // Bitmap zeichnen diff --git a/engines/sword25/gfx/fontresource.cpp b/engines/sword25/gfx/fontresource.cpp index 45acb9f045..db2598ffdd 100644 --- a/engines/sword25/gfx/fontresource.cpp +++ b/engines/sword25/gfx/fontresource.cpp @@ -55,7 +55,7 @@ FontResource::FontResource(Kernel *pKernel, const Common::String &fileName) : // Get a pointer to the package manager BS_ASSERT(_pKernel); - PackageManager *pPackage = _pKernel->GetPackage(); + PackageManager *pPackage = _pKernel->getPackage(); BS_ASSERT(pPackage); // Load the contents of the file @@ -93,7 +93,7 @@ bool FontResource::parserCallback_font(ParserNode *node) { // Get a reference to the package manager BS_ASSERT(_pKernel); - PackageManager *pPackage = _pKernel->GetPackage(); + PackageManager *pPackage = _pKernel->getPackage(); BS_ASSERT(pPackage); // Get the full path and filename for the bitmap resource @@ -104,7 +104,7 @@ bool FontResource::parserCallback_font(ParserNode *node) { } // Pre-cache the resource - if (!_pKernel->GetResourceManager()->PrecacheResource(_bitmapFileName)) { + if (!_pKernel->getResourceManager()->precacheResource(_bitmapFileName)) { BS_LOG_ERRORLN("Could not precache \"%s\".", _bitmapFileName.c_str()); } diff --git a/engines/sword25/gfx/graphicengine.cpp b/engines/sword25/gfx/graphicengine.cpp index e16876ddba..37499cc14d 100644 --- a/engines/sword25/gfx/graphicengine.cpp +++ b/engines/sword25/gfx/graphicengine.cpp @@ -306,7 +306,7 @@ Resource *GraphicEngine::loadResource(const Common::String &filename) { debug(2, "VectorImage: %s", filename.c_str()); // Pointer auf Package-Manager holen - PackageManager *pPackage = Kernel::GetInstance()->GetPackage(); + PackageManager *pPackage = Kernel::getInstance()->getPackage(); BS_ASSERT(pPackage); // Datei laden @@ -349,7 +349,7 @@ Resource *GraphicEngine::loadResource(const Common::String &filename) { // Load font if (filename.hasSuffix("_fnt.xml")) { - FontResource *pResource = new FontResource(Kernel::GetInstance(), filename); + FontResource *pResource = new FontResource(Kernel::getInstance(), filename); if (pResource->isValid()) return pResource; else { @@ -383,7 +383,7 @@ void GraphicEngine::drawDebugLine(const Vertex &start, const Vertex &end, uint c void GraphicEngine::updateLastFrameDuration() { // Record current time - const uint currentTime = Kernel::GetInstance()->GetMilliTicks(); + const uint currentTime = Kernel::getInstance()->getMilliTicks(); // Compute the elapsed time since the last frame and prevent too big ( > 250 msecs) time jumps. // These can occur when loading save states, during debugging or due to hardware inaccuracies. diff --git a/engines/sword25/gfx/graphicengine_script.cpp b/engines/sword25/gfx/graphicengine_script.cpp index 97359252db..956c0352f0 100644 --- a/engines/sword25/gfx/graphicengine_script.cpp +++ b/engines/sword25/gfx/graphicengine_script.cpp @@ -209,9 +209,9 @@ static const luaL_reg ANIMATION_TEMPLATE_METHODS[] = { }; static GraphicEngine *getGE() { - Kernel *pKernel = Kernel::GetInstance(); + Kernel *pKernel = Kernel::getInstance(); BS_ASSERT(pKernel); - GraphicEngine *pGE = pKernel->GetGfx(); + GraphicEngine *pGE = pKernel->getGfx(); BS_ASSERT(pGE); return pGE; } @@ -1039,7 +1039,7 @@ static int a_isPlaying(lua_State *L) { } static bool animationLoopPointCallback(uint handle) { - lua_State *L = static_cast<lua_State *>(Kernel::GetInstance()->GetScript()->getScriptObject()); + lua_State *L = static_cast<lua_State *>(Kernel::getInstance()->getScript()->getScriptObject()); loopPointCallbackPtr->invokeCallbackFunctions(L, handle); return true; @@ -1071,7 +1071,7 @@ static bool animationActionCallback(uint Handle) { RenderObjectPtr<Animation> animationPtr(Handle); if (animationPtr.isValid()) { actionCallbackPtr->Action = animationPtr->getCurrentAction(); - lua_State *L = static_cast<lua_State *>(Kernel::GetInstance()->GetScript()->getScriptObject()); + lua_State *L = static_cast<lua_State *>(Kernel::getInstance()->getScript()->getScriptObject()); actionCallbackPtr->invokeCallbackFunctions(L, animationPtr->getHandle()); } @@ -1101,7 +1101,7 @@ static int a_unregisterActionCallback(lua_State *L) { } static bool animationDeleteCallback(uint Handle) { - lua_State *L = static_cast<lua_State *>(Kernel::GetInstance()->GetScript()->getScriptObject()); + lua_State *L = static_cast<lua_State *>(Kernel::getInstance()->getScript()->getScriptObject()); loopPointCallbackPtr->removeAllObjectCallbacks(L, Handle); return true; @@ -1268,9 +1268,9 @@ static const luaL_reg TEXT_METHODS[] = { }; bool GraphicEngine::registerScriptBindings() { - Kernel *pKernel = Kernel::GetInstance(); + Kernel *pKernel = Kernel::getInstance(); BS_ASSERT(pKernel); - ScriptEngine *pScript = pKernel->GetScript(); + ScriptEngine *pScript = pKernel->getScript(); BS_ASSERT(pScript); lua_State *L = static_cast<lua_State *>(pScript->getScriptObject()); BS_ASSERT(L); diff --git a/engines/sword25/gfx/image/renderedimage.cpp b/engines/sword25/gfx/image/renderedimage.cpp index a9ac4e6d26..39dec46d25 100644 --- a/engines/sword25/gfx/image/renderedimage.cpp +++ b/engines/sword25/gfx/image/renderedimage.cpp @@ -56,10 +56,10 @@ RenderedImage::RenderedImage(const Common::String &filename, bool &result) : _height(0) { result = false; - PackageManager *pPackage = Kernel::GetInstance()->GetPackage(); + PackageManager *pPackage = Kernel::getInstance()->getPackage(); BS_ASSERT(pPackage); - _backSurface = Kernel::GetInstance()->GetGfx()->getSurface(); + _backSurface = Kernel::getInstance()->getGfx()->getSurface(); // Datei laden byte *pFileData; @@ -103,7 +103,7 @@ RenderedImage::RenderedImage(uint width, uint height, bool &result) : _data = new byte[width * height * 4]; Common::set_to(_data, &_data[width * height * 4], 0); - _backSurface = Kernel::GetInstance()->GetGfx()->getSurface(); + _backSurface = Kernel::getInstance()->getGfx()->getSurface(); _doCleanup = true; @@ -112,7 +112,7 @@ RenderedImage::RenderedImage(uint width, uint height, bool &result) : } RenderedImage::RenderedImage() : _width(0), _height(0), _data(0) { - _backSurface = Kernel::GetInstance()->GetGfx()->getSurface(); + _backSurface = Kernel::getInstance()->getGfx()->getSurface(); _doCleanup = false; diff --git a/engines/sword25/gfx/image/swimage.cpp b/engines/sword25/gfx/image/swimage.cpp index 04fc8c4bcc..2c27cbe3fc 100644 --- a/engines/sword25/gfx/image/swimage.cpp +++ b/engines/sword25/gfx/image/swimage.cpp @@ -47,7 +47,7 @@ SWImage::SWImage(const Common::String &filename, bool &result) : _height(0) { result = false; - PackageManager *pPackage = Kernel::GetInstance()->GetPackage(); + PackageManager *pPackage = Kernel::getInstance()->getPackage(); BS_ASSERT(pPackage); // Datei laden diff --git a/engines/sword25/gfx/panel.cpp b/engines/sword25/gfx/panel.cpp index 1e2921fd56..2de1de133a 100644 --- a/engines/sword25/gfx/panel.cpp +++ b/engines/sword25/gfx/panel.cpp @@ -77,7 +77,7 @@ bool Panel::doRender() { if (_color >> 24 == 0) return true; - GraphicEngine *gfxPtr = Kernel::GetInstance()->GetGfx(); + GraphicEngine *gfxPtr = Kernel::getInstance()->getGfx(); BS_ASSERT(gfxPtr); return gfxPtr->fill(&_bbox, _color); diff --git a/engines/sword25/gfx/renderobjectmanager.cpp b/engines/sword25/gfx/renderobjectmanager.cpp index 74a69a5d0a..94f7a04b45 100644 --- a/engines/sword25/gfx/renderobjectmanager.cpp +++ b/engines/sword25/gfx/renderobjectmanager.cpp @@ -63,7 +63,7 @@ void RenderObjectManager::startFrame() { _frameStarted = true; // Verstrichene Zeit bestimmen - int timeElapsed = Kernel::GetInstance()->GetGfx()->getLastFrameDurationMicro(); + int timeElapsed = Kernel::getInstance()->getGfx()->getLastFrameDurationMicro(); // Alle BS_TimedRenderObject Objekte über den Framestart und die verstrichene Zeit in Kenntnis setzen RenderObjectList::iterator iter = _timedRenderObjects.begin(); diff --git a/engines/sword25/gfx/staticbitmap.cpp b/engines/sword25/gfx/staticbitmap.cpp index 43e9ef73c6..bbcadb11c6 100644 --- a/engines/sword25/gfx/staticbitmap.cpp +++ b/engines/sword25/gfx/staticbitmap.cpp @@ -58,12 +58,12 @@ StaticBitmap::StaticBitmap(InputPersistenceBlock &reader, RenderObjectPtr<Render bool StaticBitmap::initBitmapResource(const Common::String &filename) { // Bild-Resource laden - Resource *resourcePtr = Kernel::GetInstance()->GetResourceManager()->RequestResource(filename); + Resource *resourcePtr = Kernel::getInstance()->getResourceManager()->requestResource(filename); if (!resourcePtr) { BS_LOG_ERRORLN("Could not request resource \"%s\".", filename.c_str()); return false; } - if (resourcePtr->GetType() != Resource::TYPE_BITMAP) { + if (resourcePtr->getType() != Resource::TYPE_BITMAP) { BS_LOG_ERRORLN("Requested resource \"%s\" is not a bitmap.", filename.c_str()); return false; } @@ -88,13 +88,13 @@ StaticBitmap::~StaticBitmap() { bool StaticBitmap::doRender() { // Bitmap holen - Resource *resourcePtr = Kernel::GetInstance()->GetResourceManager()->RequestResource(_resourceFilename); + Resource *resourcePtr = Kernel::getInstance()->getResourceManager()->requestResource(_resourceFilename); BS_ASSERT(resourcePtr); - BS_ASSERT(resourcePtr->GetType() == Resource::TYPE_BITMAP); + BS_ASSERT(resourcePtr->getType() == Resource::TYPE_BITMAP); BitmapResource *bitmapResourcePtr = static_cast<BitmapResource *>(resourcePtr); // Framebufferobjekt holen - GraphicEngine *gfxPtr = Kernel::GetInstance()->GetGfx(); + GraphicEngine *gfxPtr = Kernel::getInstance()->getGfx(); BS_ASSERT(gfxPtr); // Bitmap zeichnen @@ -121,8 +121,8 @@ uint StaticBitmap::getPixel(int x, int y) const { BS_ASSERT(x >= 0 && x < _width); BS_ASSERT(y >= 0 && y < _height); - Resource *pResource = Kernel::GetInstance()->GetResourceManager()->RequestResource(_resourceFilename); - BS_ASSERT(pResource->GetType() == Resource::TYPE_BITMAP); + Resource *pResource = Kernel::getInstance()->getResourceManager()->requestResource(_resourceFilename); + BS_ASSERT(pResource->getType() == Resource::TYPE_BITMAP); BitmapResource *pBitmapResource = static_cast<BitmapResource *>(pResource); uint result = pBitmapResource->getPixel(x, y); pResource->release(); @@ -135,24 +135,24 @@ bool StaticBitmap::setContent(const byte *pixeldata, uint size, uint offset, uin } bool StaticBitmap::isAlphaAllowed() const { - Resource *pResource = Kernel::GetInstance()->GetResourceManager()->RequestResource(_resourceFilename); - BS_ASSERT(pResource->GetType() == Resource::TYPE_BITMAP); + Resource *pResource = Kernel::getInstance()->getResourceManager()->requestResource(_resourceFilename); + BS_ASSERT(pResource->getType() == Resource::TYPE_BITMAP); bool result = static_cast<BitmapResource *>(pResource)->isAlphaAllowed(); pResource->release(); return result; } bool StaticBitmap::isColorModulationAllowed() const { - Resource *pResource = Kernel::GetInstance()->GetResourceManager()->RequestResource(_resourceFilename); - BS_ASSERT(pResource->GetType() == Resource::TYPE_BITMAP); + Resource *pResource = Kernel::getInstance()->getResourceManager()->requestResource(_resourceFilename); + BS_ASSERT(pResource->getType() == Resource::TYPE_BITMAP); bool result = static_cast<BitmapResource *>(pResource)->isColorModulationAllowed(); pResource->release(); return result; } bool StaticBitmap::isScalingAllowed() const { - Resource *pResource = Kernel::GetInstance()->GetResourceManager()->RequestResource(_resourceFilename); - BS_ASSERT(pResource->GetType() == Resource::TYPE_BITMAP); + Resource *pResource = Kernel::getInstance()->getResourceManager()->requestResource(_resourceFilename); + BS_ASSERT(pResource->getType() == Resource::TYPE_BITMAP); bool result = static_cast<BitmapResource *>(pResource)->isScalingAllowed(); pResource->release(); return result; diff --git a/engines/sword25/gfx/text.cpp b/engines/sword25/gfx/text.cpp index 69e0818503..55a87a41d6 100644 --- a/engines/sword25/gfx/text.cpp +++ b/engines/sword25/gfx/text.cpp @@ -73,7 +73,7 @@ Text::Text(InputPersistenceBlock &reader, RenderObjectPtr<RenderObject> parentPt bool Text::setFont(const Common::String &font) { // Font precachen. - if (getResourceManager()->PrecacheResource(font)) { + if (getResourceManager()->precacheResource(font)) { _font = font; updateFormat(); forceRefresh(); @@ -134,12 +134,12 @@ bool Text::doRender() { ResourceManager *rmPtr = getResourceManager(); BitmapResource *charMapPtr; { - Resource *pResource = rmPtr->RequestResource(fontPtr->getCharactermapFileName()); + Resource *pResource = rmPtr->requestResource(fontPtr->getCharactermapFileName()); if (!pResource) { BS_LOG_ERRORLN("Could not request resource \"%s\".", fontPtr->getCharactermapFileName().c_str()); return false; } - if (pResource->GetType() != Resource::TYPE_BITMAP) { + if (pResource->getType() != Resource::TYPE_BITMAP) { BS_LOG_ERRORLN("Requested resource \"%s\" is not a bitmap.", fontPtr->getCharactermapFileName().c_str()); return false; } @@ -148,7 +148,7 @@ bool Text::doRender() { } // Framebufferobjekt holen. - GraphicEngine *gfxPtr = Kernel::GetInstance()->GetGfx(); + GraphicEngine *gfxPtr = Kernel::getInstance()->getGfx(); BS_ASSERT(gfxPtr); bool result = true; @@ -187,7 +187,7 @@ bool Text::doRender() { ResourceManager *Text::getResourceManager() { // Pointer auf den Resource-Manager holen. - return Kernel::GetInstance()->GetResourceManager(); + return Kernel::getInstance()->getResourceManager(); } FontResource *Text::lockFontResource() { @@ -196,12 +196,12 @@ FontResource *Text::lockFontResource() { // Font-Resource locken. FontResource *fontPtr; { - Resource *resourcePtr = rmPtr->RequestResource(_font); + Resource *resourcePtr = rmPtr->requestResource(_font); if (!resourcePtr) { BS_LOG_ERRORLN("Could not request resource \"%s\".", _font.c_str()); return NULL; } - if (resourcePtr->GetType() != Resource::TYPE_FONT) { + if (resourcePtr->getType() != Resource::TYPE_FONT) { BS_LOG_ERRORLN("Requested resource \"%s\" is not a font.", _font.c_str()); return NULL; } diff --git a/engines/sword25/input/inputengine.cpp b/engines/sword25/input/inputengine.cpp index 9936a20127..181e13b7ff 100644 --- a/engines/sword25/input/inputengine.cpp +++ b/engines/sword25/input/inputengine.cpp @@ -51,24 +51,24 @@ namespace Sword25 { InputEngine::InputEngine(Kernel *pKernel) : Service(pKernel), - m_CurrentState(0), - m_LeftMouseDown(false), - m_RightMouseDown(false), - m_MouseX(0), - m_MouseY(0), - m_LeftDoubleClick(false), - m_DoubleClickTime(DOUBLE_CLICK_TIME), - m_DoubleClickRectWidth(DOUBLE_CLICK_RECT_SIZE), - m_DoubleClickRectHeight(DOUBLE_CLICK_RECT_SIZE), - m_LastLeftClickTime(0), - m_LastLeftClickMouseX(0), - m_LastLeftClickMouseY(0) { - memset(m_KeyboardState[0], 0, sizeof(m_KeyboardState[0])); - memset(m_KeyboardState[1], 0, sizeof(m_KeyboardState[1])); - m_LeftMouseState[0] = false; - m_LeftMouseState[1] = false; - m_RightMouseState[0] = false; - m_RightMouseState[1] = false; + _currentState(0), + _leftMouseDown(false), + _rightMouseDown(false), + _mouseX(0), + _mouseY(0), + _leftDoubleClick(false), + _doubleClickTime(DOUBLE_CLICK_TIME), + _doubleClickRectWidth(DOUBLE_CLICK_RECT_SIZE), + _doubleClickRectHeight(DOUBLE_CLICK_RECT_SIZE), + _lastLeftClickTime(0), + _lastLeftClickMouseX(0), + _lastLeftClickMouseY(0) { + memset(_keyboardState[0], 0, sizeof(_keyboardState[0])); + memset(_keyboardState[1], 0, sizeof(_keyboardState[1])); + _leftMouseState[0] = false; + _leftMouseState[1] = false; + _rightMouseState[0] = false; + _rightMouseState[1] = false; if (!registerScriptBindings()) BS_LOG_ERRORLN("Script bindings could not be registered."); @@ -80,18 +80,14 @@ Service *InputEngine_CreateObject(Kernel *pKernel) { return new InputEngine(pKernel); } -// ----------------------------------------------------------------------------- - -bool InputEngine::Init() { +bool InputEngine::init() { // No initialisation needed return true; } -// ----------------------------------------------------------------------------- - -void InputEngine::Update() { +void InputEngine::update() { Common::Event event; - m_CurrentState ^= 1; + _currentState ^= 1; // Loop through processing any pending events bool handleEvents = true; @@ -99,31 +95,31 @@ void InputEngine::Update() { switch (event.type) { case Common::EVENT_LBUTTONDOWN: case Common::EVENT_LBUTTONUP: - m_LeftMouseDown = event.type == Common::EVENT_LBUTTONDOWN; - m_MouseX = event.mouse.x; - m_MouseY = event.mouse.y; + _leftMouseDown = event.type == Common::EVENT_LBUTTONDOWN; + _mouseX = event.mouse.x; + _mouseY = event.mouse.y; handleEvents = false; break; case Common::EVENT_RBUTTONDOWN: case Common::EVENT_RBUTTONUP: - m_RightMouseDown = event.type == Common::EVENT_RBUTTONDOWN; - m_MouseX = event.mouse.x; - m_MouseY = event.mouse.y; + _rightMouseDown = event.type == Common::EVENT_RBUTTONDOWN; + _mouseX = event.mouse.x; + _mouseY = event.mouse.y; handleEvents = false; break; case Common::EVENT_MOUSEMOVE: - m_MouseX = event.mouse.x; - m_MouseY = event.mouse.y; + _mouseX = event.mouse.x; + _mouseY = event.mouse.y; break; case Common::EVENT_KEYDOWN: case Common::EVENT_KEYUP: - AlterKeyboardState(event.kbd.keycode, (event.type == Common::EVENT_KEYDOWN) ? 0x80 : 0); + alterKeyboardState(event.kbd.keycode, (event.type == Common::EVENT_KEYDOWN) ? 0x80 : 0); break; case Common::EVENT_QUIT: - Kernel::GetInstance()->GetWindow()->SetWindowAlive(false); + Kernel::getInstance()->getWindow()->setWindowAlive(false); break; default: @@ -131,125 +127,97 @@ void InputEngine::Update() { } } - m_LeftMouseState[m_CurrentState] = m_LeftMouseDown; - m_RightMouseState[m_CurrentState] = m_RightMouseDown; + _leftMouseState[_currentState] = _leftMouseDown; + _rightMouseState[_currentState] = _rightMouseDown; - TestForLeftDoubleClick(); + testForLeftDoubleClick(); } -// ----------------------------------------------------------------------------- - -bool InputEngine::IsLeftMouseDown() { - return m_LeftMouseDown; +bool InputEngine::isLeftMouseDown() { + return _leftMouseDown; } -// ----------------------------------------------------------------------------- - -bool InputEngine::IsRightMouseDown() { - return m_RightMouseDown; +bool InputEngine::isRightMouseDown() { + return _rightMouseDown; } -// ----------------------------------------------------------------------------- - -void InputEngine::TestForLeftDoubleClick() { - m_LeftDoubleClick = false; +void InputEngine::testForLeftDoubleClick() { + _leftDoubleClick = false; // Only bother checking for a double click if the left mouse button was clicked - if (WasLeftMouseDown()) { + if (wasLeftMouseDown()) { // Get the time now - uint Now = Kernel::GetInstance()->GetMilliTicks(); + uint now = Kernel::getInstance()->getMilliTicks(); // A double click is signalled if // 1. The two clicks are close enough together // 2. The mouse cursor hasn't moved much - if (Now - m_LastLeftClickTime <= m_DoubleClickTime && - ABS(m_MouseX - m_LastLeftClickMouseX) <= m_DoubleClickRectWidth / 2 && - ABS(m_MouseY - m_LastLeftClickMouseY) <= m_DoubleClickRectHeight / 2) { - m_LeftDoubleClick = true; + if (now - _lastLeftClickTime <= _doubleClickTime && + ABS(_mouseX - _lastLeftClickMouseX) <= _doubleClickRectWidth / 2 && + ABS(_mouseY - _lastLeftClickMouseY) <= _doubleClickRectHeight / 2) { + _leftDoubleClick = true; // Reset the time and position of the last click, so that clicking is not // interpreted as the first click of a further double-click - m_LastLeftClickTime = 0; - m_LastLeftClickMouseX = 0; - m_LastLeftClickMouseY = 0; + _lastLeftClickTime = 0; + _lastLeftClickMouseX = 0; + _lastLeftClickMouseY = 0; } else { // There is no double click. Remember the position and time of the click, // in case it's the first click of a double-click sequence - m_LastLeftClickTime = Now; - m_LastLeftClickMouseX = m_MouseX; - m_LastLeftClickMouseY = m_MouseY; + _lastLeftClickTime = now; + _lastLeftClickMouseX = _mouseX; + _lastLeftClickMouseY = _mouseY; } } } -// ----------------------------------------------------------------------------- - -void InputEngine::AlterKeyboardState(int keycode, byte newState) { - m_KeyboardState[m_CurrentState][keycode] = newState; +void InputEngine::alterKeyboardState(int keycode, byte newState) { + _keyboardState[_currentState][keycode] = newState; } -// ----------------------------------------------------------------------------- - -bool InputEngine::IsLeftDoubleClick() { - return m_LeftDoubleClick; +bool InputEngine::isLeftDoubleClick() { + return _leftDoubleClick; } -// ----------------------------------------------------------------------------- - -bool InputEngine::WasLeftMouseDown() { - return (m_LeftMouseState[m_CurrentState] == false) && (m_LeftMouseState[m_CurrentState ^ 1] == true); +bool InputEngine::wasLeftMouseDown() { + return (_leftMouseState[_currentState] == false) && (_leftMouseState[_currentState ^ 1] == true); } -// ----------------------------------------------------------------------------- - -bool InputEngine::WasRightMouseDown() { - return (m_RightMouseState[m_CurrentState] == false) && (m_RightMouseState[m_CurrentState ^ 1] == true); +bool InputEngine::wasRightMouseDown() { + return (_rightMouseState[_currentState] == false) && (_rightMouseState[_currentState ^ 1] == true); } -// ----------------------------------------------------------------------------- - -int InputEngine::GetMouseX() { - return m_MouseX; +int InputEngine::getMouseX() { + return _mouseX; } -// ----------------------------------------------------------------------------- - -int InputEngine::GetMouseY() { - return m_MouseY; +int InputEngine::getMouseY() { + return _mouseY; } -// ----------------------------------------------------------------------------- - -bool InputEngine::IsKeyDown(uint KeyCode) { - return (m_KeyboardState[m_CurrentState][KeyCode] & 0x80) != 0; +bool InputEngine::isKeyDown(uint keyCode) { + return (_keyboardState[_currentState][keyCode] & 0x80) != 0; } -// ----------------------------------------------------------------------------- - -bool InputEngine::WasKeyDown(uint KeyCode) { - return ((m_KeyboardState[m_CurrentState][KeyCode] & 0x80) == 0) && - ((m_KeyboardState[m_CurrentState ^ 1][KeyCode] & 0x80) != 0); +bool InputEngine::wasKeyDown(uint keyCode) { + return ((_keyboardState[_currentState][keyCode] & 0x80) == 0) && + ((_keyboardState[_currentState ^ 1][keyCode] & 0x80) != 0); } -// ----------------------------------------------------------------------------- - -void InputEngine::SetMouseX(int PosX) { - m_MouseX = PosX; - g_system->warpMouse(m_MouseX, m_MouseY); +void InputEngine::setMouseX(int posX) { + _mouseX = posX; + g_system->warpMouse(_mouseX, _mouseY); } -// ----------------------------------------------------------------------------- - -void InputEngine::SetMouseY(int PosY) { - m_MouseY = PosY; - g_system->warpMouse(m_MouseX, m_MouseY); +void InputEngine::setMouseY(int posY) { + _mouseY = posY; + g_system->warpMouse(_mouseX, _mouseY); } -// ----------------------------------------------------------------------------- - -bool InputEngine::RegisterCharacterCallback(CharacterCallback Callback) { - if (Common::find(m_CharacterCallbacks.begin(), m_CharacterCallbacks.end(), Callback) == m_CharacterCallbacks.end()) { - m_CharacterCallbacks.push_back(Callback); +bool InputEngine::registerCharacterCallback(CharacterCallback callback) { + if (Common::find(_characterCallbacks.begin(), _characterCallbacks.end(), callback) == _characterCallbacks.end()) { + _characterCallbacks.push_back(callback); return true; } else { BS_LOG_WARNINGLN("Tried to register an CharacterCallback that was already registered."); @@ -257,13 +225,11 @@ bool InputEngine::RegisterCharacterCallback(CharacterCallback Callback) { } } -// ----------------------------------------------------------------------------- - -bool InputEngine::UnregisterCharacterCallback(CharacterCallback Callback) { - Common::List<CharacterCallback>::iterator CallbackIter = Common::find(m_CharacterCallbacks.begin(), - m_CharacterCallbacks.end(), Callback); - if (CallbackIter != m_CharacterCallbacks.end()) { - m_CharacterCallbacks.erase(CallbackIter); +bool InputEngine::unregisterCharacterCallback(CharacterCallback callback) { + Common::List<CharacterCallback>::iterator callbackIter = Common::find(_characterCallbacks.begin(), + _characterCallbacks.end(), callback); + if (callbackIter != _characterCallbacks.end()) { + _characterCallbacks.erase(callbackIter); return true; } else { BS_LOG_WARNINGLN("Tried to unregister an CharacterCallback that was not previously registered."); @@ -271,11 +237,9 @@ bool InputEngine::UnregisterCharacterCallback(CharacterCallback Callback) { } } -// ----------------------------------------------------------------------------- - -bool InputEngine::RegisterCommandCallback(CommandCallback Callback) { - if (Common::find(m_CommandCallbacks.begin(), m_CommandCallbacks.end(), Callback) == m_CommandCallbacks.end()) { - m_CommandCallbacks.push_back(Callback); +bool InputEngine::registerCommandCallback(CommandCallback callback) { + if (Common::find(_commandCallbacks.begin(), _commandCallbacks.end(), callback) == _commandCallbacks.end()) { + _commandCallbacks.push_back(callback); return true; } else { BS_LOG_WARNINGLN("Tried to register an CommandCallback that was already registered."); @@ -283,13 +247,11 @@ bool InputEngine::RegisterCommandCallback(CommandCallback Callback) { } } -// ----------------------------------------------------------------------------- - -bool InputEngine::UnregisterCommandCallback(CommandCallback Callback) { - Common::List<CommandCallback>::iterator CallbackIter = - Common::find(m_CommandCallbacks.begin(), m_CommandCallbacks.end(), Callback); - if (CallbackIter != m_CommandCallbacks.end()) { - m_CommandCallbacks.erase(CallbackIter); +bool InputEngine::unregisterCommandCallback(CommandCallback callback) { + Common::List<CommandCallback>::iterator callbackIter = + Common::find(_commandCallbacks.begin(), _commandCallbacks.end(), callback); + if (callbackIter != _commandCallbacks.end()) { + _commandCallbacks.erase(callbackIter); return true; } else { BS_LOG_WARNINGLN("Tried to unregister an CommandCallback that was not previously registered."); @@ -297,60 +259,52 @@ bool InputEngine::UnregisterCommandCallback(CommandCallback Callback) { } } -// ----------------------------------------------------------------------------- - -void InputEngine::ReportCharacter(byte Character) { - Common::List<CharacterCallback>::const_iterator CallbackIter = m_CharacterCallbacks.begin(); - while (CallbackIter != m_CharacterCallbacks.end()) { +void InputEngine::reportCharacter(byte character) { + Common::List<CharacterCallback>::const_iterator callbackIter = _characterCallbacks.begin(); + while (callbackIter != _characterCallbacks.end()) { // Iterator vor dem Aufruf erhöhen und im Folgendem auf einer Kopie arbeiten. // Dieses Vorgehen ist notwendig da der Iterator möglicherweise von der Callbackfunktion durch das Deregistrieren des Callbacks // invalidiert wird. - Common::List<CharacterCallback>::const_iterator CurCallbackIter = CallbackIter; - ++CallbackIter; + Common::List<CharacterCallback>::const_iterator curCallbackIter = callbackIter; + ++callbackIter; - (*CurCallbackIter)(Character); + (*curCallbackIter)(character); } } -// ----------------------------------------------------------------------------- - -void InputEngine::ReportCommand(KEY_COMMANDS Command) { - Common::List<CommandCallback>::const_iterator CallbackIter = m_CommandCallbacks.begin(); - while (CallbackIter != m_CommandCallbacks.end()) { +void InputEngine::reportCommand(KEY_COMMANDS command) { + Common::List<CommandCallback>::const_iterator callbackIter = _commandCallbacks.begin(); + while (callbackIter != _commandCallbacks.end()) { // Iterator vor dem Aufruf erhöhen und im Folgendem auf einer Kopie arbeiten. // Dieses Vorgehen ist notwendig da der Iterator möglicherweise von der Callbackfunktion durch das Deregistrieren des Callbacks // invalidiert wird. - Common::List<CommandCallback>::const_iterator CurCallbackIter = CallbackIter; - ++CallbackIter; + Common::List<CommandCallback>::const_iterator curCallbackIter = callbackIter; + ++callbackIter; - (*CurCallbackIter)(Command); + (*curCallbackIter)(command); } } -// ----------------------------------------------------------------------------- -// Persistenz -// ----------------------------------------------------------------------------- - bool InputEngine::persist(OutputPersistenceBlock &writer) { // Anzahl an Command-Callbacks persistieren. - writer.write(m_CommandCallbacks.size()); + writer.write(_commandCallbacks.size()); // Alle Command-Callbacks einzeln persistieren. { - Common::List<CommandCallback>::const_iterator It = m_CommandCallbacks.begin(); - while (It != m_CommandCallbacks.end()) { + Common::List<CommandCallback>::const_iterator It = _commandCallbacks.begin(); + while (It != _commandCallbacks.end()) { writer.write(CallbackRegistry::instance().resolveCallbackPointer(*It)); ++It; } } // Anzahl an Character-Callbacks persistieren. - writer.write(m_CharacterCallbacks.size()); + writer.write(_characterCallbacks.size()); // Alle Character-Callbacks einzeln persistieren. { - Common::List<CharacterCallback>::const_iterator It = m_CharacterCallbacks.begin(); - while (It != m_CharacterCallbacks.end()) { + Common::List<CharacterCallback>::const_iterator It = _characterCallbacks.begin(); + while (It != _characterCallbacks.end()) { writer.write(CallbackRegistry::instance().resolveCallbackPointer(*It)); ++It; } @@ -359,38 +313,36 @@ bool InputEngine::persist(OutputPersistenceBlock &writer) { return true; } -// ----------------------------------------------------------------------------- - bool InputEngine::unpersist(InputPersistenceBlock &reader) { // Command-Callbackliste leeren. - m_CommandCallbacks.clear(); + _commandCallbacks.clear(); // Anzahl an Command-Callbacks lesen. - uint CommandCallbackCount; - reader.read(CommandCallbackCount); + uint commandCallbackCount; + reader.read(commandCallbackCount); // Alle Command-Callbacks wieder herstellen. - for (uint i = 0; i < CommandCallbackCount; ++i) { - Common::String CallbackFunctionName; - reader.read(CallbackFunctionName); + for (uint i = 0; i < commandCallbackCount; ++i) { + Common::String callbackFunctionName; + reader.read(callbackFunctionName); - m_CommandCallbacks.push_back(reinterpret_cast<CommandCallback>( - CallbackRegistry::instance().resolveCallbackFunction(CallbackFunctionName))); + _commandCallbacks.push_back(reinterpret_cast<CommandCallback>( + CallbackRegistry::instance().resolveCallbackFunction(callbackFunctionName))); } // Character-Callbackliste leeren. - m_CharacterCallbacks.clear(); + _characterCallbacks.clear(); // Anzahl an Character-Callbacks lesen. - uint CharacterCallbackCount; - reader.read(CharacterCallbackCount); + uint characterCallbackCount; + reader.read(characterCallbackCount); // Alle Character-Callbacks wieder herstellen. - for (uint i = 0; i < CharacterCallbackCount; ++i) { - Common::String CallbackFunctionName; - reader.read(CallbackFunctionName); + for (uint i = 0; i < characterCallbackCount; ++i) { + Common::String callbackFunctionName; + reader.read(callbackFunctionName); - m_CharacterCallbacks.push_back(reinterpret_cast<CharacterCallback>(CallbackRegistry::instance().resolveCallbackFunction(CallbackFunctionName))); + _characterCallbacks.push_back(reinterpret_cast<CharacterCallback>(CallbackRegistry::instance().resolveCallbackFunction(callbackFunctionName))); } return reader.isGood(); diff --git a/engines/sword25/input/inputengine.h b/engines/sword25/input/inputengine.h index 59ce8fedc4..07e56928cb 100644 --- a/engines/sword25/input/inputengine.h +++ b/engines/sword25/input/inputengine.h @@ -45,7 +45,6 @@ #ifndef SWORD25_INPUTENGINE_H #define SWORD25_INPUTENGINE_H -/// Includes #include "sword25/kernel/common.h" #include "sword25/kernel/service.h" #include "sword25/kernel/persistable.h" @@ -176,7 +175,7 @@ public: * Initialises the input engine * @return Returns a true on success, otherwise false. */ - bool Init(); + bool init(); /** * Performs a "tick" of the input engine. @@ -185,17 +184,17 @@ public: * of the input engine that are not running in their own thread, or to perform * additional administrative tasks that are needed. */ - void Update(); + void update(); /** * Returns true if the left mouse button is pressed */ - bool IsLeftMouseDown(); + bool isLeftMouseDown(); /** * Returns true if the right mouse button is pressed. */ - bool IsRightMouseDown(); + bool isRightMouseDown(); /** * Returns true if the left mouse button was pressed and released. @@ -203,7 +202,7 @@ public: * The difference between this and IsLeftMouseDown() is that this only returns * true when the left mouse button is released. */ - bool WasLeftMouseDown(); + bool wasLeftMouseDown(); /** * Returns true if the right mouse button was pressed and released. @@ -211,39 +210,39 @@ public: * The difference between this and IsRightMouseDown() is that this only returns * true when the right mouse button is released. */ - bool WasRightMouseDown(); + bool wasRightMouseDown(); /** * Returns true if the left mouse button double click was done */ - bool IsLeftDoubleClick(); + bool isLeftDoubleClick(); /** * Returns the X position of the cursor in pixels */ - int GetMouseX(); + int getMouseX(); /** * Returns the Y position of the cursor in pixels */ - int GetMouseY(); + int getMouseY(); /** * Sets the X position of the cursor in pixels */ - void SetMouseX(int PosX); + void setMouseX(int posX); /** * Sets the Y position of the cursor in pixels */ - void SetMouseY(int PosY); + void setMouseY(int posY); /** * Returns true if a given key was pressed * @param KeyCode The key code to be checked * @return Returns true if the given key is done, otherwise false. */ - bool IsKeyDown(uint KeyCode); + bool isKeyDown(uint keyCode); /** * Returns true if a certain key was pushed and released. @@ -253,7 +252,7 @@ public: * strings that users type. * @param KeyCode The key code to be checked */ - bool WasKeyDown(uint KeyCode); + bool wasKeyDown(uint keyCode); typedef CallbackPtr CharacterCallback; @@ -269,13 +268,13 @@ public: * The input of strings by the user through use of callbacks should be implemented. * @return Returns true if the function was registered, otherwise false. */ - bool RegisterCharacterCallback(CallbackPtr Callback); + bool registerCharacterCallback(CallbackPtr callback); /** * De-registeres a previously registered callback function. * @return Returns true if the function could be de-registered, otherwise false. */ - bool UnregisterCharacterCallback(CallbackPtr Callback); + bool unregisterCharacterCallback(CallbackPtr callback); typedef CallbackPtr CommandCallback; @@ -288,16 +287,16 @@ public: * The input of strings by the user through the use of callbacks should be implemented. * @return Returns true if the function was registered, otherwise false. */ - bool RegisterCommandCallback(CallbackPtr Callback); + bool registerCommandCallback(CallbackPtr callback); /** * Un-register a callback function for the input of commands that can have an influence on the string input. * @return Returns true if the function could be de-registered, otherwise false. */ - bool UnregisterCommandCallback(CommandCallback Callback); + bool unregisterCommandCallback(CommandCallback callback); - void ReportCharacter(byte Character); - void ReportCommand(KEY_COMMANDS Command); + void reportCharacter(byte character); + void reportCommand(KEY_COMMANDS command); bool persist(OutputPersistenceBlock &writer); bool unpersist(InputPersistenceBlock &reader); @@ -306,26 +305,26 @@ private: bool registerScriptBindings(); private: - void TestForLeftDoubleClick(); - void AlterKeyboardState(int keycode, byte newState); - - byte m_KeyboardState[2][256]; - bool m_LeftMouseState[2]; - bool m_RightMouseState[2]; - uint m_CurrentState; - int m_MouseX; - int m_MouseY; - bool m_LeftMouseDown; - bool m_RightMouseDown; - bool m_LeftDoubleClick; - uint m_DoubleClickTime; - int m_DoubleClickRectWidth; - int m_DoubleClickRectHeight; - uint m_LastLeftClickTime; - int m_LastLeftClickMouseX; - int m_LastLeftClickMouseY; - Common::List<CommandCallback> m_CommandCallbacks; - Common::List<CharacterCallback> m_CharacterCallbacks; + void testForLeftDoubleClick(); + void alterKeyboardState(int keycode, byte newState); + + byte _keyboardState[2][256]; + bool _leftMouseState[2]; + bool _rightMouseState[2]; + uint _currentState; + int _mouseX; + int _mouseY; + bool _leftMouseDown; + bool _rightMouseDown; + bool _leftDoubleClick; + uint _doubleClickTime; + int _doubleClickRectWidth; + int _doubleClickRectHeight; + uint _lastLeftClickTime; + int _lastLeftClickMouseX; + int _lastLeftClickMouseY; + Common::List<CommandCallback> _commandCallbacks; + Common::List<CharacterCallback> _characterCallbacks; }; } // End of namespace Sword25 diff --git a/engines/sword25/input/inputengine_script.cpp b/engines/sword25/input/inputengine_script.cpp index 2b1f3b9ec6..303f0e69e1 100644 --- a/engines/sword25/input/inputengine_script.cpp +++ b/engines/sword25/input/inputengine_script.cpp @@ -32,10 +32,6 @@ * */ -// ----------------------------------------------------------------------------- -// Includes -// ----------------------------------------------------------------------------- - #include "common/ptr.h" #include "common/str.h" #include "sword25/kernel/common.h" @@ -51,268 +47,218 @@ namespace Sword25 { -// ----------------------------------------------------------------------------- -// Callback-Objekte -// ----------------------------------------------------------------------------- - -static void TheCharacterCallback(int Character); -static void TheCommandCallback(int Command); +static void theCharacterCallback(int character); +static void theCommandCallback(int command); namespace { class CharacterCallbackClass : public LuaCallback { public: CharacterCallbackClass(lua_State *L) : LuaCallback(L) {} - Common::String Character; + Common::String _character; protected: int PreFunctionInvokation(lua_State *L) { - lua_pushstring(L, Character.c_str()); + lua_pushstring(L, _character.c_str()); return 1; } }; -Common::SharedPtr<CharacterCallbackClass> CharacterCallbackPtr; - -// ----------------------------------------------------------------------------- +Common::SharedPtr<CharacterCallbackClass> characterCallbackPtr; class CommandCallbackClass : public LuaCallback { public: CommandCallbackClass(lua_State *L) : LuaCallback(L) { - Command = InputEngine::KEY_COMMAND_BACKSPACE; + _command = InputEngine::KEY_COMMAND_BACKSPACE; } - InputEngine::KEY_COMMANDS Command; + InputEngine::KEY_COMMANDS _command; protected: - int PreFunctionInvokation(lua_State *L) { - lua_pushnumber(L, Command); + int preFunctionInvokation(lua_State *L) { + lua_pushnumber(L, _command); return 1; } }; -Common::SharedPtr<CommandCallbackClass> CommandCallbackPtr; - -// ------------------------------------------------------------------------- +Common::SharedPtr<CommandCallbackClass> commandCallbackPtr; struct CallbackfunctionRegisterer { CallbackfunctionRegisterer() { - CallbackRegistry::instance().registerCallbackFunction("LuaCommandCB", TheCommandCallback); - CallbackRegistry::instance().registerCallbackFunction("LuaCharacterCB", TheCharacterCallback); + CallbackRegistry::instance().registerCallbackFunction("LuaCommandCB", theCommandCallback); + CallbackRegistry::instance().registerCallbackFunction("LuaCharacterCB", theCharacterCallback); } }; -static CallbackfunctionRegisterer Instance; +static CallbackfunctionRegisterer instance; } -// ----------------------------------------------------------------------------- - -static InputEngine *GetIE() { - Kernel *pKernel = Kernel::GetInstance(); +static InputEngine *getIE() { + Kernel *pKernel = Kernel::getInstance(); BS_ASSERT(pKernel); - InputEngine *pIE = pKernel->GetInput(); + InputEngine *pIE = pKernel->getInput(); BS_ASSERT(pIE); return pIE; } -// ----------------------------------------------------------------------------- - -static int Init(lua_State *L) { - InputEngine *pIE = GetIE(); +static int init(lua_State *L) { + InputEngine *pIE = getIE(); - lua_pushbooleancpp(L, pIE->Init()); + lua_pushbooleancpp(L, pIE->init()); return 1; } -// ----------------------------------------------------------------------------- - -static int Update(lua_State *L) { - InputEngine *pIE = GetIE(); +static int update(lua_State *L) { + InputEngine *pIE = getIE(); // Beim ersten Aufruf der Update()-Methode werden die beiden Callbacks am Input-Objekt registriert. // Dieses kann nicht in _RegisterScriptBindings() passieren, da diese Funktion vom Konstruktor der abstrakten Basisklasse aufgerufen wird und die // Register...()-Methoden abstrakt sind, im Konstruktor der Basisklasse also nicht aufgerufen werden können. - static bool FirstCall = true; - if (FirstCall) { - FirstCall = false; - pIE->RegisterCharacterCallback(TheCharacterCallback); - pIE->RegisterCommandCallback(TheCommandCallback); + static bool firstCall = true; + if (firstCall) { + firstCall = false; + pIE->registerCharacterCallback(theCharacterCallback); + pIE->registerCommandCallback(theCommandCallback); } - pIE->Update(); + pIE->update(); return 0; } -// ----------------------------------------------------------------------------- +static int isLeftMouseDown(lua_State *L) { + InputEngine *pIE = getIE(); -static int IsLeftMouseDown(lua_State *L) { - InputEngine *pIE = GetIE(); - - lua_pushbooleancpp(L, pIE->IsLeftMouseDown()); + lua_pushbooleancpp(L, pIE->isLeftMouseDown()); return 1; } -// ----------------------------------------------------------------------------- - -static int IsRightMouseDown(lua_State *L) { - InputEngine *pIE = GetIE(); +static int isRightMouseDown(lua_State *L) { + InputEngine *pIE = getIE(); - lua_pushbooleancpp(L, pIE->IsRightMouseDown()); + lua_pushbooleancpp(L, pIE->isRightMouseDown()); return 1; } -// ----------------------------------------------------------------------------- - -static int WasLeftMouseDown(lua_State *L) { - InputEngine *pIE = GetIE(); +static int wasLeftMouseDown(lua_State *L) { + InputEngine *pIE = getIE(); - lua_pushbooleancpp(L, pIE->WasLeftMouseDown()); + lua_pushbooleancpp(L, pIE->wasLeftMouseDown()); return 1; } -// ----------------------------------------------------------------------------- - -static int WasRightMouseDown(lua_State *L) { - InputEngine *pIE = GetIE(); +static int wasRightMouseDown(lua_State *L) { + InputEngine *pIE = getIE(); - lua_pushbooleancpp(L, pIE->WasRightMouseDown()); + lua_pushbooleancpp(L, pIE->wasRightMouseDown()); return 1; } -// ----------------------------------------------------------------------------- - -static int IsLeftDoubleClick(lua_State *L) { - InputEngine *pIE = GetIE(); +static int isLeftDoubleClick(lua_State *L) { + InputEngine *pIE = getIE(); - lua_pushbooleancpp(L, pIE->IsLeftDoubleClick()); + lua_pushbooleancpp(L, pIE->isLeftDoubleClick()); return 1; } -// ----------------------------------------------------------------------------- - -static int GetMouseX(lua_State *L) { - InputEngine *pIE = GetIE(); +static int getMouseX(lua_State *L) { + InputEngine *pIE = getIE(); - lua_pushnumber(L, pIE->GetMouseX()); + lua_pushnumber(L, pIE->getMouseX()); return 1; } -// ----------------------------------------------------------------------------- - -static int GetMouseY(lua_State *L) { - InputEngine *pIE = GetIE(); +static int getMouseY(lua_State *L) { + InputEngine *pIE = getIE(); - lua_pushnumber(L, pIE->GetMouseY()); + lua_pushnumber(L, pIE->getMouseY()); return 1; } -// ----------------------------------------------------------------------------- - -static int IsKeyDown(lua_State *L) { - InputEngine *pIE = GetIE(); +static int isKeyDown(lua_State *L) { + InputEngine *pIE = getIE(); - lua_pushbooleancpp(L, pIE->IsKeyDown((uint) luaL_checknumber(L, 1))); + lua_pushbooleancpp(L, pIE->isKeyDown((uint)luaL_checknumber(L, 1))); return 1; } -// ----------------------------------------------------------------------------- +static int wasKeyDown(lua_State *L) { + InputEngine *pIE = getIE(); -static int WasKeyDown(lua_State *L) { - InputEngine *pIE = GetIE(); - - lua_pushbooleancpp(L, pIE->WasKeyDown((uint) luaL_checknumber(L, 1))); + lua_pushbooleancpp(L, pIE->wasKeyDown((uint)luaL_checknumber(L, 1))); return 1; } -// ----------------------------------------------------------------------------- - -static int SetMouseX(lua_State *L) { - InputEngine *pIE = GetIE(); +static int setMouseX(lua_State *L) { + InputEngine *pIE = getIE(); - pIE->SetMouseX((int) luaL_checknumber(L, 1)); + pIE->setMouseX((int)luaL_checknumber(L, 1)); return 0; } -// ----------------------------------------------------------------------------- - -static int SetMouseY(lua_State *L) { - InputEngine *pIE = GetIE(); +static int setMouseY(lua_State *L) { + InputEngine *pIE = getIE(); - pIE->SetMouseY((int) luaL_checknumber(L, 1)); + pIE->setMouseY((int)luaL_checknumber(L, 1)); return 0; } -// ----------------------------------------------------------------------------- - -static void TheCharacterCallback(int Character) { - CharacterCallbackPtr->Character = static_cast<byte>(Character); - lua_State *L = static_cast<lua_State *>(Kernel::GetInstance()->GetScript()->getScriptObject()); - CharacterCallbackPtr->invokeCallbackFunctions(L, 1); +static void theCharacterCallback(int character) { + characterCallbackPtr->_character = static_cast<byte>(character); + lua_State *L = static_cast<lua_State *>(Kernel::getInstance()->getScript()->getScriptObject()); + characterCallbackPtr->invokeCallbackFunctions(L, 1); } -// ----------------------------------------------------------------------------- - -static int RegisterCharacterCallback(lua_State *L) { +static int registerCharacterCallback(lua_State *L) { luaL_checktype(L, 1, LUA_TFUNCTION); - CharacterCallbackPtr->registerCallbackFunction(L, 1); + characterCallbackPtr->registerCallbackFunction(L, 1); return 0; } -// ----------------------------------------------------------------------------- - -static int UnregisterCharacterCallback(lua_State *L) { +static int unregisterCharacterCallback(lua_State *L) { luaL_checktype(L, 1, LUA_TFUNCTION); - CharacterCallbackPtr->unregisterCallbackFunction(L, 1); + characterCallbackPtr->unregisterCallbackFunction(L, 1); return 0; } -// ----------------------------------------------------------------------------- - -static void TheCommandCallback(int Command) { - CommandCallbackPtr->Command = static_cast<InputEngine::KEY_COMMANDS>(Command); - lua_State *L = static_cast<lua_State *>(Kernel::GetInstance()->GetScript()->getScriptObject()); - CommandCallbackPtr->invokeCallbackFunctions(L, 1); +static void theCommandCallback(int command) { + commandCallbackPtr->_command = static_cast<InputEngine::KEY_COMMANDS>(command); + lua_State *L = static_cast<lua_State *>(Kernel::getInstance()->getScript()->getScriptObject()); + commandCallbackPtr->invokeCallbackFunctions(L, 1); } -// ----------------------------------------------------------------------------- - -static int RegisterCommandCallback(lua_State *L) { +static int registerCommandCallback(lua_State *L) { luaL_checktype(L, 1, LUA_TFUNCTION); - CommandCallbackPtr->registerCallbackFunction(L, 1); + commandCallbackPtr->registerCallbackFunction(L, 1); return 0; } -// ----------------------------------------------------------------------------- - -static int UnregisterCommandCallback(lua_State *L) { +static int unregisterCommandCallback(lua_State *L) { luaL_checktype(L, 1, LUA_TFUNCTION); - CommandCallbackPtr->unregisterCallbackFunction(L, 1); + commandCallbackPtr->unregisterCallbackFunction(L, 1); return 0; } -// ----------------------------------------------------------------------------- - static const char *PACKAGE_LIBRARY_NAME = "Input"; static const luaL_reg PACKAGE_FUNCTIONS[] = { - {"Init", Init}, - {"Update", Update}, - {"IsLeftMouseDown", IsLeftMouseDown}, - {"IsRightMouseDown", IsRightMouseDown}, - {"WasLeftMouseDown", WasLeftMouseDown}, - {"WasRightMouseDown", WasRightMouseDown}, - {"IsLeftDoubleClick", IsLeftDoubleClick}, - {"GetMouseX", GetMouseX}, - {"GetMouseY", GetMouseY}, - {"SetMouseX", SetMouseX}, - {"SetMouseY", SetMouseY}, - {"IsKeyDown", IsKeyDown}, - {"WasKeyDown", WasKeyDown}, - {"RegisterCharacterCallback", RegisterCharacterCallback}, - {"UnregisterCharacterCallback", UnregisterCharacterCallback}, - {"RegisterCommandCallback", RegisterCommandCallback}, - {"UnregisterCommandCallback", UnregisterCommandCallback}, + {"Init", init}, + {"Update", update}, + {"IsLeftMouseDown", isLeftMouseDown}, + {"IsRightMouseDown", isRightMouseDown}, + {"WasLeftMouseDown", wasLeftMouseDown}, + {"WasRightMouseDown", wasRightMouseDown}, + {"IsLeftDoubleClick", isLeftDoubleClick}, + {"GetMouseX", getMouseX}, + {"GetMouseY", getMouseY}, + {"SetMouseX", setMouseX}, + {"SetMouseY", setMouseY}, + {"IsKeyDown", isKeyDown}, + {"WasKeyDown", wasKeyDown}, + {"RegisterCharacterCallback", registerCharacterCallback}, + {"UnregisterCharacterCallback", unregisterCharacterCallback}, + {"RegisterCommandCallback", registerCommandCallback}, + {"UnregisterCommandCallback", unregisterCommandCallback}, {0, 0} }; @@ -334,9 +280,9 @@ static const lua_constant_reg PACKAGE_CONSTANTS[] = { // ----------------------------------------------------------------------------- bool InputEngine::registerScriptBindings() { - Kernel *pKernel = Kernel::GetInstance(); + Kernel *pKernel = Kernel::getInstance(); BS_ASSERT(pKernel); - ScriptEngine *pScript = pKernel->GetScript(); + ScriptEngine *pScript = pKernel->getScript(); BS_ASSERT(pScript); lua_State *L = static_cast<lua_State *>(pScript->getScriptObject()); BS_ASSERT(L); @@ -344,8 +290,8 @@ bool InputEngine::registerScriptBindings() { if (!LuaBindhelper::addFunctionsToLib(L, PACKAGE_LIBRARY_NAME, PACKAGE_FUNCTIONS)) return false; if (!LuaBindhelper::addConstantsToLib(L, PACKAGE_LIBRARY_NAME, PACKAGE_CONSTANTS)) return false; - CharacterCallbackPtr = Common::SharedPtr<CharacterCallbackClass>(new CharacterCallbackClass(L)); - CommandCallbackPtr = Common::SharedPtr<CommandCallbackClass>(new CommandCallbackClass(L)); + characterCallbackPtr = Common::SharedPtr<CharacterCallbackClass>(new CharacterCallbackClass(L)); + commandCallbackPtr = Common::SharedPtr<CommandCallbackClass>(new CommandCallbackClass(L)); return true; } 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 diff --git a/engines/sword25/math/geometry_script.cpp b/engines/sword25/math/geometry_script.cpp index 3cba72ff7e..8882d5e588 100644 --- a/engines/sword25/math/geometry_script.cpp +++ b/engines/sword25/math/geometry_script.cpp @@ -360,7 +360,7 @@ static int r_setY(lua_State *L) { } static void drawPolygon(const Polygon &polygon, uint color, const Vertex &offset) { - GraphicEngine *pGE = Kernel::GetInstance()->GetGfx(); + GraphicEngine *pGE = Kernel::getInstance()->getGfx(); BS_ASSERT(pGE); for (int i = 0; i < polygon.vertexCount - 1; i++) @@ -470,9 +470,9 @@ static const luaL_reg WALKREGION_METHODS[] = { }; bool Geometry::registerScriptBindings() { - Kernel *pKernel = Kernel::GetInstance(); + Kernel *pKernel = Kernel::getInstance(); BS_ASSERT(pKernel); - ScriptEngine *pScript = pKernel->GetScript(); + ScriptEngine *pScript = pKernel->getScript(); BS_ASSERT(pScript); lua_State *L = static_cast< lua_State *>(pScript->getScriptObject()); BS_ASSERT(L); diff --git a/engines/sword25/math/walkregion.cpp b/engines/sword25/math/walkregion.cpp index 3f4ad3c030..51818bc9e8 100644 --- a/engines/sword25/math/walkregion.cpp +++ b/engines/sword25/math/walkregion.cpp @@ -165,7 +165,7 @@ static void relaxEndPoint(const Vertex &curNodePos, } template<class T> -void ReverseArray(Common::Array<T> &arr) { +void reverseArray(Common::Array<T> &arr) { const uint size = arr.size(); if (size < 2) return; @@ -216,7 +216,7 @@ bool WalkRegion::findPath(const Vertex &start, const Vertex &end, BS_Path &path) // The nodes of the path must be untwisted, as they were extracted in reverse order. // This step could be saved if the path from end to the beginning was desired - ReverseArray<Vertex>(path); + reverseArray<Vertex>(path); return true; } diff --git a/engines/sword25/package/packagemanager.cpp b/engines/sword25/package/packagemanager.cpp index def9802386..0286aad9e6 100644 --- a/engines/sword25/package/packagemanager.cpp +++ b/engines/sword25/package/packagemanager.cpp @@ -154,7 +154,7 @@ byte *PackageManager::getFile(const Common::String &fileName, uint *fileSizePtr) // Savegame loading logic Common::SaveFileManager *sfm = g_system->getSavefileManager(); Common::InSaveFile *file = sfm->openForLoading( - FileSystemUtil::GetInstance().GetPathFilename(fileName)); + FileSystemUtil::getInstance().getPathFilename(fileName)); if (!file) { BS_LOG_ERRORLN("Could not load savegame \"%s\".", fileName.c_str()); return 0; diff --git a/engines/sword25/package/packagemanager_script.cpp b/engines/sword25/package/packagemanager_script.cpp index 8a32d0b4cc..afab573511 100644 --- a/engines/sword25/package/packagemanager_script.cpp +++ b/engines/sword25/package/packagemanager_script.cpp @@ -42,9 +42,9 @@ namespace Sword25 { static PackageManager *getPM() { - Kernel *pKernel = Kernel::GetInstance(); + Kernel *pKernel = Kernel::getInstance(); BS_ASSERT(pKernel); - PackageManager *pPM = pKernel->GetPackage(); + PackageManager *pPM = pKernel->getPackage(); BS_ASSERT(pPM); return pPM; } @@ -197,9 +197,9 @@ static const luaL_reg PACKAGE_FUNCTIONS[] = { }; bool PackageManager::registerScriptBindings() { - Kernel *pKernel = Kernel::GetInstance(); + Kernel *pKernel = Kernel::getInstance(); BS_ASSERT(pKernel); - ScriptEngine *pScript = pKernel->GetScript(); + ScriptEngine *pScript = pKernel->getScript(); BS_ASSERT(pScript); lua_State *L = static_cast<lua_State *>(pScript->getScriptObject()); BS_ASSERT(L); diff --git a/engines/sword25/script/lua_extensions.cpp b/engines/sword25/script/lua_extensions.cpp index 3c0d4570a2..25a43e17d2 100644 --- a/engines/sword25/script/lua_extensions.cpp +++ b/engines/sword25/script/lua_extensions.cpp @@ -47,7 +47,7 @@ static int warning(lua_State *L) { lua_pushstring(L, "WARNING - "); lua_pushvalue(L, 1); lua_concat(L, 3); - BS_Log::Log("%s\n", luaL_checkstring(L, -1)); + BS_Log::log("%s\n", luaL_checkstring(L, -1)); lua_pop(L, 1); #ifdef DEBUG diff --git a/engines/sword25/script/luascript.cpp b/engines/sword25/script/luascript.cpp index a16959656d..4144a6a9e2 100644 --- a/engines/sword25/script/luascript.cpp +++ b/engines/sword25/script/luascript.cpp @@ -151,7 +151,7 @@ bool LuaScriptEngine::executeFile(const Common::String &fileName) { debug(2, "LuaScriptEngine::executeFile(%s)", fileName.c_str()); // Get a pointer to the package manager - PackageManager *pPackage = Kernel::GetInstance()->GetPackage(); + PackageManager *pPackage = Kernel::getInstance()->getPackage(); BS_ASSERT(pPackage); // File read diff --git a/engines/sword25/sfx/soundengine.cpp b/engines/sword25/sfx/soundengine.cpp index c753afd9b9..3498e23d3d 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/sfx/soundengine_script.cpp b/engines/sword25/sfx/soundengine_script.cpp index 56e8f19b74..eabbef6e5e 100644 --- a/engines/sword25/sfx/soundengine_script.cpp +++ b/engines/sword25/sfx/soundengine_script.cpp @@ -46,9 +46,9 @@ namespace Sword25 { static int init(lua_State *L) { - Kernel *pKernel = Kernel::GetInstance(); + Kernel *pKernel = Kernel::getInstance(); BS_ASSERT(pKernel); - SoundEngine *pSfx = pKernel->GetSfx(); + SoundEngine *pSfx = pKernel->getSfx(); BS_ASSERT(pSfx); if (lua_gettop(L) == 0) @@ -62,9 +62,9 @@ static int init(lua_State *L) { } static int update(lua_State *L) { - Kernel *pKernel = Kernel::GetInstance(); + Kernel *pKernel = Kernel::getInstance(); BS_ASSERT(pKernel); - SoundEngine *pSfx = pKernel->GetSfx(); + SoundEngine *pSfx = pKernel->getSfx(); BS_ASSERT(pSfx); pSfx->update(); @@ -73,9 +73,9 @@ static int update(lua_State *L) { } static int setVolume(lua_State *L) { - Kernel *pKernel = Kernel::GetInstance(); + Kernel *pKernel = Kernel::getInstance(); BS_ASSERT(pKernel); - SoundEngine *pSfx = pKernel->GetSfx(); + SoundEngine *pSfx = pKernel->getSfx(); BS_ASSERT(pSfx); pSfx->setVolume(static_cast<float>(luaL_checknumber(L, 1)), @@ -85,9 +85,9 @@ static int setVolume(lua_State *L) { } static int getVolume(lua_State *L) { - Kernel *pKernel = Kernel::GetInstance(); + Kernel *pKernel = Kernel::getInstance(); BS_ASSERT(pKernel); - SoundEngine *pSfx = pKernel->GetSfx(); + SoundEngine *pSfx = pKernel->getSfx(); BS_ASSERT(pSfx); lua_pushnumber(L, pSfx->getVolume(static_cast<SoundEngine::SOUND_TYPES>(static_cast<uint>(luaL_checknumber(L, 1))))); @@ -96,9 +96,9 @@ static int getVolume(lua_State *L) { } static int pauseAll(lua_State *L) { - Kernel *pKernel = Kernel::GetInstance(); + Kernel *pKernel = Kernel::getInstance(); BS_ASSERT(pKernel); - SoundEngine *pSfx = pKernel->GetSfx(); + SoundEngine *pSfx = pKernel->getSfx(); BS_ASSERT(pSfx); pSfx->pauseAll(); @@ -107,9 +107,9 @@ static int pauseAll(lua_State *L) { } static int resumeAll(lua_State *L) { - Kernel *pKernel = Kernel::GetInstance(); + Kernel *pKernel = Kernel::getInstance(); BS_ASSERT(pKernel); - SoundEngine *pSfx = pKernel->GetSfx(); + SoundEngine *pSfx = pKernel->getSfx(); BS_ASSERT(pSfx); pSfx->resumeAll(); @@ -118,9 +118,9 @@ static int resumeAll(lua_State *L) { } static int pauseLayer(lua_State *L) { - Kernel *pKernel = Kernel::GetInstance(); + Kernel *pKernel = Kernel::getInstance(); BS_ASSERT(pKernel); - SoundEngine *pSfx = pKernel->GetSfx(); + SoundEngine *pSfx = pKernel->getSfx(); BS_ASSERT(pSfx); pSfx->pauseLayer(static_cast<int>(luaL_checknumber(L, 1))); @@ -129,9 +129,9 @@ static int pauseLayer(lua_State *L) { } static int resumeLayer(lua_State *L) { - Kernel *pKernel = Kernel::GetInstance(); + Kernel *pKernel = Kernel::getInstance(); BS_ASSERT(pKernel); - SoundEngine *pSfx = pKernel->GetSfx(); + SoundEngine *pSfx = pKernel->getSfx(); BS_ASSERT(pSfx); pSfx->resumeLayer(static_cast<int>(luaL_checknumber(L, 1))); @@ -176,9 +176,9 @@ static void processPlayParams(lua_State *L, Common::String &fileName, SoundEngin } static int playSound(lua_State *L) { - Kernel *pKernel = Kernel::GetInstance(); + Kernel *pKernel = Kernel::getInstance(); BS_ASSERT(pKernel); - SoundEngine *pSfx = pKernel->GetSfx(); + SoundEngine *pSfx = pKernel->getSfx(); BS_ASSERT(pSfx); Common::String fileName; @@ -197,9 +197,9 @@ static int playSound(lua_State *L) { } static int playSoundEx(lua_State *L) { - Kernel *pKernel = Kernel::GetInstance(); + Kernel *pKernel = Kernel::getInstance(); BS_ASSERT(pKernel); - SoundEngine *pSfx = pKernel->GetSfx(); + SoundEngine *pSfx = pKernel->getSfx(); BS_ASSERT(pSfx); Common::String fileName; @@ -218,9 +218,9 @@ static int playSoundEx(lua_State *L) { } static int setSoundVolume(lua_State *L) { - Kernel *pKernel = Kernel::GetInstance(); + Kernel *pKernel = Kernel::getInstance(); BS_ASSERT(pKernel); - SoundEngine *pSfx = pKernel->GetSfx(); + SoundEngine *pSfx = pKernel->getSfx(); BS_ASSERT(pSfx); pSfx->setSoundVolume(static_cast<uint>(luaL_checknumber(L, 1)), static_cast<float>(luaL_checknumber(L, 2))); @@ -229,9 +229,9 @@ static int setSoundVolume(lua_State *L) { } static int setSoundPanning(lua_State *L) { - Kernel *pKernel = Kernel::GetInstance(); + Kernel *pKernel = Kernel::getInstance(); BS_ASSERT(pKernel); - SoundEngine *pSfx = pKernel->GetSfx(); + SoundEngine *pSfx = pKernel->getSfx(); BS_ASSERT(pSfx); pSfx->setSoundPanning(static_cast<uint>(luaL_checknumber(L, 1)), static_cast<float>(luaL_checknumber(L, 2))); @@ -240,9 +240,9 @@ static int setSoundPanning(lua_State *L) { } static int pauseSound(lua_State *L) { - Kernel *pKernel = Kernel::GetInstance(); + Kernel *pKernel = Kernel::getInstance(); BS_ASSERT(pKernel); - SoundEngine *pSfx = pKernel->GetSfx(); + SoundEngine *pSfx = pKernel->getSfx(); BS_ASSERT(pSfx); pSfx->pauseSound(static_cast<uint>(luaL_checknumber(L, 1))); @@ -251,9 +251,9 @@ static int pauseSound(lua_State *L) { } static int resumeSound(lua_State *L) { - Kernel *pKernel = Kernel::GetInstance(); + Kernel *pKernel = Kernel::getInstance(); BS_ASSERT(pKernel); - SoundEngine *pSfx = pKernel->GetSfx(); + SoundEngine *pSfx = pKernel->getSfx(); BS_ASSERT(pSfx); pSfx->resumeSound(static_cast<uint>(luaL_checknumber(L, 1))); @@ -262,9 +262,9 @@ static int resumeSound(lua_State *L) { } static int stopSound(lua_State *L) { - Kernel *pKernel = Kernel::GetInstance(); + Kernel *pKernel = Kernel::getInstance(); BS_ASSERT(pKernel); - SoundEngine *pSfx = pKernel->GetSfx(); + SoundEngine *pSfx = pKernel->getSfx(); BS_ASSERT(pSfx); pSfx->stopSound(static_cast<uint>(luaL_checknumber(L, 1))); @@ -273,9 +273,9 @@ static int stopSound(lua_State *L) { } static int isSoundPaused(lua_State *L) { - Kernel *pKernel = Kernel::GetInstance(); + Kernel *pKernel = Kernel::getInstance(); BS_ASSERT(pKernel); - SoundEngine *pSfx = pKernel->GetSfx(); + SoundEngine *pSfx = pKernel->getSfx(); BS_ASSERT(pSfx); lua_pushbooleancpp(L, pSfx->isSoundPaused(static_cast<uint>(luaL_checknumber(L, 1)))); @@ -284,9 +284,9 @@ static int isSoundPaused(lua_State *L) { } static int isSoundPlaying(lua_State *L) { - Kernel *pKernel = Kernel::GetInstance(); + Kernel *pKernel = Kernel::getInstance(); BS_ASSERT(pKernel); - SoundEngine *pSfx = pKernel->GetSfx(); + SoundEngine *pSfx = pKernel->getSfx(); BS_ASSERT(pSfx); lua_pushbooleancpp(L, pSfx->isSoundPlaying(static_cast<uint>(luaL_checknumber(L, 1)))); @@ -295,9 +295,9 @@ static int isSoundPlaying(lua_State *L) { } static int getSoundVolume(lua_State *L) { - Kernel *pKernel = Kernel::GetInstance(); + Kernel *pKernel = Kernel::getInstance(); BS_ASSERT(pKernel); - SoundEngine *pSfx = pKernel->GetSfx(); + SoundEngine *pSfx = pKernel->getSfx(); BS_ASSERT(pSfx); lua_pushnumber(L, pSfx->getSoundVolume(static_cast<uint>(luaL_checknumber(L, 1)))); @@ -306,9 +306,9 @@ static int getSoundVolume(lua_State *L) { } static int getSoundPanning(lua_State *L) { - Kernel *pKernel = Kernel::GetInstance(); + Kernel *pKernel = Kernel::getInstance(); BS_ASSERT(pKernel); - SoundEngine *pSfx = pKernel->GetSfx(); + SoundEngine *pSfx = pKernel->getSfx(); BS_ASSERT(pSfx); lua_pushnumber(L, pSfx->getSoundPanning(static_cast<uint>(luaL_checknumber(L, 1)))); @@ -349,9 +349,9 @@ static const lua_constant_reg SFX_CONSTANTS[] = { }; bool SoundEngine::registerScriptBindings() { - Kernel *pKernel = Kernel::GetInstance(); + Kernel *pKernel = Kernel::getInstance(); BS_ASSERT(pKernel); - ScriptEngine *pScript = pKernel->GetScript(); + ScriptEngine *pScript = pKernel->getScript(); BS_ASSERT(pScript); lua_State *L = static_cast<lua_State *>(pScript->getScriptObject()); BS_ASSERT(L); diff --git a/engines/sword25/sword25.cpp b/engines/sword25/sword25.cpp index 23db38f843..9f3c963013 100644 --- a/engines/sword25/sword25.cpp +++ b/engines/sword25/sword25.cpp @@ -90,13 +90,13 @@ Common::Error Sword25Engine::appStart() { return Common::kUnsupportedColorMode; // Kernel initialization - if (!Kernel::GetInstance()->GetInitSuccess()) { + if (!Kernel::getInstance()->getInitSuccess()) { BS_LOG_ERRORLN("Kernel initialization failed."); return Common::kUnknownError; } // Package-Manager starten, damit die Packfiles geladen werden können. - PackageManager *packageManagerPtr = static_cast<PackageManager *>(Kernel::GetInstance()->NewService("package", PACKAGE_MANAGER)); + PackageManager *packageManagerPtr = static_cast<PackageManager *>(Kernel::getInstance()->newService("package", PACKAGE_MANAGER)); if (!packageManagerPtr) { BS_LOG_ERRORLN("PackageManager initialization failed."); return Common::kUnknownError; @@ -112,7 +112,7 @@ Common::Error Sword25Engine::appStart() { } // Einen Pointer auf den Skript-Engine holen. - ScriptEngine *scriptPtr = Kernel::GetInstance()->GetScript(); + ScriptEngine *scriptPtr = Kernel::getInstance()->getScript(); if (!scriptPtr) { BS_LOG_ERRORLN("Script intialization failed."); return Common::kUnknownError; @@ -126,7 +126,7 @@ Common::Error Sword25Engine::appStart() { bool Sword25Engine::appMain() { // The main script start. This script loads all the other scripts and starts the actual game. - ScriptEngine *scriptPtr = Kernel::GetInstance()->GetScript(); + ScriptEngine *scriptPtr = Kernel::getInstance()->getScript(); BS_ASSERT(scriptPtr); scriptPtr->executeFile(DEFAULT_SCRIPT_FILE); @@ -135,20 +135,20 @@ bool Sword25Engine::appMain() { bool Sword25Engine::appEnd() { // The kernel is shutdown, and un-initialises all subsystems - Kernel::DeleteInstance(); + Kernel::deleteInstance(); AnimationTemplateRegistry::destroy(); RenderObjectRegistry::destroy(); RegionRegistry::destroy(); // Free the log file if it was used - BS_Log::_CloseLog(); + BS_Log::closeLog(); return true; } bool Sword25Engine::loadPackages() { - PackageManager *packageManagerPtr = Kernel::GetInstance()->GetPackage(); + PackageManager *packageManagerPtr = Kernel::getInstance()->getPackage(); BS_ASSERT(packageManagerPtr); // Load the main package |