From a683a420a9e43705c972b5e74d55e319729e1a81 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 29 Jul 2010 19:53:02 +0000 Subject: SWORD25: Importing original sources svn-id: r53171 --- engines/sword25/kernel/kernel.cpp | 412 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 412 insertions(+) create mode 100755 engines/sword25/kernel/kernel.cpp (limited to 'engines/sword25/kernel/kernel.cpp') diff --git a/engines/sword25/kernel/kernel.cpp b/engines/sword25/kernel/kernel.cpp new file mode 100755 index 0000000000..e6d8ec2872 --- /dev/null +++ b/engines/sword25/kernel/kernel.cpp @@ -0,0 +1,412 @@ +// ----------------------------------------------------------------------------- +// This file is part of Broken Sword 2.5 +// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdörfer +// +// Broken Sword 2.5 is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// Broken Sword 2.5 is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Broken Sword 2.5; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +// ----------------------------------------------------------------------------- + +#define WIN32_LEAN_AND_MEAN +#define NOMINMAX +#include +#include +#pragma comment(lib, "psapi.lib") + +#include +#include + +#include "kernel.h" +#include "timer.h" +#include "service_ids.h" + +#include "gfx/graphicengine.h" +#include "sfx/soundengine.h" +#include "input/inputengine.h" +#include "package/packagemanager.h" +#include "script/script.h" +#include "fmv/movieplayer.h" +#include "persistenceservice.h" +#include "cpuinfo.h" + +#define BS_LOG_PREFIX "KERNEL" + +BS_Kernel * BS_Kernel::_Instance = 0; + +// Konstruktion / Destruktion +// -------------------------- +BS_Kernel::BS_Kernel() : + _pWindow(NULL), + _Running(false), + _pResourceManager(NULL), + _InitSuccess(false) +{ + // TODO: + // Messagebox ausgeben wenn nicht gelogged werden kann -> log.txt schreibgeschützt + BS_LOGLN("created."); + + // CPU-Daten in die Log-Datei schreiben + const BS_CPUInfo & CI = BS_CPUInfo::GetInstance(); + BS_LOGLN("CPU detected (vendor name: \"%s\", CPU name: \"%s\").", CI.GetVendorString().c_str(), CI.GetCPUName().c_str()); + BS_LOGLN("CPU features: %s%s%s%s%s.", + CI.IsMMXSupported() ? "MMX" : "", + CI.IsSSESupported() ? " SSE" : "", + CI.IsSSE2Supported() ? " SSE2" : "", + CI.Is3DNowSupported() ? " 3DNow!" : "", + CI.Is3DNowExtSupported() ? " 3DNow!Ext" : ""); + + // Sicherstellen, dass der Prozessor über MMX verfügt + if (!CI.IsMMXSupported()) + { + BS_LOG_ERRORLN("MMX support needed."); + return; + } + + // Feststellen, ob der Timer unterstützt wird. + if (!BS_Timer::IsTimerAvaliable()) + { + BS_LOG_ERRORLN("This machine doesn't support a performance counter."); + return; + } + + // Die BS_SERVICE_TABLE auslesen und kernelinterne Strukturen vorbereiten + for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++) + { + // Ist die Superclass schon registriert? + Superclass* pCurSuperclass = NULL; + std::vector::iterator Iter; + for (Iter = _SuperclassList.begin(); Iter != _SuperclassList.end(); ++Iter) + if ((*Iter)->GetIdentifier() == BS_SERVICE_TABLE[i].SuperclassIdentifier) + { + pCurSuperclass = *Iter; + break; + } + + // Falls die Superclass noch nicht registriert war, wird dies jetzt gemacht + if (!pCurSuperclass) + _SuperclassList.push_back(new Superclass(this, BS_SERVICE_TABLE[i].SuperclassIdentifier)); + } + + // Fensterobjekt erstellen + _pWindow = BS_Window::CreateBSWindow(0,0,0,0,false); + if (!_pWindow) + { + BS_LOG_ERRORLN("Failed to create the window."); + } + else + BS_LOGLN("Window created."); + + // Resource-Manager erstellen + _pResourceManager = new BS_ResourceManager(this); + + // Random-Number-Generator initialisieren + srand(GetMilliTicks()); + + // Die Skriptengine initialisieren + // Die Skriptengine muss bereits von Kernel und nicht vom Benutzer gestartet werden, damit der Kernel seine Funktionen bei seiner Erzeugung + // registrieren kann. + BS_ScriptEngine * pScript = static_cast(NewService("script", "lua")); + if (!pScript || !pScript->Init()) + { + _InitSuccess = false; + return; + } + + // Scriptbindings des Kernels registrieren + if (!_RegisterScriptBindings()) + { + BS_LOG_ERRORLN("Script bindings could not be registered."); + _InitSuccess = false; + return; + } + BS_LOGLN("Script bindings registered."); + + _InitSuccess = true; +} + +BS_Kernel::~BS_Kernel() +{ + // Services in umgekehrter Reihenfolge der Erstellung endladen. + while (!_ServiceCreationOrder.empty()) + { + Superclass * superclass = GetSuperclassByIdentifier(_ServiceCreationOrder.top()); + if (superclass) superclass->DisconnectService(); + _ServiceCreationOrder.pop(); + } + + // Superclasslist leeren + while (_SuperclassList.size()) + { + delete _SuperclassList.back(); + _SuperclassList.pop_back(); + } + + // Fensterobjekt freigeben + delete _pWindow; + BS_LOGLN("Window destroyed."); + + // Resource-Manager freigeben + delete _pResourceManager; + + BS_LOGLN("destroyed."); +} + +// Service Methoden +// ---------------- +BS_Kernel::Superclass::Superclass (BS_Kernel* pKernel, const std::string& Identifier) : + _pKernel(pKernel), + _Identifier(Identifier), + _ServiceCount(0), + _ActiveService(NULL) +{ + for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++) + if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier) + _ServiceCount++; +} + +BS_Kernel::Superclass::~Superclass() +{ + DisconnectService(); +} + +std::string BS_Kernel::Superclass::GetServiceIdentifier(unsigned int Number) +{ + if (Number > _ServiceCount) return NULL; + + unsigned int CurServiceOrd = 0; + for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++) + { + if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier) + if (Number == CurServiceOrd) + return BS_SERVICE_TABLE[i].ServiceIdentifier; + else + CurServiceOrd++; + } + + return std::string(""); +} + +BS_Service* BS_Kernel::Superclass::NewService(const std::string& ServiceIdentifier) +{ + for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++) + if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier && + BS_SERVICE_TABLE[i].ServiceIdentifier == ServiceIdentifier) + { + BS_Service* NewService = BS_SERVICE_TABLE[i].CreateMethod(_pKernel); + + if (NewService) + { + DisconnectService(); + BS_LOGLN("Service '%s' created from superclass '%s'.", ServiceIdentifier.c_str(), _Identifier.c_str()); + _ActiveService = NewService; + _ActiveServiceName = BS_SERVICE_TABLE[i].ServiceIdentifier; + return _ActiveService; + } + else + { + BS_LOG_ERRORLN("Failed to create service '%s' from superclass '%s'.", ServiceIdentifier.c_str(), _Identifier.c_str()); + return NULL; + } + } + + BS_LOG_ERRORLN("Service '%s' is not avaliable from superclass '%s'.", ServiceIdentifier.c_str(), _Identifier.c_str()); + return NULL; +} + +bool BS_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; +} + +BS_Kernel::Superclass* BS_Kernel::GetSuperclassByIdentifier(const std::string & Identifier) +{ + std::vector::iterator Iter; + for (Iter = _SuperclassList.begin(); Iter != _SuperclassList.end(); ++Iter) + { + if ((*Iter)->GetIdentifier() == Identifier) + return *Iter; + } + + // BS_LOG_ERRORLN("Superclass '%s' does not exist.", Identifier.c_str()); + return NULL; +} + +unsigned int BS_Kernel::GetSuperclassCount() +{ + return _SuperclassList.size(); +} + +std::string BS_Kernel::GetSuperclassIdentifier(unsigned int Number) +{ + if (Number > _SuperclassList.size()) return NULL; + + unsigned int CurSuperclassOrd = 0; + std::vector::iterator Iter; + for (Iter = _SuperclassList.begin(); Iter != _SuperclassList.end(); ++Iter) + { + if (CurSuperclassOrd == Number) + return ((*Iter)->GetIdentifier()); + + CurSuperclassOrd++; + } + + return std::string(""); +} + +unsigned int BS_Kernel::GetServiceCount(const std::string & SuperclassIdentifier) +{ + Superclass* pSuperclass; + if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return 0; + + return pSuperclass->GetServiceCount(); + +} + +std::string BS_Kernel::GetServiceIdentifier(const std::string & SuperclassIdentifier, unsigned int Number) +{ + Superclass* pSuperclass; + if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return NULL; + + return (pSuperclass->GetServiceIdentifier(Number)); +} + +BS_Service* BS_Kernel::NewService(const std::string& SuperclassIdentifier, const std::string& ServiceIdentifier) +{ + Superclass* pSuperclass; + if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return NULL; + + // Die Reihenfolge merken, in der Services erstellt werden, damit sie später in umgekehrter Reihenfolge entladen werden können. + _ServiceCreationOrder.push(SuperclassIdentifier); + + return pSuperclass->NewService(ServiceIdentifier); +} + +bool BS_Kernel::DisconnectService(const std::string& SuperclassIdentifier) +{ + Superclass* pSuperclass; + if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return false; + + return pSuperclass->DisconnectService(); +} + +BS_Service* BS_Kernel::GetService(const std::string& SuperclassIdentifier) +{ + Superclass* pSuperclass; + if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return NULL; + + return (pSuperclass->GetActiveService()); +} + +std::string BS_Kernel::GetActiveServiceIdentifier(const std::string& SuperclassIdentifier) +{ + Superclass * pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier); + if (!pSuperclass) return std::string(""); + + return (pSuperclass->GetActiveServiceName()); +} + +// ----------------------------------------------------------------------------- + +int BS_Kernel::GetRandomNumber(int Min, int Max) +{ + BS_ASSERT(Min <= Max); + unsigned int MaxInternal = (Min - Max + 1) < 0 ? - (Min - Max + 1) : (Min - Max + 1); + return (rand() % MaxInternal) + Min; +} + +// Timer Methoden +// -------------- +unsigned int BS_Kernel::GetMilliTicks() +{ + return BS_Timer::GetMilliTicks(); +} + +uint64_t BS_Kernel::GetMicroTicks() +{ + return BS_Timer::GetMicroTicks(); +} + +// Sonstige Methoden +// ----------------- + +size_t BS_Kernel::GetUsedMemory() +{ + 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; + } +} + +// ----------------------------------------------------------------------------- + +BS_GraphicEngine * BS_Kernel::GetGfx() +{ + return static_cast(GetService("gfx")); +} + +// ----------------------------------------------------------------------------- + +BS_SoundEngine * BS_Kernel::GetSfx() +{ + return static_cast(GetService("sfx")); +} + +// ----------------------------------------------------------------------------- + +BS_InputEngine * BS_Kernel::GetInput() +{ + return static_cast(GetService("input")); +} + +// ----------------------------------------------------------------------------- + +BS_PackageManager * BS_Kernel::GetPackage() +{ + return static_cast(GetService("package")); +} + +// ----------------------------------------------------------------------------- + +BS_ScriptEngine * BS_Kernel::GetScript() +{ + return static_cast(GetService("script")); +} + +// ----------------------------------------------------------------------------- + +BS_MoviePlayer * BS_Kernel::GetFMV() +{ + return static_cast(GetService("fmv")); +} + +// ----------------------------------------------------------------------------- + +void BS_Kernel::Sleep(unsigned int Msecs) const +{ + ::Sleep(Msecs); +} -- cgit v1.2.3 From 2cbeeb1e97500b23eeb864519e7daef50783a6b5 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 29 Jul 2010 19:53:21 +0000 Subject: SWORD25: Removed cpuinfo.cpp file svn-id: r53173 --- engines/sword25/kernel/kernel.cpp | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'engines/sword25/kernel/kernel.cpp') diff --git a/engines/sword25/kernel/kernel.cpp b/engines/sword25/kernel/kernel.cpp index e6d8ec2872..123a19b13c 100755 --- a/engines/sword25/kernel/kernel.cpp +++ b/engines/sword25/kernel/kernel.cpp @@ -37,7 +37,6 @@ #include "script/script.h" #include "fmv/movieplayer.h" #include "persistenceservice.h" -#include "cpuinfo.h" #define BS_LOG_PREFIX "KERNEL" @@ -55,23 +54,6 @@ BS_Kernel::BS_Kernel() : // Messagebox ausgeben wenn nicht gelogged werden kann -> log.txt schreibgeschützt BS_LOGLN("created."); - // CPU-Daten in die Log-Datei schreiben - const BS_CPUInfo & CI = BS_CPUInfo::GetInstance(); - BS_LOGLN("CPU detected (vendor name: \"%s\", CPU name: \"%s\").", CI.GetVendorString().c_str(), CI.GetCPUName().c_str()); - BS_LOGLN("CPU features: %s%s%s%s%s.", - CI.IsMMXSupported() ? "MMX" : "", - CI.IsSSESupported() ? " SSE" : "", - CI.IsSSE2Supported() ? " SSE2" : "", - CI.Is3DNowSupported() ? " 3DNow!" : "", - CI.Is3DNowExtSupported() ? " 3DNow!Ext" : ""); - - // Sicherstellen, dass der Prozessor über MMX verfügt - if (!CI.IsMMXSupported()) - { - BS_LOG_ERRORLN("MMX support needed."); - return; - } - // Feststellen, ob der Timer unterstützt wird. if (!BS_Timer::IsTimerAvaliable()) { -- cgit v1.2.3 From e8bca8b8fe0f80e0d5053b190840b034f50ae163 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 30 Jul 2010 09:02:39 +0000 Subject: SWORD25: Fixed rest of the include paths svn-id: r53181 --- engines/sword25/kernel/kernel.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'engines/sword25/kernel/kernel.cpp') diff --git a/engines/sword25/kernel/kernel.cpp b/engines/sword25/kernel/kernel.cpp index 123a19b13c..9a0580324f 100755 --- a/engines/sword25/kernel/kernel.cpp +++ b/engines/sword25/kernel/kernel.cpp @@ -26,17 +26,17 @@ #include #include -#include "kernel.h" -#include "timer.h" -#include "service_ids.h" - -#include "gfx/graphicengine.h" -#include "sfx/soundengine.h" -#include "input/inputengine.h" -#include "package/packagemanager.h" -#include "script/script.h" -#include "fmv/movieplayer.h" -#include "persistenceservice.h" +#include "sword25/kernel/kernel.h" +#include "sword25/kernel/timer.h" +#include "sword25/kernel/service_ids.h" + +#include "sword25/gfx/graphicengine.h" +#include "sword25/sfx/soundengine.h" +#include "sword25/input/inputengine.h" +#include "sword25/package/packagemanager.h" +#include "sword25/script/script.h" +#include "sword25/fmv/movieplayer.h" +#include "sword25/kernel/persistenceservice.h" #define BS_LOG_PREFIX "KERNEL" -- cgit v1.2.3 From e78b19a650e27fe9a24d0e4c9c938294c7b08650 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 31 Jul 2010 06:23:38 +0000 Subject: SWORD25: Converted kernel/kernel.cpp to compile under ScummVM This commit creates a skeleton detection and engine class, as well as code necessary to call the kernel initiation. The kernel/kernel.cpp has been converted to compile under ScummVM, along with all dependant header files. svn-id: r53184 --- engines/sword25/kernel/kernel.cpp | 382 ++++++++++++++++++++++---------------- 1 file changed, 220 insertions(+), 162 deletions(-) (limited to 'engines/sword25/kernel/kernel.cpp') diff --git a/engines/sword25/kernel/kernel.cpp b/engines/sword25/kernel/kernel.cpp index 9a0580324f..a12f206a99 100755 --- a/engines/sword25/kernel/kernel.cpp +++ b/engines/sword25/kernel/kernel.cpp @@ -1,112 +1,89 @@ -// ----------------------------------------------------------------------------- -// This file is part of Broken Sword 2.5 -// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdörfer -// -// Broken Sword 2.5 is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// Broken Sword 2.5 is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Broken Sword 2.5; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -// ----------------------------------------------------------------------------- - -#define WIN32_LEAN_AND_MEAN -#define NOMINMAX -#include -#include -#pragma comment(lib, "psapi.lib") - -#include -#include - -#include "sword25/kernel/kernel.h" -#include "sword25/kernel/timer.h" -#include "sword25/kernel/service_ids.h" - +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "common/system.h" #include "sword25/gfx/graphicengine.h" -#include "sword25/sfx/soundengine.h" +#include "sword25/fmv/movieplayer.h" #include "sword25/input/inputengine.h" +#include "sword25/kernel/kernel.h" +#include "sword25/kernel/persistenceservice.h" +#include "sword25/kernel/service_ids.h" #include "sword25/package/packagemanager.h" #include "sword25/script/script.h" -#include "sword25/fmv/movieplayer.h" -#include "sword25/kernel/persistenceservice.h" +#include "sword25/sfx/soundengine.h" + +namespace Sword25 { #define BS_LOG_PREFIX "KERNEL" -BS_Kernel * BS_Kernel::_Instance = 0; +BS_Kernel *BS_Kernel::_Instance = 0; -// Konstruktion / Destruktion -// -------------------------- BS_Kernel::BS_Kernel() : _pWindow(NULL), _Running(false), _pResourceManager(NULL), - _InitSuccess(false) -{ - // TODO: - // Messagebox ausgeben wenn nicht gelogged werden kann -> log.txt schreibgeschützt + _InitSuccess(false) { + + // Log that the kernel is beign created BS_LOGLN("created."); - // Feststellen, ob der Timer unterstützt wird. - if (!BS_Timer::IsTimerAvaliable()) - { - BS_LOG_ERRORLN("This machine doesn't support a performance counter."); - return; - } - - // Die BS_SERVICE_TABLE auslesen und kernelinterne Strukturen vorbereiten - for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++) - { - // Ist die Superclass schon registriert? - Superclass* pCurSuperclass = NULL; - std::vector::iterator Iter; + // Read the BS_SERVICE_TABLE and prepare kernel structures + for (uint i = 0; i < BS_SERVICE_COUNT; i++) { + // Is the superclass already registered? + Superclass *pCurSuperclass = NULL; + Common::Array::iterator Iter; for (Iter = _SuperclassList.begin(); Iter != _SuperclassList.end(); ++Iter) - if ((*Iter)->GetIdentifier() == BS_SERVICE_TABLE[i].SuperclassIdentifier) - { + if ((*Iter)->GetIdentifier() == BS_SERVICE_TABLE[i].SuperclassIdentifier) { pCurSuperclass = *Iter; break; } - // Falls die Superclass noch nicht registriert war, wird dies jetzt gemacht + // If the superclass isn't already registered, then add it in if (!pCurSuperclass) _SuperclassList.push_back(new Superclass(this, BS_SERVICE_TABLE[i].SuperclassIdentifier)); } - // Fensterobjekt erstellen - _pWindow = BS_Window::CreateBSWindow(0,0,0,0,false); - if (!_pWindow) - { + // Create window object + _pWindow = BS_Window::CreateBSWindow(0, 0, 0, 0, false); + if (!_pWindow) { BS_LOG_ERRORLN("Failed to create the window."); - } - else + } else BS_LOGLN("Window created."); - // Resource-Manager erstellen + // Create the resource manager _pResourceManager = new BS_ResourceManager(this); - // Random-Number-Generator initialisieren - srand(GetMilliTicks()); - - // Die Skriptengine initialisieren - // Die Skriptengine muss bereits von Kernel und nicht vom Benutzer gestartet werden, damit der Kernel seine Funktionen bei seiner Erzeugung - // registrieren kann. - BS_ScriptEngine * pScript = static_cast(NewService("script", "lua")); - if (!pScript || !pScript->Init()) - { + // Initialise the script engine + BS_ScriptEngine *pScript = static_cast(NewService("script", "lua")); + if (!pScript || !pScript->Init()) { _InitSuccess = false; return; } - // Scriptbindings des Kernels registrieren - if (!_RegisterScriptBindings()) - { + // Register kernel script bindings + if (!_RegisterScriptBindings()) { BS_LOG_ERRORLN("Script bindings could not be registered."); _InitSuccess = false; return; @@ -116,24 +93,21 @@ BS_Kernel::BS_Kernel() : _InitSuccess = true; } -BS_Kernel::~BS_Kernel() -{ - // Services in umgekehrter Reihenfolge der Erstellung endladen. - while (!_ServiceCreationOrder.empty()) - { - Superclass * superclass = GetSuperclassByIdentifier(_ServiceCreationOrder.top()); +BS_Kernel::~BS_Kernel() { + // Services are de-registered in reverse order of creation + while (!_ServiceCreationOrder.empty()) { + Superclass *superclass = GetSuperclassByIdentifier(_ServiceCreationOrder.top()); if (superclass) superclass->DisconnectService(); _ServiceCreationOrder.pop(); } - // Superclasslist leeren - while (_SuperclassList.size()) - { + // Empty the Superclass list + while (_SuperclassList.size()) { delete _SuperclassList.back(); _SuperclassList.pop_back(); } - // Fensterobjekt freigeben + // Release the window object delete _pWindow; BS_LOGLN("Window destroyed."); @@ -145,7 +119,8 @@ BS_Kernel::~BS_Kernel() // Service Methoden // ---------------- -BS_Kernel::Superclass::Superclass (BS_Kernel* pKernel, const std::string& Identifier) : + +BS_Kernel::Superclass::Superclass (BS_Kernel* pKernel, const Common::String& Identifier) : _pKernel(pKernel), _Identifier(Identifier), _ServiceCount(0), @@ -156,18 +131,24 @@ BS_Kernel::Superclass::Superclass (BS_Kernel* pKernel, const std::string& Identi _ServiceCount++; } -BS_Kernel::Superclass::~Superclass() -{ +BS_Kernel::Superclass::~Superclass() { DisconnectService(); } -std::string BS_Kernel::Superclass::GetServiceIdentifier(unsigned int Number) -{ +/** + * Gets the identifier of a service with a given superclass. + * The number of services in a superclass can be learned with GetServiceCount(). + * @param SuperclassIdentifier The name of the superclass + * z.B: "sfx", "gfx", "package" ... + * @param Number die Nummer des Services, dessen Bezeichner man erfahren will.
+ * 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 BS_Kernel::Superclass::GetServiceIdentifier(unsigned int Number) { if (Number > _ServiceCount) return NULL; unsigned int CurServiceOrd = 0; - for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++) - { + for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++) { if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier) if (Number == CurServiceOrd) return BS_SERVICE_TABLE[i].ServiceIdentifier; @@ -175,11 +156,19 @@ std::string BS_Kernel::Superclass::GetServiceIdentifier(unsigned int Number) CurServiceOrd++; } - return std::string(""); + return Common::String(""); } -BS_Service* BS_Kernel::Superclass::NewService(const std::string& ServiceIdentifier) -{ +/** + * Creates a new service with the given identifier. Returns a pointer to the service, or null if the + * service could not be created + * Note: All services must be registered in service_ids.h, otherwise they cannot be created here + * @param SuperclassIdentifier The name of the superclass of the service + * z.B: "sfx", "gfx", "package" ... + * @param ServiceIdentifier The name of the service + * For the superclass "sfx" an example could be "Fmod" or "directsound" + */ +BS_Service *BS_Kernel::Superclass::NewService(const Common::String &ServiceIdentifier) { for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++) if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier && BS_SERVICE_TABLE[i].ServiceIdentifier == ServiceIdentifier) @@ -205,10 +194,14 @@ BS_Service* BS_Kernel::Superclass::NewService(const std::string& ServiceIdentifi return NULL; } -bool BS_Kernel::Superclass::DisconnectService() -{ - if (_ActiveService) - { +/** + * Ends the current service of a superclass. Returns true on success, and false if the superclass + * does not exist or if not service was active + * @param SuperclassIdentfier The name of the superclass which is to be disconnected + * z.B: "sfx", "gfx", "package" ... + */ +bool BS_Kernel::Superclass::DisconnectService() { + if (_ActiveService) { delete _ActiveService; _ActiveService = 0; BS_LOGLN("Active service '%s' disconnected from superclass '%s'.", _ActiveServiceName.c_str(), _Identifier.c_str()); @@ -218,11 +211,9 @@ bool BS_Kernel::Superclass::DisconnectService() return false; } -BS_Kernel::Superclass* BS_Kernel::GetSuperclassByIdentifier(const std::string & Identifier) -{ - std::vector::iterator Iter; - for (Iter = _SuperclassList.begin(); Iter != _SuperclassList.end(); ++Iter) - { +BS_Kernel::Superclass *BS_Kernel::GetSuperclassByIdentifier(const Common::String &Identifier) { + Common::Array::iterator Iter; + for (Iter = _SuperclassList.begin(); Iter != _SuperclassList.end(); ++Iter) { if ((*Iter)->GetIdentifier() == Identifier) return *Iter; } @@ -231,48 +222,75 @@ BS_Kernel::Superclass* BS_Kernel::GetSuperclassByIdentifier(const std::string & return NULL; } -unsigned int BS_Kernel::GetSuperclassCount() -{ +/** + * Returns the number of register superclasses + */ +unsigned int BS_Kernel::GetSuperclassCount() { return _SuperclassList.size(); } -std::string BS_Kernel::GetSuperclassIdentifier(unsigned int Number) -{ +/** + * Returns the name of a superclass with the specified index. + * Note: The number of superclasses can be retrieved using GetSuperclassCount + * @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 BS_Kernel::GetSuperclassIdentifier(unsigned int Number) { if (Number > _SuperclassList.size()) return NULL; unsigned int CurSuperclassOrd = 0; - std::vector::iterator Iter; - for (Iter = _SuperclassList.begin(); Iter != _SuperclassList.end(); ++Iter) - { + Common::Array::iterator Iter; + for (Iter = _SuperclassList.begin(); Iter != _SuperclassList.end(); ++Iter) { if (CurSuperclassOrd == Number) return ((*Iter)->GetIdentifier()); CurSuperclassOrd++; } - return std::string(""); + return Common::String(""); } -unsigned int BS_Kernel::GetServiceCount(const std::string & SuperclassIdentifier) -{ - Superclass* pSuperclass; - if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return 0; +/** + * Returns the number of services registered with a given superclass + * @param SuperclassIdentifier The name of the superclass + * z.B: "sfx", "gfx", "package" ... + */ +unsigned int BS_Kernel::GetServiceCount(const Common::String & SuperclassIdentifier) { + Superclass *pSuperclass; + if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) + return 0; return pSuperclass->GetServiceCount(); } -std::string BS_Kernel::GetServiceIdentifier(const std::string & SuperclassIdentifier, unsigned int Number) -{ +/** + * Gets the identifier of a service with a given superclass. + * The number of services in a superclass can be learned with GetServiceCount(). + * @param SuperclassIdentifier The name of the superclass + * z.B: "sfx", "gfx", "package" ... + * @param Number die Nummer des Services, dessen Bezeichner man erfahren will.
+ * 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 BS_Kernel::GetServiceIdentifier(const Common::String & SuperclassIdentifier, unsigned int Number) { Superclass* pSuperclass; if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return NULL; return (pSuperclass->GetServiceIdentifier(Number)); } -BS_Service* BS_Kernel::NewService(const std::string& SuperclassIdentifier, const std::string& ServiceIdentifier) -{ - Superclass* pSuperclass; +/** + * Creates a new service with the given identifier. Returns a pointer to the service, or null if the + * service could not be created + * Note: All services must be registered in service_ids.h, otherwise they cannot be created here + * @param SuperclassIdentifier The name of the superclass of the service + * z.B: "sfx", "gfx", "package" ... + * @param ServiceIdentifier The name of the service + * For the superclass "sfx" an example could be "Fmod" or "directsound" + */ +BS_Service *BS_Kernel::NewService(const Common::String& SuperclassIdentifier, const Common::String& ServiceIdentifier) { + Superclass *pSuperclass; if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return NULL; // Die Reihenfolge merken, in der Services erstellt werden, damit sie später in umgekehrter Reihenfolge entladen werden können. @@ -281,56 +299,82 @@ BS_Service* BS_Kernel::NewService(const std::string& SuperclassIdentifier, const return pSuperclass->NewService(ServiceIdentifier); } -bool BS_Kernel::DisconnectService(const std::string& SuperclassIdentifier) -{ - Superclass* pSuperclass; +/** + * Ends the current service of a superclass. Returns true on success, and false if the superclass + * does not exist or if not service was active + * @param SuperclassIdentfier The name of the superclass which is to be disconnected + * z.B: "sfx", "gfx", "package" ... + */ +bool BS_Kernel::DisconnectService(const Common::String& SuperclassIdentifier) { + Superclass *pSuperclass; if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return false; return pSuperclass->DisconnectService(); } -BS_Service* BS_Kernel::GetService(const std::string& SuperclassIdentifier) -{ - Superclass* pSuperclass; +/** + * Returns a pointer to the currently active service object of a superclass + * @param SuperclassIdentfier The name of the superclass + * z.B: "sfx", "gfx", "package" ... + */ +BS_Service *BS_Kernel::GetService(const Common::String& SuperclassIdentifier) { + Superclass *pSuperclass; if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return NULL; return (pSuperclass->GetActiveService()); } -std::string BS_Kernel::GetActiveServiceIdentifier(const std::string& SuperclassIdentifier) -{ +/** + * Returns the name of the currentl active service object of a superclass. + * If an error occurs, then an empty string is returned + * @param SuperclassIdentfier The name of the superclass + * z.B: "sfx", "gfx", "package" ... + */ +Common::String BS_Kernel::GetActiveServiceIdentifier(const Common::String& SuperclassIdentifier) { Superclass * pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier); - if (!pSuperclass) return std::string(""); + if (!pSuperclass) return Common::String(""); return (pSuperclass->GetActiveServiceName()); } // ----------------------------------------------------------------------------- -int BS_Kernel::GetRandomNumber(int Min, int Max) -{ +/** + * Returns a random number + * @param Min The minimum allowed value + * @param Max The maximum allowed value + */ +int BS_Kernel::GetRandomNumber(int Min, int Max) { BS_ASSERT(Min <= Max); - unsigned int MaxInternal = (Min - Max + 1) < 0 ? - (Min - Max + 1) : (Min - Max + 1); - return (rand() % MaxInternal) + Min; + + return Min + _rnd.getRandomNumber(Max - Min + 1); } -// Timer Methoden -// -------------- -unsigned int BS_Kernel::GetMilliTicks() -{ - return BS_Timer::GetMilliTicks(); +/** + * Returns the elapsed time since startup in milliseconds + */ +unsigned int BS_Kernel::GetMilliTicks() { + return g_system->getMillis(); } -uint64_t BS_Kernel::GetMicroTicks() -{ - return BS_Timer::GetMicroTicks(); +/** + * Returns the elapsed time since the system start in microseconds. + * This method should be used only if GetMilliTick() for the desired application is inaccurate. + */ +uint64 BS_Kernel::GetMicroTicks() { + return g_system->getMillis() * 1000; } -// Sonstige Methoden +// Other methods // ----------------- -size_t BS_Kernel::GetUsedMemory() -{ +/** + * Returns how much memory is being used + */ +size_t BS_Kernel::GetUsedMemory() { + return 0; + +#ifdef SCUMMVM_DISABLED_CODE PROCESS_MEMORY_COUNTERS pmc; pmc.cb = sizeof(pmc); if (GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc))) @@ -342,53 +386,67 @@ size_t BS_Kernel::GetUsedMemory() BS_LOG_ERRORLN("Call to GetProcessMemoryInfo() failed. Error code: %d", GetLastError()); return 0; } +#endif } // ----------------------------------------------------------------------------- -BS_GraphicEngine * BS_Kernel::GetGfx() -{ +/** + * Returns a pointer to the active Gfx Service, or NULL if no Gfx service is active + */ +BS_GraphicEngine * BS_Kernel::GetGfx() { return static_cast(GetService("gfx")); } // ----------------------------------------------------------------------------- -BS_SoundEngine * BS_Kernel::GetSfx() -{ +/** + * Returns a pointer to the active Sfx Service, or NULL if no Sfx service is active + */ +BS_SoundEngine * BS_Kernel::GetSfx() { return static_cast(GetService("sfx")); } // ----------------------------------------------------------------------------- -BS_InputEngine * BS_Kernel::GetInput() -{ +/** + * Returns a pointer to the active input service, or NULL if no input service is active + */ +BS_InputEngine * BS_Kernel::GetInput() { return static_cast(GetService("input")); } // ----------------------------------------------------------------------------- -BS_PackageManager * BS_Kernel::GetPackage() -{ +/** + * Returns a pointer to the active package manager, or NULL if no manager is active + */ +BS_PackageManager * BS_Kernel::GetPackage() { return static_cast(GetService("package")); } // ----------------------------------------------------------------------------- -BS_ScriptEngine * BS_Kernel::GetScript() -{ +/** + * Returns a pointer to the script engine, or NULL if it is not active + */ +BS_ScriptEngine * BS_Kernel::GetScript() { return static_cast(GetService("script")); } // ----------------------------------------------------------------------------- -BS_MoviePlayer * BS_Kernel::GetFMV() -{ +/** + * Returns a pointer to the movie player, or NULL if it is not active + */ +BS_MoviePlayer * BS_Kernel::GetFMV() { return static_cast(GetService("fmv")); } // ----------------------------------------------------------------------------- -void BS_Kernel::Sleep(unsigned int Msecs) const -{ - ::Sleep(Msecs); +void BS_Kernel::Sleep(unsigned int Msecs) const { + g_system->delayMillis(Msecs); } + +} // End of namespace Sword25 -- cgit v1.2.3 From 293bf95c01f76c8d812a300eb038854f1246ab3d Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 31 Jul 2010 09:53:02 +0000 Subject: SWORD25: Replacing headers with ScummVM ones plus original (C) svn-id: r53188 --- engines/sword25/kernel/kernel.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) mode change 100755 => 100644 engines/sword25/kernel/kernel.cpp (limited to 'engines/sword25/kernel/kernel.cpp') diff --git a/engines/sword25/kernel/kernel.cpp b/engines/sword25/kernel/kernel.cpp old mode 100755 new mode 100644 index a12f206a99..8275db67f7 --- a/engines/sword25/kernel/kernel.cpp +++ b/engines/sword25/kernel/kernel.cpp @@ -23,6 +23,15 @@ * */ +/* + * This code is based on Broken Sword 2.5 engine + * + * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer + * + * Licensed under GNU GPL v2 + * + */ + #include "common/system.h" #include "sword25/gfx/graphicengine.h" #include "sword25/fmv/movieplayer.h" -- cgit v1.2.3 From 47904bc7b2992189bb554833f00a79ff0fea9fb8 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 6 Aug 2010 13:13:25 +0000 Subject: SWORD25: Mass-astyle. svn-id: r53222 --- engines/sword25/kernel/kernel.cpp | 146 ++++++++++++++++++-------------------- 1 file changed, 69 insertions(+), 77 deletions(-) (limited to 'engines/sword25/kernel/kernel.cpp') diff --git a/engines/sword25/kernel/kernel.cpp b/engines/sword25/kernel/kernel.cpp index 8275db67f7..6348ca0f63 100644 --- a/engines/sword25/kernel/kernel.cpp +++ b/engines/sword25/kernel/kernel.cpp @@ -23,7 +23,7 @@ * */ -/* +/* * This code is based on Broken Sword 2.5 engine * * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer @@ -54,7 +54,7 @@ BS_Kernel::BS_Kernel() : _Running(false), _pResourceManager(NULL), _InitSuccess(false) { - + // Log that the kernel is beign created BS_LOGLN("created."); @@ -115,7 +115,7 @@ BS_Kernel::~BS_Kernel() { delete _SuperclassList.back(); _SuperclassList.pop_back(); } - + // Release the window object delete _pWindow; BS_LOGLN("Window destroyed."); @@ -129,12 +129,11 @@ BS_Kernel::~BS_Kernel() { // Service Methoden // ---------------- -BS_Kernel::Superclass::Superclass (BS_Kernel* pKernel, const Common::String& Identifier) : +BS_Kernel::Superclass::Superclass(BS_Kernel *pKernel, const Common::String &Identifier) : _pKernel(pKernel), - _Identifier(Identifier), - _ServiceCount(0), - _ActiveService(NULL) -{ + _Identifier(Identifier), + _ServiceCount(0), + _ActiveService(NULL) { for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++) if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier) _ServiceCount++; @@ -147,15 +146,15 @@ BS_Kernel::Superclass::~Superclass() { /** * Gets the identifier of a service with a given superclass. * The number of services in a superclass can be learned with GetServiceCount(). - * @param SuperclassIdentifier The name of the superclass - * z.B: "sfx", "gfx", "package" ... + * @param SuperclassIdentifier The name of the superclass + * z.B: "sfx", "gfx", "package" ... * @param Number die Nummer des Services, dessen Bezeichner man erfahren will.
- * Hierbei ist zu beachten, dass der erste Service die Nummer 0 erhält. Number muss also eine Zahl zwischen - * 0 und GetServiceCount() - 1 sein. + * 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 BS_Kernel::Superclass::GetServiceIdentifier(unsigned int Number) { if (Number > _ServiceCount) return NULL; - + unsigned int CurServiceOrd = 0; for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++) { if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier) @@ -169,31 +168,27 @@ Common::String BS_Kernel::Superclass::GetServiceIdentifier(unsigned int Number) } /** - * Creates a new service with the given identifier. Returns a pointer to the service, or null if the + * Creates a new service with the given identifier. Returns a pointer to the service, or null if the * service could not be created * Note: All services must be registered in service_ids.h, otherwise they cannot be created here - * @param SuperclassIdentifier The name of the superclass of the service - * z.B: "sfx", "gfx", "package" ... - * @param ServiceIdentifier The name of the service - * For the superclass "sfx" an example could be "Fmod" or "directsound" + * @param SuperclassIdentifier The name of the superclass of the service + * z.B: "sfx", "gfx", "package" ... + * @param ServiceIdentifier The name of the service + * For the superclass "sfx" an example could be "Fmod" or "directsound" */ BS_Service *BS_Kernel::Superclass::NewService(const Common::String &ServiceIdentifier) { for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++) if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier && - BS_SERVICE_TABLE[i].ServiceIdentifier == ServiceIdentifier) - { - BS_Service* NewService = BS_SERVICE_TABLE[i].CreateMethod(_pKernel); - - if (NewService) - { + BS_SERVICE_TABLE[i].ServiceIdentifier == ServiceIdentifier) { + BS_Service *NewService = BS_SERVICE_TABLE[i].CreateMethod(_pKernel); + + if (NewService) { DisconnectService(); BS_LOGLN("Service '%s' created from superclass '%s'.", ServiceIdentifier.c_str(), _Identifier.c_str()); _ActiveService = NewService; _ActiveServiceName = BS_SERVICE_TABLE[i].ServiceIdentifier; return _ActiveService; - } - else - { + } else { BS_LOG_ERRORLN("Failed to create service '%s' from superclass '%s'.", ServiceIdentifier.c_str(), _Identifier.c_str()); return NULL; } @@ -204,10 +199,10 @@ BS_Service *BS_Kernel::Superclass::NewService(const Common::String &ServiceIdent } /** - * Ends the current service of a superclass. Returns true on success, and false if the superclass + * Ends the current service of a superclass. Returns true on success, and false if the superclass * does not exist or if not service was active - * @param SuperclassIdentfier The name of the superclass which is to be disconnected - * z.B: "sfx", "gfx", "package" ... + * @param SuperclassIdentfier The name of the superclass which is to be disconnected + * z.B: "sfx", "gfx", "package" ... */ bool BS_Kernel::Superclass::DisconnectService() { if (_ActiveService) { @@ -221,7 +216,7 @@ bool BS_Kernel::Superclass::DisconnectService() { } BS_Kernel::Superclass *BS_Kernel::GetSuperclassByIdentifier(const Common::String &Identifier) { - Common::Array::iterator Iter; + Common::Array::iterator Iter; for (Iter = _SuperclassList.begin(); Iter != _SuperclassList.end(); ++Iter) { if ((*Iter)->GetIdentifier() == Identifier) return *Iter; @@ -241,32 +236,32 @@ unsigned int BS_Kernel::GetSuperclassCount() { /** * Returns the name of a superclass with the specified index. * Note: The number of superclasses can be retrieved using GetSuperclassCount - * @param Number The number of the superclass to return the identifier for. + * @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 BS_Kernel::GetSuperclassIdentifier(unsigned int Number) { if (Number > _SuperclassList.size()) return NULL; - + unsigned int CurSuperclassOrd = 0; - Common::Array::iterator Iter; + Common::Array::iterator Iter; for (Iter = _SuperclassList.begin(); Iter != _SuperclassList.end(); ++Iter) { if (CurSuperclassOrd == Number) return ((*Iter)->GetIdentifier()); - + CurSuperclassOrd++; } - + return Common::String(""); } /** * Returns the number of services registered with a given superclass - * @param SuperclassIdentifier The name of the superclass - * z.B: "sfx", "gfx", "package" ... + * @param SuperclassIdentifier The name of the superclass + * z.B: "sfx", "gfx", "package" ... */ -unsigned int BS_Kernel::GetServiceCount(const Common::String & SuperclassIdentifier) { +unsigned int BS_Kernel::GetServiceCount(const Common::String &SuperclassIdentifier) { Superclass *pSuperclass; - if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) + if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return 0; return pSuperclass->GetServiceCount(); @@ -276,29 +271,29 @@ unsigned int BS_Kernel::GetServiceCount(const Common::String & SuperclassIdentif /** * Gets the identifier of a service with a given superclass. * The number of services in a superclass can be learned with GetServiceCount(). - * @param SuperclassIdentifier The name of the superclass - * z.B: "sfx", "gfx", "package" ... + * @param SuperclassIdentifier The name of the superclass + * z.B: "sfx", "gfx", "package" ... * @param Number die Nummer des Services, dessen Bezeichner man erfahren will.
- * Hierbei ist zu beachten, dass der erste Service die Nummer 0 erhält. Number muss also eine Zahl zwischen - * 0 und GetServiceCount() - 1 sein. + * 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 BS_Kernel::GetServiceIdentifier(const Common::String & SuperclassIdentifier, unsigned int Number) { - Superclass* pSuperclass; +Common::String BS_Kernel::GetServiceIdentifier(const Common::String &SuperclassIdentifier, unsigned int Number) { + Superclass *pSuperclass; if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return NULL; - return (pSuperclass->GetServiceIdentifier(Number)); + return (pSuperclass->GetServiceIdentifier(Number)); } /** - * Creates a new service with the given identifier. Returns a pointer to the service, or null if the + * Creates a new service with the given identifier. Returns a pointer to the service, or null if the * service could not be created * Note: All services must be registered in service_ids.h, otherwise they cannot be created here - * @param SuperclassIdentifier The name of the superclass of the service - * z.B: "sfx", "gfx", "package" ... - * @param ServiceIdentifier The name of the service - * For the superclass "sfx" an example could be "Fmod" or "directsound" + * @param SuperclassIdentifier The name of the superclass of the service + * z.B: "sfx", "gfx", "package" ... + * @param ServiceIdentifier The name of the service + * For the superclass "sfx" an example could be "Fmod" or "directsound" */ -BS_Service *BS_Kernel::NewService(const Common::String& SuperclassIdentifier, const Common::String& ServiceIdentifier) { +BS_Service *BS_Kernel::NewService(const Common::String &SuperclassIdentifier, const Common::String &ServiceIdentifier) { Superclass *pSuperclass; if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return NULL; @@ -309,12 +304,12 @@ BS_Service *BS_Kernel::NewService(const Common::String& SuperclassIdentifier, co } /** - * Ends the current service of a superclass. Returns true on success, and false if the superclass + * Ends the current service of a superclass. Returns true on success, and false if the superclass * does not exist or if not service was active - * @param SuperclassIdentfier The name of the superclass which is to be disconnected - * z.B: "sfx", "gfx", "package" ... + * @param SuperclassIdentfier The name of the superclass which is to be disconnected + * z.B: "sfx", "gfx", "package" ... */ -bool BS_Kernel::DisconnectService(const Common::String& SuperclassIdentifier) { +bool BS_Kernel::DisconnectService(const Common::String &SuperclassIdentifier) { Superclass *pSuperclass; if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return false; @@ -323,10 +318,10 @@ bool BS_Kernel::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" ... + * @param SuperclassIdentfier The name of the superclass + * z.B: "sfx", "gfx", "package" ... */ -BS_Service *BS_Kernel::GetService(const Common::String& SuperclassIdentifier) { +BS_Service *BS_Kernel::GetService(const Common::String &SuperclassIdentifier) { Superclass *pSuperclass; if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return NULL; @@ -336,11 +331,11 @@ BS_Service *BS_Kernel::GetService(const Common::String& SuperclassIdentifier) { /** * Returns the name of the currentl active service object of a superclass. * If an error occurs, then an empty string is returned - * @param SuperclassIdentfier The name of the superclass - * z.B: "sfx", "gfx", "package" ... + * @param SuperclassIdentfier The name of the superclass + * z.B: "sfx", "gfx", "package" ... */ -Common::String BS_Kernel::GetActiveServiceIdentifier(const Common::String& SuperclassIdentifier) { - Superclass * pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier); +Common::String BS_Kernel::GetActiveServiceIdentifier(const Common::String &SuperclassIdentifier) { + Superclass *pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier); if (!pSuperclass) return Common::String(""); return (pSuperclass->GetActiveServiceName()); @@ -350,8 +345,8 @@ Common::String BS_Kernel::GetActiveServiceIdentifier(const Common::String& Super /** * Returns a random number - * @param Min The minimum allowed value - * @param Max The maximum allowed value + * @param Min The minimum allowed value + * @param Max The maximum allowed value */ int BS_Kernel::GetRandomNumber(int Min, int Max) { BS_ASSERT(Min <= Max); @@ -386,12 +381,9 @@ size_t BS_Kernel::GetUsedMemory() { #ifdef SCUMMVM_DISABLED_CODE PROCESS_MEMORY_COUNTERS pmc; pmc.cb = sizeof(pmc); - if (GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc))) - { + if (GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc))) { return pmc.WorkingSetSize; - } - else - { + } else { BS_LOG_ERRORLN("Call to GetProcessMemoryInfo() failed. Error code: %d", GetLastError()); return 0; } @@ -403,7 +395,7 @@ size_t BS_Kernel::GetUsedMemory() { /** * Returns a pointer to the active Gfx Service, or NULL if no Gfx service is active */ -BS_GraphicEngine * BS_Kernel::GetGfx() { +BS_GraphicEngine *BS_Kernel::GetGfx() { return static_cast(GetService("gfx")); } @@ -412,7 +404,7 @@ BS_GraphicEngine * BS_Kernel::GetGfx() { /** * Returns a pointer to the active Sfx Service, or NULL if no Sfx service is active */ -BS_SoundEngine * BS_Kernel::GetSfx() { +BS_SoundEngine *BS_Kernel::GetSfx() { return static_cast(GetService("sfx")); } @@ -421,7 +413,7 @@ BS_SoundEngine * BS_Kernel::GetSfx() { /** * Returns a pointer to the active input service, or NULL if no input service is active */ -BS_InputEngine * BS_Kernel::GetInput() { +BS_InputEngine *BS_Kernel::GetInput() { return static_cast(GetService("input")); } @@ -430,7 +422,7 @@ BS_InputEngine * BS_Kernel::GetInput() { /** * Returns a pointer to the active package manager, or NULL if no manager is active */ -BS_PackageManager * BS_Kernel::GetPackage() { +BS_PackageManager *BS_Kernel::GetPackage() { return static_cast(GetService("package")); } @@ -439,7 +431,7 @@ BS_PackageManager * BS_Kernel::GetPackage() { /** * Returns a pointer to the script engine, or NULL if it is not active */ -BS_ScriptEngine * BS_Kernel::GetScript() { +BS_ScriptEngine *BS_Kernel::GetScript() { return static_cast(GetService("script")); } @@ -448,7 +440,7 @@ BS_ScriptEngine * BS_Kernel::GetScript() { /** * Returns a pointer to the movie player, or NULL if it is not active */ -BS_MoviePlayer * BS_Kernel::GetFMV() { +BS_MoviePlayer *BS_Kernel::GetFMV() { return static_cast(GetService("fmv")); } -- cgit v1.2.3 From 72130c284d2f3b2db8d54da96f798806082029f3 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 14 Aug 2010 19:56:15 +0000 Subject: SWORD25: Fix couple more warnings svn-id: r53236 --- engines/sword25/kernel/kernel.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/sword25/kernel/kernel.cpp') diff --git a/engines/sword25/kernel/kernel.cpp b/engines/sword25/kernel/kernel.cpp index 6348ca0f63..6150024e20 100644 --- a/engines/sword25/kernel/kernel.cpp +++ b/engines/sword25/kernel/kernel.cpp @@ -180,12 +180,12 @@ BS_Service *BS_Kernel::Superclass::NewService(const Common::String &ServiceIdent for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++) if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier && BS_SERVICE_TABLE[i].ServiceIdentifier == ServiceIdentifier) { - BS_Service *NewService = BS_SERVICE_TABLE[i].CreateMethod(_pKernel); + BS_Service *NewService_ = BS_SERVICE_TABLE[i].CreateMethod(_pKernel); - if (NewService) { + if (NewService_) { DisconnectService(); BS_LOGLN("Service '%s' created from superclass '%s'.", ServiceIdentifier.c_str(), _Identifier.c_str()); - _ActiveService = NewService; + _ActiveService = NewService_; _ActiveServiceName = BS_SERVICE_TABLE[i].ServiceIdentifier; return _ActiveService; } else { -- cgit v1.2.3 From a1d22a063b2a9de47cf3f23cac1cd73777eea321 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 16 Aug 2010 20:23:53 +0000 Subject: SWORD25: Fix warnings svn-id: r53254 --- engines/sword25/kernel/kernel.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/sword25/kernel/kernel.cpp') diff --git a/engines/sword25/kernel/kernel.cpp b/engines/sword25/kernel/kernel.cpp index 6150024e20..eb57a23232 100644 --- a/engines/sword25/kernel/kernel.cpp +++ b/engines/sword25/kernel/kernel.cpp @@ -157,11 +157,12 @@ Common::String BS_Kernel::Superclass::GetServiceIdentifier(unsigned int Number) unsigned int CurServiceOrd = 0; for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++) { - if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier) + if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier) { if (Number == CurServiceOrd) return BS_SERVICE_TABLE[i].ServiceIdentifier; else CurServiceOrd++; + } } return Common::String(""); -- cgit v1.2.3 From 485ff15d23b3ae9545f5c9df794f1326185eae7a Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 18 Aug 2010 10:52:24 +0000 Subject: SWORD25: Mass-eliminating of BS_ prefix in fmv/ and gfx/ svn-id: r53258 --- engines/sword25/kernel/kernel.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/sword25/kernel/kernel.cpp') diff --git a/engines/sword25/kernel/kernel.cpp b/engines/sword25/kernel/kernel.cpp index eb57a23232..4e61965c93 100644 --- a/engines/sword25/kernel/kernel.cpp +++ b/engines/sword25/kernel/kernel.cpp @@ -396,8 +396,8 @@ size_t BS_Kernel::GetUsedMemory() { /** * Returns a pointer to the active Gfx Service, or NULL if no Gfx service is active */ -BS_GraphicEngine *BS_Kernel::GetGfx() { - return static_cast(GetService("gfx")); +GraphicEngine *BS_Kernel::GetGfx() { + return static_cast(GetService("gfx")); } // ----------------------------------------------------------------------------- @@ -441,8 +441,8 @@ BS_ScriptEngine *BS_Kernel::GetScript() { /** * Returns a pointer to the movie player, or NULL if it is not active */ -BS_MoviePlayer *BS_Kernel::GetFMV() { - return static_cast(GetService("fmv")); +MoviePlayer *BS_Kernel::GetFMV() { + return static_cast(GetService("fmv")); } // ----------------------------------------------------------------------------- -- cgit v1.2.3 From be44216e5c1d74879d7843215ce1cd3f488b4db8 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 18 Aug 2010 12:57:47 +0000 Subject: SWORD25: eliminated BS_ prefix in all but kernel/ svn-id: r53259 --- engines/sword25/kernel/kernel.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'engines/sword25/kernel/kernel.cpp') diff --git a/engines/sword25/kernel/kernel.cpp b/engines/sword25/kernel/kernel.cpp index 4e61965c93..40833fed04 100644 --- a/engines/sword25/kernel/kernel.cpp +++ b/engines/sword25/kernel/kernel.cpp @@ -85,7 +85,7 @@ BS_Kernel::BS_Kernel() : _pResourceManager = new BS_ResourceManager(this); // Initialise the script engine - BS_ScriptEngine *pScript = static_cast(NewService("script", "lua")); + ScriptEngine *pScript = static_cast(NewService("script", "lua")); if (!pScript || !pScript->Init()) { _InitSuccess = false; return; @@ -405,8 +405,8 @@ GraphicEngine *BS_Kernel::GetGfx() { /** * Returns a pointer to the active Sfx Service, or NULL if no Sfx service is active */ -BS_SoundEngine *BS_Kernel::GetSfx() { - return static_cast(GetService("sfx")); +SoundEngine *BS_Kernel::GetSfx() { + return static_cast(GetService("sfx")); } // ----------------------------------------------------------------------------- @@ -414,8 +414,8 @@ BS_SoundEngine *BS_Kernel::GetSfx() { /** * Returns a pointer to the active input service, or NULL if no input service is active */ -BS_InputEngine *BS_Kernel::GetInput() { - return static_cast(GetService("input")); +InputEngine *BS_Kernel::GetInput() { + return static_cast(GetService("input")); } // ----------------------------------------------------------------------------- @@ -423,8 +423,8 @@ BS_InputEngine *BS_Kernel::GetInput() { /** * Returns a pointer to the active package manager, or NULL if no manager is active */ -BS_PackageManager *BS_Kernel::GetPackage() { - return static_cast(GetService("package")); +PackageManager *BS_Kernel::GetPackage() { + return static_cast(GetService("package")); } // ----------------------------------------------------------------------------- @@ -432,8 +432,8 @@ BS_PackageManager *BS_Kernel::GetPackage() { /** * Returns a pointer to the script engine, or NULL if it is not active */ -BS_ScriptEngine *BS_Kernel::GetScript() { - return static_cast(GetService("script")); +ScriptEngine *BS_Kernel::GetScript() { + return static_cast(GetService("script")); } // ----------------------------------------------------------------------------- -- cgit v1.2.3 From b01994a53bbc96da907a4c28934e644184291017 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 18 Aug 2010 12:58:22 +0000 Subject: SWORD25: removed BS_ prefix from rest of the classes. The things which are intentionally left with the prefix: BS_LOG, BS_ASSERT, BS_Rect, BS_String. svn-id: r53261 --- engines/sword25/kernel/kernel.cpp | 62 +++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'engines/sword25/kernel/kernel.cpp') diff --git a/engines/sword25/kernel/kernel.cpp b/engines/sword25/kernel/kernel.cpp index 40833fed04..8c08e18e81 100644 --- a/engines/sword25/kernel/kernel.cpp +++ b/engines/sword25/kernel/kernel.cpp @@ -47,9 +47,9 @@ namespace Sword25 { #define BS_LOG_PREFIX "KERNEL" -BS_Kernel *BS_Kernel::_Instance = 0; +Kernel *Kernel::_Instance = 0; -BS_Kernel::BS_Kernel() : +Kernel::Kernel() : _pWindow(NULL), _Running(false), _pResourceManager(NULL), @@ -75,14 +75,14 @@ BS_Kernel::BS_Kernel() : } // Create window object - _pWindow = BS_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 BS_LOGLN("Window created."); // Create the resource manager - _pResourceManager = new BS_ResourceManager(this); + _pResourceManager = new ResourceManager(this); // Initialise the script engine ScriptEngine *pScript = static_cast(NewService("script", "lua")); @@ -102,7 +102,7 @@ BS_Kernel::BS_Kernel() : _InitSuccess = true; } -BS_Kernel::~BS_Kernel() { +Kernel::~Kernel() { // Services are de-registered in reverse order of creation while (!_ServiceCreationOrder.empty()) { Superclass *superclass = GetSuperclassByIdentifier(_ServiceCreationOrder.top()); @@ -129,7 +129,7 @@ BS_Kernel::~BS_Kernel() { // Service Methoden // ---------------- -BS_Kernel::Superclass::Superclass(BS_Kernel *pKernel, const Common::String &Identifier) : +Kernel::Superclass::Superclass(Kernel *pKernel, const Common::String &Identifier) : _pKernel(pKernel), _Identifier(Identifier), _ServiceCount(0), @@ -139,7 +139,7 @@ BS_Kernel::Superclass::Superclass(BS_Kernel *pKernel, const Common::String &Iden _ServiceCount++; } -BS_Kernel::Superclass::~Superclass() { +Kernel::Superclass::~Superclass() { DisconnectService(); } @@ -152,7 +152,7 @@ BS_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 BS_Kernel::Superclass::GetServiceIdentifier(unsigned int Number) { +Common::String Kernel::Superclass::GetServiceIdentifier(unsigned int Number) { if (Number > _ServiceCount) return NULL; unsigned int CurServiceOrd = 0; @@ -177,11 +177,11 @@ Common::String BS_Kernel::Superclass::GetServiceIdentifier(unsigned int Number) * @param ServiceIdentifier The name of the service * For the superclass "sfx" an example could be "Fmod" or "directsound" */ -BS_Service *BS_Kernel::Superclass::NewService(const Common::String &ServiceIdentifier) { +Service *Kernel::Superclass::NewService(const Common::String &ServiceIdentifier) { for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++) if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier && BS_SERVICE_TABLE[i].ServiceIdentifier == ServiceIdentifier) { - BS_Service *NewService_ = BS_SERVICE_TABLE[i].CreateMethod(_pKernel); + Service *NewService_ = BS_SERVICE_TABLE[i].CreateMethod(_pKernel); if (NewService_) { DisconnectService(); @@ -205,7 +205,7 @@ BS_Service *BS_Kernel::Superclass::NewService(const Common::String &ServiceIdent * @param SuperclassIdentfier The name of the superclass which is to be disconnected * z.B: "sfx", "gfx", "package" ... */ -bool BS_Kernel::Superclass::DisconnectService() { +bool Kernel::Superclass::DisconnectService() { if (_ActiveService) { delete _ActiveService; _ActiveService = 0; @@ -216,7 +216,7 @@ bool BS_Kernel::Superclass::DisconnectService() { return false; } -BS_Kernel::Superclass *BS_Kernel::GetSuperclassByIdentifier(const Common::String &Identifier) { +Kernel::Superclass *Kernel::GetSuperclassByIdentifier(const Common::String &Identifier) { Common::Array::iterator Iter; for (Iter = _SuperclassList.begin(); Iter != _SuperclassList.end(); ++Iter) { if ((*Iter)->GetIdentifier() == Identifier) @@ -230,7 +230,7 @@ BS_Kernel::Superclass *BS_Kernel::GetSuperclassByIdentifier(const Common::String /** * Returns the number of register superclasses */ -unsigned int BS_Kernel::GetSuperclassCount() { +unsigned int Kernel::GetSuperclassCount() { return _SuperclassList.size(); } @@ -240,7 +240,7 @@ unsigned int BS_Kernel::GetSuperclassCount() { * @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 BS_Kernel::GetSuperclassIdentifier(unsigned int Number) { +Common::String Kernel::GetSuperclassIdentifier(unsigned int Number) { if (Number > _SuperclassList.size()) return NULL; unsigned int CurSuperclassOrd = 0; @@ -260,7 +260,7 @@ Common::String BS_Kernel::GetSuperclassIdentifier(unsigned int Number) { * @param SuperclassIdentifier The name of the superclass * z.B: "sfx", "gfx", "package" ... */ -unsigned int BS_Kernel::GetServiceCount(const Common::String &SuperclassIdentifier) { +unsigned int Kernel::GetServiceCount(const Common::String &SuperclassIdentifier) { Superclass *pSuperclass; if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return 0; @@ -278,7 +278,7 @@ unsigned int BS_Kernel::GetServiceCount(const Common::String &SuperclassIdentifi * 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 BS_Kernel::GetServiceIdentifier(const Common::String &SuperclassIdentifier, unsigned int Number) { +Common::String Kernel::GetServiceIdentifier(const Common::String &SuperclassIdentifier, unsigned int Number) { Superclass *pSuperclass; if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return NULL; @@ -294,7 +294,7 @@ Common::String BS_Kernel::GetServiceIdentifier(const Common::String &SuperclassI * @param ServiceIdentifier The name of the service * For the superclass "sfx" an example could be "Fmod" or "directsound" */ -BS_Service *BS_Kernel::NewService(const Common::String &SuperclassIdentifier, const Common::String &ServiceIdentifier) { +Service *Kernel::NewService(const Common::String &SuperclassIdentifier, const Common::String &ServiceIdentifier) { Superclass *pSuperclass; if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return NULL; @@ -310,7 +310,7 @@ BS_Service *BS_Kernel::NewService(const Common::String &SuperclassIdentifier, co * @param SuperclassIdentfier The name of the superclass which is to be disconnected * z.B: "sfx", "gfx", "package" ... */ -bool BS_Kernel::DisconnectService(const Common::String &SuperclassIdentifier) { +bool Kernel::DisconnectService(const Common::String &SuperclassIdentifier) { Superclass *pSuperclass; if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return false; @@ -322,7 +322,7 @@ bool BS_Kernel::DisconnectService(const Common::String &SuperclassIdentifier) { * @param SuperclassIdentfier The name of the superclass * z.B: "sfx", "gfx", "package" ... */ -BS_Service *BS_Kernel::GetService(const Common::String &SuperclassIdentifier) { +Service *Kernel::GetService(const Common::String &SuperclassIdentifier) { Superclass *pSuperclass; if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return NULL; @@ -335,7 +335,7 @@ BS_Service *BS_Kernel::GetService(const Common::String &SuperclassIdentifier) { * @param SuperclassIdentfier The name of the superclass * z.B: "sfx", "gfx", "package" ... */ -Common::String BS_Kernel::GetActiveServiceIdentifier(const Common::String &SuperclassIdentifier) { +Common::String Kernel::GetActiveServiceIdentifier(const Common::String &SuperclassIdentifier) { Superclass *pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier); if (!pSuperclass) return Common::String(""); @@ -349,7 +349,7 @@ Common::String BS_Kernel::GetActiveServiceIdentifier(const Common::String &Super * @param Min The minimum allowed value * @param Max The maximum allowed value */ -int BS_Kernel::GetRandomNumber(int Min, int Max) { +int Kernel::GetRandomNumber(int Min, int Max) { BS_ASSERT(Min <= Max); return Min + _rnd.getRandomNumber(Max - Min + 1); @@ -358,7 +358,7 @@ int BS_Kernel::GetRandomNumber(int Min, int Max) { /** * Returns the elapsed time since startup in milliseconds */ -unsigned int BS_Kernel::GetMilliTicks() { +unsigned int Kernel::GetMilliTicks() { return g_system->getMillis(); } @@ -366,7 +366,7 @@ unsigned int BS_Kernel::GetMilliTicks() { * Returns the elapsed time since the system start in microseconds. * This method should be used only if GetMilliTick() for the desired application is inaccurate. */ -uint64 BS_Kernel::GetMicroTicks() { +uint64 Kernel::GetMicroTicks() { return g_system->getMillis() * 1000; } @@ -376,7 +376,7 @@ uint64 BS_Kernel::GetMicroTicks() { /** * Returns how much memory is being used */ -size_t BS_Kernel::GetUsedMemory() { +size_t Kernel::GetUsedMemory() { return 0; #ifdef SCUMMVM_DISABLED_CODE @@ -396,7 +396,7 @@ size_t BS_Kernel::GetUsedMemory() { /** * Returns a pointer to the active Gfx Service, or NULL if no Gfx service is active */ -GraphicEngine *BS_Kernel::GetGfx() { +GraphicEngine *Kernel::GetGfx() { return static_cast(GetService("gfx")); } @@ -405,7 +405,7 @@ GraphicEngine *BS_Kernel::GetGfx() { /** * Returns a pointer to the active Sfx Service, or NULL if no Sfx service is active */ -SoundEngine *BS_Kernel::GetSfx() { +SoundEngine *Kernel::GetSfx() { return static_cast(GetService("sfx")); } @@ -414,7 +414,7 @@ SoundEngine *BS_Kernel::GetSfx() { /** * Returns a pointer to the active input service, or NULL if no input service is active */ -InputEngine *BS_Kernel::GetInput() { +InputEngine *Kernel::GetInput() { return static_cast(GetService("input")); } @@ -423,7 +423,7 @@ InputEngine *BS_Kernel::GetInput() { /** * Returns a pointer to the active package manager, or NULL if no manager is active */ -PackageManager *BS_Kernel::GetPackage() { +PackageManager *Kernel::GetPackage() { return static_cast(GetService("package")); } @@ -432,7 +432,7 @@ PackageManager *BS_Kernel::GetPackage() { /** * Returns a pointer to the script engine, or NULL if it is not active */ -ScriptEngine *BS_Kernel::GetScript() { +ScriptEngine *Kernel::GetScript() { return static_cast(GetService("script")); } @@ -441,13 +441,13 @@ ScriptEngine *BS_Kernel::GetScript() { /** * Returns a pointer to the movie player, or NULL if it is not active */ -MoviePlayer *BS_Kernel::GetFMV() { +MoviePlayer *Kernel::GetFMV() { return static_cast(GetService("fmv")); } // ----------------------------------------------------------------------------- -void BS_Kernel::Sleep(unsigned int Msecs) const { +void Kernel::Sleep(unsigned int Msecs) const { g_system->delayMillis(Msecs); } -- cgit v1.2.3 From 086f5961b6575c50bb386750b6e9a3ed1efdd8cd Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 2 Sep 2010 12:14:04 +0000 Subject: SWORD25: unsigned int -> uint svn-id: r53309 --- engines/sword25/kernel/kernel.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'engines/sword25/kernel/kernel.cpp') diff --git a/engines/sword25/kernel/kernel.cpp b/engines/sword25/kernel/kernel.cpp index 8c08e18e81..a398fdfa38 100644 --- a/engines/sword25/kernel/kernel.cpp +++ b/engines/sword25/kernel/kernel.cpp @@ -134,7 +134,7 @@ Kernel::Superclass::Superclass(Kernel *pKernel, const Common::String &Identifier _Identifier(Identifier), _ServiceCount(0), _ActiveService(NULL) { - for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++) + for (uint i = 0; i < BS_SERVICE_COUNT; i++) if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier) _ServiceCount++; } @@ -152,11 +152,11 @@ 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(unsigned int Number) { +Common::String Kernel::Superclass::GetServiceIdentifier(uint Number) { if (Number > _ServiceCount) return NULL; - unsigned int CurServiceOrd = 0; - for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++) { + uint CurServiceOrd = 0; + for (uint i = 0; i < BS_SERVICE_COUNT; i++) { if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier) { if (Number == CurServiceOrd) return BS_SERVICE_TABLE[i].ServiceIdentifier; @@ -178,7 +178,7 @@ Common::String Kernel::Superclass::GetServiceIdentifier(unsigned int Number) { * For the superclass "sfx" an example could be "Fmod" or "directsound" */ Service *Kernel::Superclass::NewService(const Common::String &ServiceIdentifier) { - for (unsigned int i = 0; i < BS_SERVICE_COUNT; i++) + for (uint i = 0; i < BS_SERVICE_COUNT; i++) if (BS_SERVICE_TABLE[i].SuperclassIdentifier == _Identifier && BS_SERVICE_TABLE[i].ServiceIdentifier == ServiceIdentifier) { Service *NewService_ = BS_SERVICE_TABLE[i].CreateMethod(_pKernel); @@ -230,7 +230,7 @@ Kernel::Superclass *Kernel::GetSuperclassByIdentifier(const Common::String &Iden /** * Returns the number of register superclasses */ -unsigned int Kernel::GetSuperclassCount() { +uint Kernel::GetSuperclassCount() { return _SuperclassList.size(); } @@ -240,10 +240,10 @@ unsigned int Kernel::GetSuperclassCount() { * @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(unsigned int Number) { +Common::String Kernel::GetSuperclassIdentifier(uint Number) { if (Number > _SuperclassList.size()) return NULL; - unsigned int CurSuperclassOrd = 0; + uint CurSuperclassOrd = 0; Common::Array::iterator Iter; for (Iter = _SuperclassList.begin(); Iter != _SuperclassList.end(); ++Iter) { if (CurSuperclassOrd == Number) @@ -260,7 +260,7 @@ Common::String Kernel::GetSuperclassIdentifier(unsigned int Number) { * @param SuperclassIdentifier The name of the superclass * z.B: "sfx", "gfx", "package" ... */ -unsigned int Kernel::GetServiceCount(const Common::String &SuperclassIdentifier) { +uint Kernel::GetServiceCount(const Common::String &SuperclassIdentifier) { Superclass *pSuperclass; if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return 0; @@ -278,7 +278,7 @@ unsigned int Kernel::GetServiceCount(const Common::String &SuperclassIdentifier) * 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 &SuperclassIdentifier, unsigned int Number) { +Common::String Kernel::GetServiceIdentifier(const Common::String &SuperclassIdentifier, uint Number) { Superclass *pSuperclass; if (!(pSuperclass = GetSuperclassByIdentifier(SuperclassIdentifier))) return NULL; @@ -358,7 +358,7 @@ int Kernel::GetRandomNumber(int Min, int Max) { /** * Returns the elapsed time since startup in milliseconds */ -unsigned int Kernel::GetMilliTicks() { +uint Kernel::GetMilliTicks() { return g_system->getMillis(); } @@ -447,7 +447,7 @@ MoviePlayer *Kernel::GetFMV() { // ----------------------------------------------------------------------------- -void Kernel::Sleep(unsigned int Msecs) const { +void Kernel::Sleep(uint Msecs) const { g_system->delayMillis(Msecs); } -- cgit v1.2.3 From 54ccc8f4c906cd4f84c955581c0368886a7a9c78 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 3 Oct 2010 13:25:22 +0000 Subject: SWORD25: Enforced code naming conventions in script/* svn-id: r53391 --- engines/sword25/kernel/kernel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/sword25/kernel/kernel.cpp') diff --git a/engines/sword25/kernel/kernel.cpp b/engines/sword25/kernel/kernel.cpp index a398fdfa38..3e7e7f125f 100644 --- a/engines/sword25/kernel/kernel.cpp +++ b/engines/sword25/kernel/kernel.cpp @@ -86,7 +86,7 @@ Kernel::Kernel() : // Initialise the script engine ScriptEngine *pScript = static_cast(NewService("script", "lua")); - if (!pScript || !pScript->Init()) { + if (!pScript || !pScript->init()) { _InitSuccess = false; return; } -- cgit v1.2.3